Mohsen Kheirandishfard·Sep 7Knowledge Distillation into Tiny Students — Part II: Cutting a Model Without Killing ItPart I asked which knob to turn; this part asks what fills the gap afterward. The lazy answer is random numbers — every axis below has a…
Mohsen Kheirandishfard·Aug 25Knowledge Distillation into Tiny Students — Part I: Two Knobs, Three Ways to ShrinkA general-purpose model is built to do everything. If you only need it to do one thing, how much of it can you actually throw away? Two…
Mohsen Kheirandishfard·Jul 28The Log-Sum-Exp Trick: How PyTorch Keeps Softmax From Blowing UpOne line of algebra that every deep learning framework quietly runs behind your back — and what happens to your loss when it doesn’t.
Mohsen Kheirandishfard·Jul 12Mixture of Experts: A Giant Model’s Knowledge at a Small Model’s CostHow modern LLMs like Qwen pack the knowledge of a giant model into the running cost of a small one — with intuition, diagrams, and runnable…
Mohsen Kheirandishfard·Jul 6LoRA: Fine-Tune a Big Model on a Small Machine — Without Losing AccuracyYou have a large pretrained model and a modest GPU. Full fine-tuning won’t fit. LoRA lets you adapt the model by training less than 1% of…
Mohsen Kheirandishfard·Jun 30Out of CUDA Memory? Gradient Checkpointing Lets You Train Models That Don’t FitA simple memory trick that trades a little compute for a lot of GPU headroom — with intuition, diagrams, and runnable PyTorch code.
Mohsen Kheirandishfard·Jun 21Why Quantized Models Break, and How Quantize-Aware Training Fixes ThemQuantization can make models smaller and faster, but it can also quietly damage accuracy. Quantize-aware training helps neural networks…
Mohsen Kheirandishfard·Jun 8KV Caching in LLMs, Explained With a Tiny Character ModelLarge Language Models generate text one token at a time. They read a prompt, predict the next token, append that token to the prompt, and…
Mohsen Kheirandishfard·Jun 1Full Attention vs. FlashAttention: A Visual Guide to the Memory ProblemWhy standard attention creates huge intermediate matrices, and how FlashAttention gets the same result without storing them all at once
Mohsen Kheirandishfard·May 16A Simple Yet Effective Initialization Trick for Imbalanced ClassificationA beginner-friendly guide to class imbalance, sigmoid logits, binary cross-entropy, and final-layer bias initialization in PyTorch