Unit 12 of 12 · about 5 hours · implement, measure

Engine dispatch and fallback, kernel-to-endpoint translation and negative results

Attention baselines, shape matrices, end-to-end translation and losing regimes gave the translation formula for generic blocks. Here the runner chooses backends per phase and batch, so translation must survive dispatch, padding and fallback.

You'll be able to

  • Wire one kernel path into a serving runner with explicit backend selection and a tested eager fallback.
  • Translate a measured kernel win into endpoint TTFT, TPOT and goodput with Amdahl shares, or reject the win honestly.
  • Preserve the negative result: keep outputs identical, keep the losing regime in the report, and keep the fallback as the shipped behavior where it loses.

Covers

Engine dispatch and fallback integrationKernel-to-endpoint translationNegative end-to-end result preservationFlashInfer backend selection and custom masks
1

Read

In this order, only the parts listed

0 of 3 done

  1. Backend registry and graph fallback boundaryMini-SGLang - Kernel, Model Runner and Overlap Boundaries

    GraphRunner.pad_batch, can_use_cuda_graph, replay and the prepare_for_capture/prepare_for_replay backend hooks. For create_attention_backend and its hybrid backend string, also open https://github.com/sgl-project/mini-sglang/blob/9a91cfafe754aa85daee49998176275667eb58f2/python/minisgl/attention/__init__.py

  2. Backend selection and capture limitsFlashInfer Documentation

    FlashInfer documentation: the backend parameter (auto, fa2, fa3, trtllm-gen, cute-dsl, prims-ts) with automatic selection, use_cuda_graph rules, and the constraint that plan runs outside capture (page read 2026-10-14, release 0.7.1)

    For custom masks also open https://docs.flashinfer.ai/tutorials/kv_layout.html and read Mask Layout (2D Ragged Tensor). Keep backend="auto" on stable backends: experimental ones join automatic selection only with FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1 (Experimental APIs and Backends page), and naming one explicitly opts in too.

  3. Decode-kernel dispatch and the eager endpoint baselineAI Systems Performance Engineering companion code - Chapter 18

    BaselineVLLMV1Integration (enforce_eager=True baseline, SamplingParams, llm.generate, mean_latency_ms and throughput_tokens_per_sec); compare with build_decode_kernel in decode_kernels.py (prefer_vllm selects the vLLM path, prefer_vllm=False keeps the explicit torch path)

    The dispatch file reads paged_attention_v1 from vllm._custom_ops, which vLLM 0.31.0 does not provide; treat it as a dispatch sketch and verify the op name against your engine version. With prefer_vllm=True a missing op raises instead of falling back, unlike the tested fallback this unit asks for.

2

Focus on

  • Dispatch is per phase and batch, not per model. A hybrid prefill,decode string can win prefill and lose decode; log the backend per phase before translating.
  • Translate with shares, not kernels. For speedup on a serial critical-path share , the unchanged-rest model predicts : a 2x win on a 10% share gives about 1.05x. This is not a queueing or endpoint-tail model; overlap, dispatch, scheduler changes and load can invalidate its assumptions.
  • A fallback that never fires in testing is untested. Force an unsupported shape, dtype or backend and check outputs plus the miss count.
  • Custom masks ride the same dispatch. A mask the backend cannot express must fall back with identical outputs, not silently run unmasked.
Common mistakes · 3
  • Averaging per-kernel speedups into an endpoint claim. Weight by measured shares under the serving shape distribution.
  • Testing dispatch only on supported shapes. The fallback path ships too; an untested fallback is a latent outage.
  • Dropping the negative result from the report. A documented loss with its regime is section evidence; an unreported one will be rediscovered in production.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive the endpoint translation for a measured 2x kernel win on a 10% share: about 1.05x. Then build a two-backend dispatch matrix (serve path versus explicit torch path) over supported and unsupported shapes with per-phase backend logging; unsupported cases must take the fallback with identical outputs and a counted miss. Run the endpoint comparison under a fixed replayable load and report improvement or honest rejection with outputs preserved.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A kernel runs 3x faster on half the runtime. What is the endpoint win?Answer

    About 1.5x under a serial critical-path model with all other work unchanged: . Endpoint measurements still need to include dispatch, padding, overlap and queueing.

  2. 2.The fallback never triggers in your tests. Done?Answer

    No. Force unsupported inputs and verify identical outputs plus miss accounting; otherwise the fallback is untested code.

  3. 3.Backend A wins decode but loses prefill. Which ships?Answer

    The workload's phase mix decides. Log per-phase backends, translate each phase, and keep the hybrid or per-phase choice the numbers support.

  4. 4.The endpoint shows no win with outputs preserved. Report or retry?Answer

    Report. A preserved negative result with its regime and shifted bottleneck is the required evidence.

You're done when

One kernel path ships behind dispatch with a tested fallback, the endpoint comparison under replayable load shows a win or a preserved rejection, and every number traces to a logged share.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 11 more in the section
  • AI Systems Performance Engineering companion code - Chapter 18Chris Fregly · required

    Start with paged_attn_common.py, the dense versus paged layout pair, CUDA graph bucketing and the vLLM integration pair. Run correctness tests first, then a hardware-compatible benchmark with newly captured artifacts.

  • FlashInfer DocumentationFlashInfer Project · required

    Use the current attention, PageAttention, sampling, JIT and CUDA Graph interfaces while implementing. Pin the version and supported GPU architecture, and validate dispatch and fallback over the real workload shape distribution.

  • Mini-SGLang - Kernel, Model Runner and Overlap BoundariesSGLang Project · support

    Trace how FlashAttention or FlashInfer, KV layouts, tensor parallel communication and overlap scheduling meet the model runner. Identify the fallback and state-reset boundary before attempting a change.

Also in this section