CUDA graphs and overlapped scheduling are on, but batch-1 decode is still well below the bandwidth roofline. What would a persistent megakernel change, and why might an inference vendor argue that megakernels are the wrong target for production traffic?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
CUDA graphs remove launch overhead, but the kernel boundaries remain, and at batch 1 they are where the time goes:
- Each kernel writes its output to HBM and the next reads it back.
- Each kernel ends with a tail where most SMs sit idle while the last thread blocks finish.
- The next layer's weight loads cannot start until the previous kernel has drained.
Full worked answer
CUDA graphs remove launch overhead, but the kernel boundaries remain, and at batch 1 they are where the time goes:
- Each kernel writes its output to HBM and the next reads it back.
- Each kernel ends with a tail where most SMs sit idle while the last thread blocks finish.
- The next layer's weight loads cannot start until the previous kernel has drained.
On a small step, these ramps and drains can be a large fraction of the roofline gap.
A persistent megakernel launches once per step, or once per many steps, and keeps every SM busy, pulling work from a task graph covering the whole forward pass. Dependencies are tracked with fine-grained counters in memory, not kernel boundaries. So the next layer's weight prefetch overlaps the current layer's compute, intermediates stay on chip where they fit, and tail gaps disappear. SGLang added opt-in NVIDIA megakernel and AMD monokernel plugins in late 2026 that run DeepSeek-V4.1-Flash decode this way, reporting up to 44% faster single-user decode on GB300 and 75% on MI350X. vLLM added a ROCm monokernel path too.
The case against. Together AI argued in November 2026 that fusing everything into one kernel is the wrong design goal, and reported 1.7× over open-source megakernels at batch 1 with its own compiler. Whatever you make of a vendor's benchmark, the engineering argument is sound:
- Production is not batch 1. Batch size changes every step, chunked prefill mixes in, speculative verification adds odd shapes. At batch 32 and above, launch and tail overhead is already amortised and you are bound by bandwidth or compute. A batch-1 megakernel optimises a regime most fleet hours are not in.
- Data-dependent work. MoE routing and sparse attention decide work at runtime. A static megakernel schedule either over-provisions or stalls.
- Brittleness. One kernel per model, hardware and configuration is expensive to write, slow to update for new architectures, and fights dynamic features: paged KV, LoRA swaps, structured-output masks, new quantization formats.
- The alternative is to generate specialised kernels per shape and regime continuously, and pick the right one at runtime, rather than one fused program.
What I would do. Measure how many decode-hours actually run at batch 1 to 4. That is premium speed tiers, single-user on-prem or edge, and latency-critical interactive routes. If it is a big slice for a stable model, a megakernel path for that route is worth it, behind a flag, with fallback to the standard path for anything it does not support. If traffic is mostly large-batch, spend the effort on scheduling, speculative decoding and kernel selection instead. Confirm the gap first with a profile showing kernel tails and HBM round trips, not just low utilisation.
What a good answer covers
- Each kernel writes its output to HBM and the next reads it back
- Each kernel ends with a tail where most SMs sit idle while the last thread blocks finish
- The next layer's weight loads cannot start until the previous kernel has drained
- On a small step, these ramps and drains can be a large fraction of the roofline gap
- A persistent megakernel launches once per step, or once per many steps, and keeps every SM busy, pulling…
Key terms: A persistent megakernel · The case against · Production is not batch 1 · Data-dependent work · Brittleness · The alternative · What I would do
In the glossary: HBM · SGLang · vLLM · Chunked prefill · MoE · Speculative decoding
Interviewer follow-ups to expect
How would you show from a profile that kernel tails, not launch overhead, are the remaining gap?
Why does MoE make static megakernel scheduling hard?
What would you need from a megakernel before running it behind a production speed tier?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep