👨🏻 Brother Talk — Phase 08, Off the Record
Inference optimization — FlashAttention, speculative decoding, continuous batching. The techniques that turn "the model works" into "the model ships." Where the roofline pays off.
Brother, this is the phase where everything from P07 (the roofline) turns into concrete wins, and where you learn the optimizations that every serious inference system uses. Here's the unifying truth that ties them together: LLM inference is memory-bound, and almost every great inference optimization is really a memory-movement optimization in disguise. Hold that lens and FlashAttention, KV-caching, quantization, and batching all reveal themselves as variations on one theme — move fewer bytes, reuse what's on-chip.
FlashAttention is the crown jewel, and the lab makes you build it, so let me give you the "aha" before you do: standard attention materializes the full N×N attention matrix in memory — which for long sequences is enormous and, crucially, memory-bound (you write the whole matrix to DRAM, then read it back for the softmax, then again for the matmul with V). FlashAttention's insight is to never materialize that matrix — tile the computation, keep tiles on-chip (SRAM), and use the online softmax trick to combine tiles without ever holding the full row. Same math, exact same output, but the memory traffic drops from O(N²) to O(N). It's not a faster matmul; it's less data movement. That's why it wins, and that's the roofline lesson made flesh. Build the online-softmax recurrence by hand — the running max and running sum that let you process the sequence in tiles — and you'll understand the single most important inference kernel of the decade.
Speculative decoding is the cleverest idea in here, and it's beautiful: autoregressive generation is sequential (token N+1 needs token N), which means you're memory-bound loading the whole model's weights for one token at a time — terrible hardware utilization. Speculative decoding uses a small, fast "draft" model to guess several tokens ahead, then the big model verifies them all in one parallel forward pass. If the draft was right (often), you got multiple tokens for the price of one big-model pass. The profound part: it's exact — the verification guarantees you get identical output to running the big model alone, just faster. No accuracy tradeoff, pure latency win. Understand the accept/reject sampling that makes it exact, because "free speedup with zero accuracy cost" sounds like a lie until you see the math.
Continuous batching is the systems-level one and it's where throughput lives. Naive ("static") batching waits for the whole batch to finish before starting the next — but sequences finish at different lengths, so you have GPUs/NPUs idling while they wait for the slowest one. Continuous batching evicts finished sequences and slots in new ones every step, keeping the hardware saturated. It's the difference between 30% and 90% utilization on a serving system. For edge it matters less (often batch=1), but for any server-side or multi-stream scenario it's the throughput unlock, and it pairs with paged-KV-cache memory management (the vLLM idea).
The thing nobody tells you: these optimizations compose, and the order and interaction matter. FlashAttention + quantization + speculative decoding together is not just additive — quantizing the draft model makes speculation cheaper, FlashAttention changes the memory profile that batching schedules around, etc. The Senior Staff engineer holds the whole inference stack in their head and reasons about how the pieces interact, not just each in isolation. And the eternal discipline (same as P04): every one of these must be numerically verified. FlashAttention must match standard attention to tolerance; speculative decoding must be exactly equal to the base model; a quantized-and-fused pipeline must hold accuracy. Fast-but- wrong is a shipped bug.
For Qualcomm specifically: the edge twist is that batch is usually 1 and the constraint is latency + power, not throughput. So FlashAttention's memory savings matter (less DRAM traffic = less power), speculative decoding's latency win matters (but the draft model costs memory you may not have on a phone), and continuous batching matters less. Knowing which of these wins on edge vs server is the judgment the role wants — "adapt the latest GenAI techniques for NPUs" means knowing that the data-center playbook doesn't copy-paste to mobile.
Career truth, brother: these are the headline skills — the ones that make a résumé pop and an interview light up, because they're the techniques behind every product everyone's heard of. But the depth is what counts: anyone can say "we use FlashAttention"; the Senior Staff engineer can derive the online softmax on a whiteboard, explain why speculative decoding is exact, and reason about how they compose on a power-constrained device. Build them from scratch here so that depth is real, not borrowed.
Build FlashAttention. Build the speculative-decoding accept/reject. Verify everything to tolerance. Then come to P09, where we make sure all this speed didn't quietly cost us accuracy — evaluation, the other half of the job title.
— your brother 👨🏻