YouTube каталог
The Ultimate JAX Beginner First Steps into High-Performance AI
📦 Загальне
en

JAX: Швидкий старт у AI для лідерів технологій

Coding Hives19 днів тому26 берез. 2026Impact 6/10
AI Аналіз

Відео показує, як JAX — бібліотека Google — прискорює числові обчислення завдяки JIT-компіляції та автоматичному обчисленню градієнтів. Почасники навчаться ставити бібліотеку, працювати з масивами та порівнювати швидкість з NumPy. Це робить JAX інструментом вибору для тренування великих моделей на TPU.

Ключові тези

  • JAX — це відкрита бібліотека Google для швидких числових обчислень, аналог NumPy, але оптимізований під AI.
  • Головні можливості: автоматичне обчислення градієнтів (grad) та JIT‑компіляція через XLA, що забезпечує майже миттєве виконання після першого запуску.
  • Демонстрація для початківців включає встановлення, роботу з масивами та порівняння швидкості, де другий запуск JAX практично не бере часу.
Можливості

🟢 Можливості — починайте навчатися JAX зараз, щоб отримати досвід роботи з TPU‑оптимізованими навантаженнями та підвищити свою конкурентоспроможність у дослідженнях AI. 🔴 Загрози — залежність від одного екосистемного постачальника може обмежити вибір інфраструктури та збільшити витрати при переході на інші платформи.

Нюанси

Більшість переглядачів фокусується на швидкості JIT, проте не помічають, що immutable масиви JAX можуть обмежити гнучкість у деяких алгоритмах, що вимагають ін‑плейс модифікацій. Також прискорення більш помітне на великих масивах та TPU, а не на звичайних CPU/GPU. Таким чином, вигода найбільше проявляється у дослідженнях, а не у швидкому прототипі на ноутбуці.

Опис відео

