Google has published a free guide on scaling AI models and working with GPUs. ๐
๐ How to Scale Your Model
https://jax-ml.github.io/scaling-book/
๐ How to Think About GPUs
https://jax-ml.github.io/scaling-book/gpus/
The materials discuss the principles of model scaling, the structure of GPUs, computational limitations, memory bandwidth, parallelism, and other topics that are useful when training and running modern AI models. ๐ก
It's completely free and available online. ๐
#AI #MachineLearning #GPU #Scaling #DeepLearning #Tech
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
๐ Level up your AI & Data Science skills with HelloEncyclo โ a growing all-in-one platform featuring hands-on courses in LLMs, Deep Learning, MLOps, Data Engineering, and more.
โ 13 courses live + 40+ coming soon
๐ฏ One access, lifetime updates
๐ Use code: PRESALE-BOOK-WAVE-2GFG
๐ https://helloencyclo.com/?ref=HUSSEINSHEIKHO
๐ How to Scale Your Model
https://jax-ml.github.io/scaling-book/
๐ How to Think About GPUs
https://jax-ml.github.io/scaling-book/gpus/
The materials discuss the principles of model scaling, the structure of GPUs, computational limitations, memory bandwidth, parallelism, and other topics that are useful when training and running modern AI models. ๐ก
It's completely free and available online. ๐
#AI #MachineLearning #GPU #Scaling #DeepLearning #Tech
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
๐ Level up your AI & Data Science skills with HelloEncyclo โ a growing all-in-one platform featuring hands-on courses in LLMs, Deep Learning, MLOps, Data Engineering, and more.
โ 13 courses live + 40+ coming soon
๐ฏ One access, lifetime updates
๐ Use code: PRESALE-BOOK-WAVE-2GFG
๐ https://helloencyclo.com/?ref=HUSSEINSHEIKHO
How To Scale Your Model
Training LLMs often feels like alchemy, but understanding and optimizing the performance of your models doesn't have to. This book aims to demystify the science of scaling language models: how TPUs (and GPUs) work and how they communicate with each otherโฆ
โค1
๐ How to Reduce the Cost of LLM Inference by up to 90%
If your AI agents are constantly sending the same context, consider using LMCache. ๐
This open-source system manages a KV cache, allowing you to reuse already computed representations instead of recalculating them for each request. ๐ง
As a result:
โก๏ธ Up to 14x faster Time To First Token;
โก๏ธ Up to 4x faster decoding;
โก๏ธ Significant savings in GPU resources and inference costs. ๐ฐ
โ๏ธ Link to GitHub
https://github.com/LMCache/LMCache
#LLM #AIOptimization #LMCache #GPU #CostReduction #AIEngineering
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
If your AI agents are constantly sending the same context, consider using LMCache. ๐
This open-source system manages a KV cache, allowing you to reuse already computed representations instead of recalculating them for each request. ๐ง
As a result:
โก๏ธ Up to 14x faster Time To First Token;
โก๏ธ Up to 4x faster decoding;
โก๏ธ Significant savings in GPU resources and inference costs. ๐ฐ
โ๏ธ Link to GitHub
https://github.com/LMCache/LMCache
#LLM #AIOptimization #LMCache #GPU #CostReduction #AIEngineering
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
โค3
I thought I understood how GPU loading works until I started writing this guide. ๐ค
I was constantly confusing three different concepts:
โข The amount of work we are launching.
โข The amount of work that is actually placed on the GPU.
โข The amount of work that is ready to be executed right now.
But these are completely different things. โ ๏ธ
Consider a CUDA kernel with 240 blocks, each containing 256 threads. This results in 61,440 logical threads, or 1920 warps. However, the number of launched threads doesn't tell you how many warps can actually be present on the GPU simultaneously. ๐งฎ
Blocks are placed on streaming multiprocessors (SMs) based on the available registers, shared memory, and limitations on the number of threads, warps, and blocks.
Even after being placed on an SM, a warp can be waiting for a memory operation to complete, a dependency between arithmetic operations to be resolved, or for synchronization. The scheduler can only select warps that are actually ready to issue instructions for execution. โณ
This changed my approach to analyzing performance metrics. ๐
Occupancy is a measure of the ratio of the number of active warps on an SM to the maximum number of warps that the SM can support.
GPU utilization measures something different. In NVML, this metric reflects the percentage of the measurement interval during which at least one CUDA kernel was running.
Therefore, the GPU can show 100% utilization even if the Tensor Cores are not being used to their full potential, the HBM bandwidth is not saturated, and performance is limited by one of the system components. At the same time, a significant portion of the GPU's resources may remain underutilized. ๐
Similar misconceptions arise with memory. Registers, shared memory, L1, L2, and HBM are not simply levels of memory that differ in speed. Each has its own areas of accessibility, capacity, management characteristics, and access methods. ๐พ
If a model fits in HBM, it only means that there is enough video memory for it. But it tells you very little about how many bytes need to be transferred, how efficiently memory accesses are combined, how often data is reused, and whether memory is actually limiting the performance of the CUDA kernel.
A good example is FlashAttention. This algorithm calculates the exact attention mechanism, but uses tiling and repeated computations to reduce the amount of data transferred between HBM and the GPU's internal memory. โก๏ธ
Tensor Cores turned out to be another technology that I previously understood too simplistically.
These are specialized computational units for matrix multiplication operations with accumulation, which play a huge role in AI tasks. However, they do not "execute the model" as a whole. ๐ง
Reduction operations, indexing, element-wise calculations, synchronization, and data movement still involve other components of the GPU. In addition, launching CUDA kernels also introduces overhead.
Over time, I stopped asking myself: "Why isn't the GPU 100% utilized?" Instead, I started asking a more accurate question: "What is currently limiting the speed of performing useful work?" ๐ค
Ultimately, all of this turned into a 42-page guide. ๐
It covers streaming multiprocessors (SMs), warps, and schedulers, the memory hierarchy and latency hiding, Tensor Cores, the distribution of GEMM computations across GPU hardware resources, numerical precision, and performance metrics that are very easy to misinterpret.
https://drive.google.com/file/d/17tyvxr__8vZ6o995GNq6I5PC5JOiv0ql/view
#GPU #CUDA #AI #DeepLearning #PerformanceOptimization #TechGuide
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
I was constantly confusing three different concepts:
โข The amount of work we are launching.
โข The amount of work that is actually placed on the GPU.
โข The amount of work that is ready to be executed right now.
But these are completely different things. โ ๏ธ
Consider a CUDA kernel with 240 blocks, each containing 256 threads. This results in 61,440 logical threads, or 1920 warps. However, the number of launched threads doesn't tell you how many warps can actually be present on the GPU simultaneously. ๐งฎ
Blocks are placed on streaming multiprocessors (SMs) based on the available registers, shared memory, and limitations on the number of threads, warps, and blocks.
Even after being placed on an SM, a warp can be waiting for a memory operation to complete, a dependency between arithmetic operations to be resolved, or for synchronization. The scheduler can only select warps that are actually ready to issue instructions for execution. โณ
This changed my approach to analyzing performance metrics. ๐
Occupancy is a measure of the ratio of the number of active warps on an SM to the maximum number of warps that the SM can support.
GPU utilization measures something different. In NVML, this metric reflects the percentage of the measurement interval during which at least one CUDA kernel was running.
Therefore, the GPU can show 100% utilization even if the Tensor Cores are not being used to their full potential, the HBM bandwidth is not saturated, and performance is limited by one of the system components. At the same time, a significant portion of the GPU's resources may remain underutilized. ๐
Similar misconceptions arise with memory. Registers, shared memory, L1, L2, and HBM are not simply levels of memory that differ in speed. Each has its own areas of accessibility, capacity, management characteristics, and access methods. ๐พ
If a model fits in HBM, it only means that there is enough video memory for it. But it tells you very little about how many bytes need to be transferred, how efficiently memory accesses are combined, how often data is reused, and whether memory is actually limiting the performance of the CUDA kernel.
A good example is FlashAttention. This algorithm calculates the exact attention mechanism, but uses tiling and repeated computations to reduce the amount of data transferred between HBM and the GPU's internal memory. โก๏ธ
Tensor Cores turned out to be another technology that I previously understood too simplistically.
These are specialized computational units for matrix multiplication operations with accumulation, which play a huge role in AI tasks. However, they do not "execute the model" as a whole. ๐ง
Reduction operations, indexing, element-wise calculations, synchronization, and data movement still involve other components of the GPU. In addition, launching CUDA kernels also introduces overhead.
Over time, I stopped asking myself: "Why isn't the GPU 100% utilized?" Instead, I started asking a more accurate question: "What is currently limiting the speed of performing useful work?" ๐ค
Ultimately, all of this turned into a 42-page guide. ๐
It covers streaming multiprocessors (SMs), warps, and schedulers, the memory hierarchy and latency hiding, Tensor Cores, the distribution of GEMM computations across GPU hardware resources, numerical precision, and performance metrics that are very easy to misinterpret.
https://drive.google.com/file/d/17tyvxr__8vZ6o995GNq6I5PC5JOiv0ql/view
#GPU #CUDA #AI #DeepLearning #PerformanceOptimization #TechGuide
โจ Join Best TG Channels https://t.iss.one/addlist/0f6vfFbEMdAwODBk
โญ๏ธ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
โค2๐2