A FREE, QUESTION-LED WEB BOOK
Learn the concepts.
Question the details.
GPU programming & AI systems — explained through concepts, questions, and worked examples.
From threads and memory to Triton, inference, and kernel learning. Read the knowledge first, test your understanding, then open the answer.
THE READING PATH
Build a mental model.
Then put it to work.
GPU foundations and the memory hierarchy
4 questions · Knowledge, answers & sources
Threads, warps, occupancy, and performance models
5 questions · Knowledge, answers & sources
Memory access and synchronization
5 questions · Knowledge, answers & sources
Triton, reductions, normalization, and GEMM
8 questions · Knowledge, answers & sources
Compilation, JIT, integration, and CUDA Graphs
3 questions · Knowledge, answers & sources
Measurement, streams, correctness, and profiling
40 questions · Knowledge, answers & sources
Trust boundaries, isolation, and worker state
3 questions · Knowledge, answers & sources
Queues, scheduling, and service objectives
3 questions · Knowledge, answers & sources
Attention, KV caches, and inference
6 questions · Knowledge, answers & sources
Distributed execution and training memory
4 questions · Knowledge, answers & sources
Reinforcement learning: concepts before formulas
3 questions · Knowledge, answers & sources
PPO, GRPO, baselines, and policy lag
5 questions · Knowledge, answers & sources
Kernel rewards and multi-turn learning pipelines
5 questions · Knowledge, answers & sources
Reading papers and choosing public tools
3 questions · Knowledge, answers & sources
Worked estimates, code review, and system design
5 questions · Knowledge, answers & sources
THE QUESTION BANK
What are you trying
to understand?
102 questions
- 01.1Why not keep all model weights in registers?FoundationGPU foundations and the memory hierarchy
- 01.2Are shared memory and L1 cache the same thing?FoundationGPU foundations and the memory hierarchy
- 01.3Does a cache hit prove that memory access is coalesced?FoundationGPU foundations and the memory hierarchy
- 01.4How do you address a transposed tensor?FoundationGPU foundations and the memory hierarchy
- 02.1How many 256-thread blocks cover 1,000 elements?FoundationThreads, warps, occupancy, and performance models
- 02.2Work out occupancy for a hypothetical SM.IntermediateThreads, warps, occupancy, and performance models
- 02.3Why can a larger tile be slower?IntermediateThreads, warps, occupancy, and performance models
- 02.4Do low memory and compute throughput prove a kernel is latency-bound?IntermediateThreads, warps, occupancy, and performance models
- 02.5What is the tail effect with 133 blocks and 132 SMs?IntermediateThreads, warps, occupancy, and performance models
- 03.1Can each thread read consecutive elements yet produce poor coalescing?IntermediateMemory access and synchronization
- 03.2Why is a transpose tile often declared as float tile[32][33]?IntermediateMemory access and synchronization
- 03.3Can __syncthreads() be inside if (threadIdx.x < 16)?FoundationMemory access and synchronization
- 03.4Does atomicAdd synchronize every block?IntermediateMemory access and synchronization
- 03.5How should I approach cp.async, TMA, warp specialization, and newer Tensor Core instructions?AdvancedMemory access and synchronization
- 04.1Does BLOCK_SIZE=256 mean 256 CUDA threads?FoundationTriton, reductions, normalization, and GEMM
- 04.2For n=10 and BLOCK=4, which offsets are valid?FoundationTriton, reductions, normalization, and GEMM
- 04.3Why use negative infinity for masked softmax inputs?IntermediateTriton, reductions, normalization, and GEMM
- 04.4Is a tree reduction always bitwise deterministic?IntermediateTriton, reductions, normalization, and GEMM
- 04.5What does a minimal GEMM plan need?IntermediateTriton, reductions, normalization, and GEMM
- 04.6What can go wrong during autotuning?IntermediateTriton, reductions, normalization, and GEMM
- 04.7Should matmul, bias, and activation always be fused?IntermediateTriton, reductions, normalization, and GEMM
- 04.8How does RMSNorm differ from LayerNorm?IntermediateTriton, reductions, normalization, and GEMM
- 05.1Are torch.compile and CUDA Graphs the same optimization?FoundationCompilation, JIT, integration, and CUDA Graphs
- 05.2Why do graph examples reuse static input buffers?IntermediateCompilation, JIT, integration, and CUDA Graphs
- 05.3Does opcheck prove that my custom operator computes the right answer?IntermediateCompilation, JIT, integration, and CUDA Graphs
- 06.1Can throughput improve while latency gets worse?FoundationMeasurement, streams, correctness, and profiling
- 06.2Which baseline should I use?FoundationMeasurement, streams, correctness, and profiling
- 06.3Does changing precision count as a kernel optimization?FoundationMeasurement, streams, correctness, and profiling
- 06.4How are CUDA Event and perf_counter different?FoundationMeasurement, streams, correctness, and profiling
- 06.5Does a CUDA Event give pure kernel execution time?IntermediateMeasurement, streams, correctness, and profiling
- 06.6Why can .item(), printing, or copying to CPU change the timing?FoundationMeasurement, streams, correctness, and profiling
- 06.7What if a candidate launches work on a side stream?IntermediateMeasurement, streams, correctness, and profiling
- 06.8Are wait_stream(), record_stream(), and synchronize() interchangeable?IntermediateMeasurement, streams, correctness, and profiling
- 06.9Does non_blocking=True guarantee a transfer overlaps computation?IntermediateMeasurement, streams, correctness, and profiling
- 06.10Should I benchmark with CUDA_LAUNCH_BLOCKING=1?IntermediateMeasurement, streams, correctness, and profiling
- 06.11Is a cold worker the same as a cold cache?IntermediateMeasurement, streams, correctness, and profiling
- 06.12How do torch.compile and CUDA Graphs differ?IntermediateMeasurement, streams, correctness, and profiling
- 06.13What should I check if graph replay is still slow?IntermediateMeasurement, streams, correctness, and profiling
- 06.14What do benchmark helpers handle, and what do I still own?IntermediateMeasurement, streams, correctness, and profiling
- 06.15Should every benchmark flush L2?IntermediateMeasurement, streams, correctness, and profiling
- 06.16Can preparation outside the timer affect the interval inside it?IntermediateMeasurement, streams, correctness, and profiling
- 06.17Are cache hits and coalesced accesses the same thing?IntermediateMeasurement, streams, correctness, and profiling
- 06.18Do fixed clocks remove all noise?IntermediateMeasurement, streams, correctness, and profiling
- 06.19Why interleave A/B measurements?IntermediateMeasurement, streams, correctness, and profiling
- 06.20Why independently retest the winner?AdvancedMeasurement, streams, correctness, and profiling
- 06.21Why use the geometric mean of speedups?FoundationMeasurement, streams, correctness, and profiling
- 06.22How does speedup differ from fast_p?IntermediateMeasurement, streams, correctness, and profiling
- 06.23Does trying more candidates mean the model learned?AdvancedMeasurement, streams, correctness, and profiling
- 06.24Why isn't one random input enough?IntermediateMeasurement, streams, correctness, and profiling
- 06.25Does allclose mean bitwise equality?FoundationMeasurement, streams, correctness, and profiling
- 06.26Is a race just ordinary nondeterminism?IntermediateMeasurement, streams, correctness, and profiling
- 06.27Why validate the benchmark execution path?IntermediateMeasurement, streams, correctness, and profiling
- 06.28How is reward hacking different from overfitting?AdvancedMeasurement, streams, correctness, and profiling
- 06.29How do I tell memory-bound from compute-bound?IntermediateMeasurement, streams, correctness, and profiling
- 06.30Why can a bigger tile or higher occupancy make a kernel slower?IntermediateMeasurement, streams, correctness, and profiling
- 06.31What do stall reasons tell me?IntermediateMeasurement, streams, correctness, and profiling
- 06.32Does fusion always help?IntermediateMeasurement, streams, correctness, and profiling
- 06.33Does subprocess isolation make timings independent?AdvancedMeasurement, streams, correctness, and profiling
- 06.34What should happen after a timeout, OOM, or device failure?AdvancedMeasurement, streams, correctness, and profiling
- 06.35Why can memory_reserved stay high after tensors are freed?IntermediateMeasurement, streams, correctness, and profiling
- 06.36If a job took five seconds, was the kernel running for five seconds?IntermediateMeasurement, streams, correctness, and profiling
- 06.37Why doesn't a 2× faster kernel make the whole model 2× faster?FoundationMeasurement, streams, correctness, and profiling
- 06.38What if production latency suddenly becomes noisy?IntermediateMeasurement, streams, correctness, and profiling
- 06.39How would I investigate a kernel that is slower than expected?IntermediateMeasurement, streams, correctness, and profiling
- 06.40How would I design a trustworthy evaluation service?AdvancedMeasurement, streams, correctness, and profiling
- 07.1Why validate outputs produced by the timed path?IntermediateTrust boundaries, isolation, and worker state
- 07.2Should a device outage receive the same score as wrong arithmetic?AdvancedTrust boundaries, isolation, and worker state
- 07.3Why might clearing a cache not release GPU memory?IntermediateTrust boundaries, isolation, and worker state
- 08.1At 2 requests/s and 10 s mean time in system, how many requests are present?FoundationQueues, scheduling, and service objectives
- 08.2What happens if generation is faster than kernel evaluation?IntermediateQueues, scheduling, and service objectives
- 08.3What should I measure before adding twice as many GPUs?AdvancedQueues, scheduling, and service objectives
- 09.1FlashAttention or PagedAttention—which one replaces the other?FoundationAttention, KV caches, and inference
- 09.2Estimate KV storage for 32 layers, 8 KV heads, head_dim=128, and BF16.IntermediateAttention, KV caches, and inference
- 09.3Derive the online softmax update.AdvancedAttention, KV caches, and inference
- 09.4What does 16 GB of weights divided by 3.35 TB/s tell us?IntermediateAttention, KV caches, and inference
- 09.5Why separate prefill and decode, or use speculative decoding?IntermediateAttention, KV caches, and inference
- 09.6Are GQA, MQA, and prefix caching the same idea?FoundationAttention, KV caches, and inference
- 10.1Why is 7B BF16 inference not simply a 14 GB GPU requirement?FoundationDistributed execution and training memory
- 10.2Where does an illustrative 16 bytes per parameter come from?IntermediateDistributed execution and training memory
- 10.3What is the ring all-reduce traffic per rank?IntermediateDistributed execution and training memory
- 10.4What should a DP / FSDP / TP / PP / EP comparison include?IntermediateDistributed execution and training memory
- 11.1Is a multi-turn coding agent automatically doing RL?FoundationReinforcement learning: concepts before formulas
- 11.2Can a high reward have a low advantage?IntermediateReinforcement learning: concepts before formulas
- 11.3How can timing feedback train a code policy?IntermediateReinforcement learning: concepts before formulas
- 12.1Compute group advantages for rewards [1,0,0,1].IntermediatePPO, GRPO, baselines, and policy lag
- 12.2How does r_i - mean(other rewards) relate to r_i - group_mean?AdvancedPPO, GRPO, baselines, and policy lag
- 12.3Do PPO clipping and a reference KL penalty do the same thing?IntermediatePPO, GRPO, baselines, and policy lag
- 12.4What should I check when reading DAPO or Dr. GRPO?AdvancedPPO, GRPO, baselines, and policy lag
- 12.5What if every response in a GRPO group has the same reward?AdvancedPPO, GRPO, baselines, and policy lag
- 13.1What rewards does the illustrative formula give for S=1 and S=2?IntermediateKernel rewards and multi-turn learning pipelines
- 13.2How many evaluations are in 8 trajectories × 4 turns × 3 shapes?IntermediateKernel rewards and multi-turn learning pipelines
- 13.3Should compiler-error tool messages be trained as policy actions?AdvancedKernel rewards and multi-turn learning pipelines
- 13.4Is changing only seeds an adequate held-out split?AdvancedKernel rewards and multi-turn learning pipelines
- 13.5Why can faster evaluation fail to accelerate learning?AdvancedKernel rewards and multi-turn learning pipelines
- 14.1What does fast_p tell me that an average speedup does not?IntermediateReading papers and choosing public tools
- 14.2How should I study a kernel evaluation service such as KernelGYM?AdvancedReading papers and choosing public tools
- 14.3What should a paper comparison table record?IntermediateReading papers and choosing public tools
- 15.1Estimate FLOPs and ideal traffic for a 4096³ BF16 GEMM.IntermediateWorked estimates, code review, and system design
- 15.2What assumptions does a full-mask warp reduction need?AdvancedWorked estimates, code review, and system design
- 15.3A kernel is slower than expected. What is your investigation order?AdvancedWorked estimates, code review, and system design
- 15.4Design a kernel evaluation service.AdvancedWorked estimates, code review, and system design
- 15.5Online token latency suddenly spikes. What do you inspect?AdvancedWorked estimates, code review, and system design
No matching questions. Try a broader term or another difficulty.