Contents
Preface (p. 9)
First experiments (p. 11)
Why we chose WSL2 (p. 14)
1. The laptop as an observable system (p. 16)
2. Establishing the WSL2 baseline (p. 19)
3. Accounting for 64 GB of unified memory (p. 23)
4. Preparing a reproducible laboratory (p. 27)
5. Installing the pinned Linux runtime and model (p. 30)
6. Loading a model and proving the execution path (p. 34)
7. Asking a diagnostic question (p. 39)
8. Measuring latency and throughput (p. 43)
9. Context as a controlled resource (p. 50)
10. Quantization and model selection (p. 56)
11. Placement and memory pressure (p. 62)
12. Diagnosing failures by their first failed boundary (p. 68)
13. Testing a CUDA kernel with Python (p. 74)
14. Grounding answers in local evidence (p. 82)
15. A bounded diagnostic agent (p. 87)
16. Letting the local model choose actions (p. 91)
17. Concurrency and the memory cost of agents (p. 98)
18. Offline operation and a repeatable working practice (p. 102)
19. Diagnostic patterns for local models (p. 106)
20. Extending the laboratory (p. 108)
21. Fine-tuning within the observed memory budget (p. 109)
22. Preparing data and training a LoRA adapter (p. 111)
23. Evaluating, retaining, and deploying the adapter (p. 116)
24. Models that do not fit entirely on the GPU (p. 121)
25. Running beyond the GPU budget and diagnosing paging (p. 125)
26. Studying the CUDA ecosystem through evidence (p. 139)
27. Building and examining a small CUDA program (p. 144)
28. Capturing and interpreting GPU memory contents (p. 149)
29. Live device inspection and exception core dumps (p. 152)
30. Finding CUDA memory and synchronization errors (p. 157)
31. Collecting and reading CUDA execution traces (p. 162)
32. Studying individual kernels with Nsight Compute (p. 167)
33. Framework memory evidence and a model tracing capstone (p. 170)
34. Writing and validating a first CUDA kernel (p. 175)
35. Writing kernels for matrix layout and shared memory (p. 180)
36. Reductions and atomic updates (p. 184)
37. Writing a tiled matrix multiplication (p. 189)
38. Measuring kernel changes and writing a fused operation (p. 194)
39. Writing normalization kernels for model workloads (p. 199)
40. Integrating a CUDA kernel with PyTorch (p. 204)
41. Building and diagnosing a small transformer block (p. 210)
42. Warp programming and Tensor Core operations (p. 215)
43. Streams events and CUDA Graphs (p. 220)
44. Writing a teaching INT4 representation (p. 226)
45. Diagnosing training gradients memory and recovery (p. 230)
46. A CUDA diagnostic casebook (p. 234)
47. Agent assisted GPU diagnosis (p. 239)
48. Inspecting PTX, SASS, and device registers (p. 244)
49. Sentence embeddings and masked pooling (p. 248)
50. Retrieval data and evaluation (p. 255)
51. Inspecting embeddings with PCA (p. 259)
52. Comparing t-SNE and UMAP (p. 263)
53. Training a custom BERT model (p. 268)
54. Continuing pretraining and building sentence encoders (p. 273)
55. Fine tuning embedding models (p. 278)
56. Diagnosing and deploying embedding workloads (p. 283)
57. Monitoring GPU metrics and visualizing activity (p. 288)
58. Locating numerical divergence (p. 311)
59. Diagnosing compiled model execution (p. 316)
60. Diagnosing GPU starvation and input pipelines (p. 323)
61. Reasoning with roofline models (p. 328)
62. Diagnosing memory growth across requests (p. 332)
63. Diagnosing stalled progress (p. 337)
64. Tracing complete AI requests (p. 341)
65. Diagnosing model quality regressions (p. 345)
66. Reducing failures and isolating regressions (p. 349)
67. Debugging the observations themselves (p. 352)
68. A diagnostic pattern catalog (p. 356)
69. Blind diagnostic investigations (p. 362)
70. Distributed training on one laptop (p. 367)
71. Sharing one GPU among workers (p. 383)
72. Inference services and request diagnostics (p. 397)
73. Docker deployment inside WSL2 (p. 405)
74. Kubernetes deployment and GPU scheduling (p. 416)
75. vLLM and NVIDIA Triton Inference Server (p. 424)
76. RAPIDS data pipelines and GPU memory (p. 441)
77. ONNX export providers and fallback diagnostics (p. 451)
78. TensorRT engines profiles and execution traces (p. 458)
79. Quantization calibration and quality diagnosis (p. 469)
80. NeMo fine tuning recovery and deployment handoff (p. 479)
81. Images audio and multimodal evidence (p. 504)
82. Vision language inference and visual grounding (p. 513)
83. Diffusion models through a small executable experiment (p. 525)
84. Image generation memory and denoising traces (p. 533)
85. Music generation and audio token diagnostics (p. 550)
86. Text to speech as a reproducible signal pipeline (p. 559)
87. Speech recognition and transcript reliability (p. 571)
88. Adapting and serving multimodal pipelines (p. 582)
89. The NGC catalog as a source of reproducible GPU assets (p. 601)
90. The Hugging Face Hub as a source of models and datasets (p. 616)
91. Prometheus and Grafana for GPU observability (p. 627)
92. LangChain agents and local model adapters (p. 657)
93. LangGraph state, interrupts and recovery (p. 666)
94. LangSmith traces and evaluation (p. 673)
95. PydanticAI typed outputs and retry diagnosis (p. 679)
96. Jev decision models and calibrated routing (p. 684)
97. Ollama as a local model owner (p. 692)
98. Unsloth adaptation with measurable training boundaries (p. 705)
99. LM Studio inside WSL2 with a headless service (p. 722)
100. Nemotron models beyond the GPU weight budget (p. 733)
Advanced memory investigation (p. 750)
Appendix A. Exercise map and expected evidence (p. 771)
Appendix B. Companion programs and their contracts (p. 790)
Appendix C. Glossary (p. 802)
Appendix D. References (p. 810)
Appendix E. Validation and reproduction boundaries (p. 822)
Appendix F. Measurements from the example laptop (p. 824)
Appendix G. Learning paths and completion criteria (p. 850)
Appendix H. Subject index (p. 855)
Appendix I. Troubleshooting by symptom (p. 858)