So guys welcome back to another session from approns to algorithm. So in today's session we are going to learn some basic things about Jax AI. I will explain it in a beginner friendly way. So I think you will be feel comfortable with that. But unfortunately we have only two people in the session but no way I think this is just a beginning. We will be having more people in the coming sessions. You need to bring more people to session. So it will be helpful for them also. Yeah. So first I will share my screen. You can see the screen, right? So as I told we are going to understand about Jazz A as this is the AI era as we can you see the screen? >> Yes. >> Okay. So here uh what we are going to learn is we are going to learn the basics of a as we all are using Gemini and almost chat GPT and almost all other platforms of AI but you you need to know this Gemini is made up of the basic of I mean you know on the top of this Jax AI this Geminina is built. So today we are going to understand about some basics of Jax AI what it is how it performs more faster and what are the features of this Jax AI. These all things today we are going to learn. So here the first thing is DAX is an opensource library. It is created by Google and the thing is it is really very fast very not we cannot say it is very fast it is very very fast and what is the difference we can say it has uh you people are aware of numpy right numpy is a library in python so this j is something similar to numpy with some other features like the features mainly we can say uh grade and jit and more are there today's session I'm just focusing on the beginner level that is why I'm not adding more things. I just want to give a basic introduction about what tax is so that you can uh you can uh go step by step into it. Okay. So the basically we can say it is an open-source Python library created by Google for fast numerical computing. I mean we can do it in a more lightning speed and it is mainly used for machine learning and AI research areas. But here the thing is it uh looks and feels just like numpy which is the tool we can use in uh mass in python. I think you people are used numpy right at least you know numpy there is a library named numpy right? So uh but J has some additional key features optimized specifically for AI. We can say it can automatically compute math gradients. Gradient means you can you know we we already learned derivatives in mathematics right. So some mathematical calculations there is very easy in JS that is we are saying grad grad for gradient it can compile our code and make it uh run at light speed. Okay as we know python is a uh half interpret half compiled programming language we can say right. So first it will compile uh I mean first it will interpret the line line by line code and it will generate it into bite code then it run right but J has something different that I will explain later. So that makes this jack very speed. So because of these all things J is used by many teams to build and train LLMs. LLM means large language model. As I told Germany 3 uh uses this jacks every day. This is trained on Google's TPUs. As we are using in the normal computer, we are using CPU like central processing unit. But in the Google they are using TPU TPUs and one more is their GPU. So these are the top uh choices for the researchers to find more uh and better uh developments. So we can say here you can see here one more one more slide I think. Yeah. Yeah. So here we can say this grad is the brain of uh this jack. I mean here in AI the computer learns by finding the slope of a function. Slope means the derivative of a function. derivative I think you know for example if you are telling a derivative of x² that means 2x this is just simple mass only not that much complicated just understand slope means the derivatives okay so this grad in AI the computer learns by finding the slope of a function so usually we can find this using simply this grad function we can find this okay that is we are telling here this grad and the second one is jit that means I told j is very fast. I mean the engine is very fast. So JIT means just in time compilation that means it simplifies our code and hands it to our hardware in a way that is optimized for speed that I will explain in detail uh later I mean in the session later. Okay. So this jet uh this JIT makes the I mean this JIT makes the uh I mean execution very fast. Okay. So that is the difference. This grad is for the calculation. It is calculating the gradient or derivative and it is the engine which makes it very fast. Okay. Any if you are not understanding please give a thumbs up or anything or any uh chat or anything no problem. Okay. If you are not understanding please let me know otherwise I don't know you are getting it or not. Please uh like make it interactive. Clear. Hello Yes. >> Yeah. >> Okay. Now, now this is now uh it's your time to open Google Collab. Please open Google Collab and I will share a link so you can get the code from there. Just copy the code I'm telling and paste it to your Google Collab. You will get know like you don't need to type everything. I will share share all the details as well. Okay. just open or your Google collab and uh open a Google notebook. I will share that link. Uh I think I saved it somewhere. I think this one, right? Yeah. I'm sharing that link in this uh chat box. You can uh copy the link in your copy uh from here and paste it in your laptop and uh are you able to access the uh document? Okay. Then open Google collab. You will get something like this. You got something like this. You are seeing in this my screen. Please don't uh copy anything now. I will tell you step by step what to do. At that time only you need to copy uh from that document and paste here. Okay? so that you know what we are doing. Don't don't simply copy and paste here. I will tell you step by step what to do. >> Yeah. Yeah. Open a new notebook. Yeah. Open a new notebook. Then here you can see this one plus code. Right. Just click this plus code. So you will get a cell like this. Got it. Uh, Fatima, you got it. >> Yeah. Tell me what what is what is the issue? note like like what is the link you got collab okay now then click uh plus code you uh click here plus code okay now simply you type print hello so then run it you are getting hello just simply checking is it working or not just type print hello then uh run it It's for checking only are we are getting u I mean it's working or not. We need to check that. That's it. Working right? >> Yes. >> Okay. Now so what first we need to do is first we need to install this DAX and DAX library. The first statement in that uh document is this one pip install jacks and jack slip. So what is this is we are just installing jacks here. As you know when we are using VS code we need to uh set up the environment and everything right. But here the thing is we don't need to make any environment. We just need to install whatever we need. So here first statement you can copy from this uh sheet pip install jack slip and then you can click the run here. Okay. This is for the run here. One here. This is the run symbol. You can click this one. Okay. Just try it and let tell me after finish it. >> Okay. And Fatima you you done? Okay. Okay. Now what we need to what we need to do next is I will just show you one more thing here. Yeah. As we know uh in numpy normally we are using like import numpy as np or something like that right? You I think you tried this uh numpy. I hope so. So in j what is the difference is here import jax.numpy as an alias name. This is the alias name right? J NP anything you can give. So here only difference between numpy and jax is we are giving here import jax.numpy numpy. Normally we are simply import numpy as jnp something like that we are giving but in tags what we are going to do is import jags that library name dot numpy okay so that is the only difference here so you just copy the second code from uh that document and paste in your col okay that is import jaxnumpy as jnp and the two and the next two also like x we are giving two arrays is uh the first one is 1 2 3 and the second one is 4 5 6. Okay, it is something some kind of a list only. So you can just copy until this type of X. Okay, until this type of X just copy from the document and paste here. Once done, please let me know so that I will explain. Yeah. So here what is the thing is this import jax dot numpy as uh jnp is we are calling this jazz numpy to keep it separate from numpy. If we are not using numpy we can simply use import numpy as some alias or something like that. So what is what is the use of an alias? Can you tell me anyone? >> Yeah, because otherwise we need to write this numpy dash numpy everywhere like this, right? We can make it more shorter, more useful, more readable. That is why we are using this alias. Okay. So here that is the first line of code that we are importing uh that uh jacks.numpy. Then we are creating two arrays. Okay, we are creating two jacks arrays. So here each array contains three elements 1 2 3 and 4 5 6. And the second uh next statement is print result x + y. That means it will add the corresponding elements. So we are getting the result as five uh 7 and 9 and this type of x I know I think you know it will show the type for example indoor care or whatever it is. So here the array is tax array right. So we are getting the type as Jags. Clear. Any doubt you can ask. May I continue with the next next next session. Yeah. So here uh next. So this is about only the JS array. So you if you know numpy it is easy to you uh easy for you to learn jacks no not that much a big problem it is really easy only but later if you are going for more detailed complicated things you need to focus on more things these are the basic uh things only so we will go for the next session what it is yeah I told next the brain of a uh jaxis thing grad so grad means gradient that means we can uh calculate the gradient or uh we can say the derivative. I I hope you know what is mean by derivative right? No. Do you know derivative? I think that we learned in math uh in + 1 + 2 somewhere. Okay. So here for example I will I will explain this function here. Here we have a function named square function. it will return square of a number. For example, if I'm uh giving five, the answer will be 25. Okay. So here grad function is equal to jack dot grad. So we are calling the library jacks then dot grad then this square function. So here we know we are I told if we are giving uh for example x square we are giving the derivative of x² is 2x that is simple mathematics only I cannot explain that in a computer that we learned in our mathematics session. So x² the derivative of x² is 2x only. So here when I'm giving a grad function of five we are giving we are getting the answer as 2x that is 2 into the value of x is five that is we are getting the answer as 10 also we are calculating slope of x also using this gradient only that is why here it is mentioned the slope at x= 5 is 10 clear so this is just a real uh jack's magic we can say as he mentioned here so now uh you just copy this code in that document like this uh grad thing uh copy from the document and paste it in your collab here. So here also we need to import this grad from J. So the another uh function is grad. First one we learned uh numpy jacks. Numpy that is simple like a normal numpy and the next one is uh the brain of J that is grad. Grad means we are calculating the gradient or we can say derivative of a function. Okay. If you are not familiar with the derivative just go for a short video after the session like 10 minute video you will understand what is mean by derivative that is some mathematics only. Okay. So here just copy uh this this much portion only and paste here and run it and we will try to change something here so that you can uh know what is the difference in each guys. You tried it. Please give a thumbs up at least. Yeah, I need to know you are doing or not. Okay. >> Yeah. Yeah. I will Yeah. Okay. Uh okay. Now sorry my daughter is coming and disturbing. That is why Yeah. I will tell you. Yeah. Here in this you can try some other number. uh here for example I will tell you if you are putting here x x x² this one x square uh derivative of x² is 2x okay here you just try x cube then you will get 3 x² answer just try with the three so the derivative of x cube is 3x² how I can write here yeah just try here instead of two you just put 3 so it will get 3x² so 3 into uh 25 3 into 25 is uh 75 right? So you will get 75. Are you getting the answer 75? Yeah, yeah, yeah. That's it. So now you are you are clear, right? >> Okay. So now we will go for the next one. Fatima, you are also clear, right? >> Yes sir. >> Okay. Uh now we will go for the next one. Uh yeah. So next I will tell you some very I really really the important thing or import like uh the thing which interested me to Jax is this one this cheat is I told just in time compiler as it is really very much speed I will tell you I will give you a demo for that also so you will know like what what I am telling like the real demo I will show you the speed difference normally when we are running with the numpy it is like a normal execution only as we know like uh normal execution like how the how Python program is running. But when we are using JAS what is happening is it will uh it will compile the old function first. It will compile the old function. Okay. And there is one thing that is Excel. I think it is an accelerator. So it will store the compiled code in a cache memory in our computer. Okay. Then when we are running the code, it will take uh that uh compiled code and it will run at that time. Okay. So it will compile only one time only. That means whenever we are running a jack program, I mean whenever we are running a program with this JIT, JIT is a decorator. Okay, that I will tell you a detail. So when we are adding a JIT decorator in our program, so what is happening is it will compile the program first. Okay, only one time it will compile and it will store it in our cache memory. And here we are using one thing that is named XLA and for the later executions it will only run only like it will not compile. So normal in normal Python every time whenever we are running a program it will compile it will run. So it will take more time. I mean every time the every time we are running it will take the same time only. But when we are using JAX the first run will be take more time because first time it is compelling also. Okay. From the second onwards the I mean the time taken for execution will be very very less. Okay. So that is here I mentioned here J second run is lightning speed as compilation is cached. Okay. Clear. I hope it clear. Anything please ask. Okay. Clear, right? No response. Is it clear? >> I didn't see that. Yeah. Okay. So uh this one also I told like why Git is so fast. So I mean I will tell you this is one example as we all are every time we are every time in kitchen. Yeah. So here uh like whenever you are going to make a cake at the first time you will read the recipe one by one line and you will you will take the ingredient it will take more time right. So after you you are a good cook I mean you can you baked more more than 10 cake you are more expert that in that field and you can make the cake in less time right. So that is the difference here we can say with this normal coding and using this J and here one more point you need to mention that this XLA this Excel is the language that uses JS uh make it more faster compared to normal programming. Okay. So I will uh show you the demo also so that you will get more clarity. So here uh I will show you some one more thing I missed to tell you like the immutability. I I mean I know I think you know what is mean by mutable and immutable right? So mutable means we can say uh we can be we can edit that one right. Mutable means mutable means it is permanent. We cannot edit that. So numpy as you know we can edit the array. For example, if I am declaring an array as a numpy array after initializing, I can change the array also. But J is something like a baked cake. I I mean when we bake the cake, we cannot change it, right? We cannot change the ingredient or anything we cannot change. So the data is fixed after creation. That is uh the difference between one difference we can say the main difference is numpy is mutable and jazz is immutable. Clear? Yeah. Uh yeah, this is the difference. Uh I will I will show you the demo after this session after I mean after this uh PowerPoint presentation so that you will get more clarity. So here I just made a comparison between Numpy Jax and PyTorch or TensorFlow. So you can see here numpy is like a reliable calculator we can say but uh dax is something like a fasten numpy and but as you know pytorch and tensorflow are more heavy things and speed is numpy is a very like normal for small data but j is incredible speed and it can it can handle huge data. uh PyTorch is excellent like better than numpy but it is like it is not that much than J and this numpy we are using for uh learning and basic data calculations but JAX is more used in this rich research and high speeded uh AI things also machine learning area we are using uh JAX and PyTorch is used in production industry apps and easy like coming to the learning curve I mean numpy is very easy to learn that is very very very easy to learn. Jax is also easy if you know numpy but this pytor and tensorflow is harder to learn than this numpy and jack. So jack is really very easy is your one two for learn. I think after the session you all go for search jacks and start learn. So now I will show you that uh now you copy that one uh like the last session last code in our uh sheet and paste it in your uh collab and I will explain this. Okay, just copy and paste. Copy and paste and tell me I will explain that. done. Uh when is it done? Okay. So now I will explain this then you then only you can try to run. Okay. So here the first line is import numpy as np. Why I am using here numpy as also because I need to show you the difference between normal numpy and norm and the one that is a jax numpy. Okay. So we will try with the numpy normal numpy and jax numpy and I will show you the time difference like how fast it is. Okay. And the next one is import time. Then I I told we have this jit thing that is from jazz import jit. Okay. And the next thing is you can see here I am creating million numbers. Here it will give a cross product of 1 million numbers. So I am creating two arrays. One is normal numpy array that is x np and the second array is jax array that is x_jax and both are with 1 million numbers. This is the cross product. I mean I know I think you know the like you can say cross multiplication of a matrix you know right? Uh what other name I can say? Yeah. 1,000 into,000. So yeah. Yeah. So you will get 1 million numbers in X NP and X_JS. Clear. Now what I need to do know is I need to know how much time it will take to find the cross product. So here first I will calculate the start time. Start is equal to time to time. So it will get the current time. Then I will this is the dot product. So this will calculate uh this will calculate uh the cross multiplication I mean the uh multiplication of two matrices this one this one right I mean XNP and XNP so 1,000 uh 1,000 into th00and like 1 million members numbers we will get as output and here we will calculate the time like how much time it will take for a normal numpy to execute or calculate 1 million numbers okay so this is the normal numpy Now I am going to show you how Jax will make it more fast. So for that I told we have a decorator that is named JIT. Okay. So decorator starts with at symbol. So at JIT and here we are uh defining a function J dot. So here also we are uh making a dot function. Dot means uh the multiplication matrix. Okay. So here I am passing this X. So here we are getting this one. So now how I am calculating here is this is a function. So here I will call the function I told in the jazz first time it will uh include the compilation also. Okay. And from the second time onwards only run. So that is why here I mentioned first run includes the compilation. So here start is equal to time dot time. That means it will get the starting time. Then it will call the function j dot of x. So it will calculate the cross product I mean the multiplication matrix. Now we will uh return the time dot time minus start that means it will show the uh difference between the starting and ending. So you will get the exact time for the first run. Clear? Now we will go for the second run. Second run I told whenever we are using uh git the first time it will compile and it will store the uh I mean the machine code in the cache memory. So for from the second run it will not compile it will just run only. So it will make more speed. So here what we are going to do is we will do the same code here just making the content like to make you better like Jack's second run. This is Jack's first run that is the thing. Okay. Now just try to run this code. You can know the difference. Just try to run this code. >> Yeah. Yeah. You can see here. Yeah. The number time is this one, right? And the first run is this one. And the second run, you can see almost zero. So it it didn't take more that much time. >> Yeah. >> Clear. So yeah. So that is the thing. Uh yeah. So that is the thing you need to understand. So the question is why the first run take more time? Because only the first time it is compiling it is storing the machine code into the cache memory and from from the second run onwards it will take that machine code and run. Okay. No need to compile again and again. That is the difference between the normal programming and the jack that this this feature makes it more faster than any other code. Clear? Okay. So yeah. So uh because of this uh Gemini is built on top of this JS that is why when we are searching something we are getting a results very fast. Especially JAS is used more for this mathematical calculations. It is like this is this we are doing some basic only but for more uh more detailed calculations jags is used. Okay. So uh this is the I I told I just covered some basic things only uh as a first session. Next week I will give you more advanced like the next episode of this uh jacks. So don't forget to join the next session as well so that we can uh know what to >> Yeah. Yeah. >> Yeah. As I told when we are uh normal program J normal program every time whenever we are running a program it will compile every time. For example, if I'm running first time or second time or third time, it will compile every time and then it runs. Okay. But here Jax has one thing like Excel. This is accelerated program. And also I will share you one more thing for you. This is one is uh the Jax official document. Okay. If you are interested in JAX more, you can go here as well. This is really nice nice uh nice documentation. I'm referring from here as well. So as I as you told you can I will click here just in time compilation mainly open XLA that is the thing. So >> this is we can say it is like accelerator controller we can say like uh it is more related to an opensource thing where we are storing these all things >> and like Yeah. >> Yeah. Yeah. Yeah. As I told I just told some easy things only in this jack like we have a lot of things. This is only I we can say 0.1 percentage thing only I just shared in this session. Okay. We have a lot of things to share like this XLA we can cover in a day like a lot of things I need to share with you also uh in distributed system I think you heard about distributed systems right u also sharding you did you heard about sharding these all things like a lot of other features also jacks include so I want to make it more beginner friendly that is why I just collected some basic things from uh uh everywhere and make a session. Next session we will make it more advanced level. So just practice the sessions like I mean I shared that uh sheet right? So just and practice that all things better and come to the next session. So we will cover more in detail like we have some more thing is there we map some other thing is there. So we will cover everything uh step by step. Okay. Hello. >> Yeah. Now I I want to take a uh what I want to take a screenshot as well. If you open the camera, it will be more good. Uh are you in a situation to open the camera or uh >> just one just one second only? No, not that much time. just you will take a screenshot and uh I will I will make a post in I mean I will make a post in LinkedIn. You people please try to share it and you can post that as well. Are you are you okay to open your camera? Who is the singer? No problem. Yeah, no problem. >> Yeah. So, are you ready for Yeah. Hashidita also one just one minute. Okay. Okay or not? Just tell me like our session will end at 8:30. Yes, in UAE we have only. >> Okay then. Okay. First thing I want to tell you one more thing like we we all are trying to get a job right. First we need to be confident to sit in front of a camera or whatever wherever you are. That is the thing. Okay. Just yeah from next session please try to these all are you please consider these all are the mock sessions. So you will get more confidence to attend the real session. Yeah. Okay. I will take a screenshot next then. Yeah. Uh so I I took now do you want to tell me anything or any doubt or anything? You can you can you can ask me. No problem. Yeah, that much only. >> Okay, we will come with you. Do you have any suggestions or you want any other specific topic? >> Yeah. And if you have any suggestions for the next sessions like you are interested to do like learn something new something else other than JS please let me know so that I can prepare that as well. Yeah, but uh the thing is you know I'm I'm taking some effort but you know number of people are attending is very less you know if at least 10 people is there I'm very happy >> yeah yeah I really appreciate but please try to join all the sessions and Shahida also thank you for joining the session I will share uh the about our today's session in the LinkedIn please uh repost uh it in your profile also. Okay. Yeah. Thank you so much. Yeah. Bye. Yeah. Bye.