Kernel-to-Inference Integration

A fast isolated kernel matters only when the engine actually dispatches it and the request-level bottleneck moves. This stage integrates one custom path, traces scheduling and memory interactions, and measures TTFT, TPOT, goodput, memory and output quality together.

Section 8 of 10 · 11 units · about 41 hours

0/11

By the end you can Integrate one custom CUDA or Triton path into a real operator or small inference endpoint, prove dispatch and rollback, and show request-level TTFT, TPOT, memory, goodput and quality effects across the real shape distribution.

Units

Build it

Mini project · about 12 to 16 hours

One custom path running in a real inference endpoint

Integrate one validated CUDA or Triton path into a real operator or small endpoint: trace dispatch to the kernel, measure paged KV and chunked prefill, cover quantized and speculative paths, and gate releases with fallback and rollback.

  1. 1Trace one aten::mm entry to its kernel on an nsys timeline, reconciling profiler time with kernel intervals and wall time. Run the regional-compile pair and attribute which boundary each variant moves.
  2. 2Time eager launches of a tiny kernel against graph replay with interleaved trials, recording host load; at that size replay should win, so explain any loss. Recapture after shape changes, keep capture logs, and test eager fallback on an unsupported path.
  3. 3Work a mixed batch of short and long decodes under static and continuous batching, stating which kernel dimensions shrink as slots free. Derive per-token KV bytes for your config, place one sequence into blocks, and keep block tables with hit rates.
  4. 4Chunk one long prompt beside decodes under a token budget you set, showing per-iteration latency falls while attention work holds. Pass LeetGPU challenges 87 and 96 in your own harness, and compare disaggregated prefill and decode with TTFT, TPOT and transfer notes.
  5. 5Time encoder-batch against decoder-only execution for one image-plus-text request, with a prefix-hash check reusing only matching prefixes. Integrate one validated kernel as a custom op, compare it against production baselines under a load test, with workspace planning, and derive capacity for your GPU.
  6. 6Show that greedy decoding on logits equals greedy on their softmax, exact up to rounding ties, and gate quality with perplexity on a fixed token file. Write a versioned gate with fallback and rollback, seed one defect it catches, and drill rollback.
What you hand in
  • Dispatch and launch evidence: the operator-to-kernel trace, eager against replay trials, and batching and KV derivations.
  • The integrated custom op with workspace plan, capacity math, baselines and the multimodal timing check.
  • The quality gate on a fixed token file and the versioned regression gate with rollback drill.
How to check it
  • Self-grade with the rubric below
  • LeetGPU inference kernels

    Pass 83 Fused Residual Add RMS Norm, 87 Speculative Decoding Verification and 96 INT8 KV Cache Attention in your harness; integrate one result with fallback.

How it's graded

Dispatch proof

Pass: The trace follows one operator entry to its kernel with reconciled times, and eager against replay medians come from interleaved trials with recapture rules.

Great: Each profiler interval maps to a named kernel, and the timeline explains the gap between profiler and wall time.

Integration with quality

Pass: The custom op runs in the endpoint with stable buffers named, capacity math states its conventions, production baselines are compared under load, and quality gates pass on a fixed token file.

Great: The report bounds the end-to-end win from the measured step share.

Gates and rollback

Pass: Your own tests fail the gate on the seeded defect before timing, fallback routes correctly, and rollback is drilled with raw samples kept.

Great: The gate rebuilds from a clean checkout, and rollback restores the previous release's measured result.

Resources

  • AI Systems Performance Engineering - Chapters 13, 15 and 16Chris Fregly

    Read Chapter 13 on profiling and tuning PyTorch, Chapter 15 on inference parallelism, decoding and routing, and Chapter 16 on profiling and debugging inference. Keep Chapters 17 to 19 for GPU-9 and depth.

  • AI Systems Performance Engineering companion code - Chapters 12 to 16Chris Fregly

    Use compatible examples from code/ch12 through code/ch16. Trace whether each optimized path changes a kernel, graph, compiler choice, scheduler or library dispatch, then integrate one bounded custom path into a realistic operator or small endpoint.

  • PagedAttention and vLLMvLLM Authors

    Study block-based key-value allocation, sharing and scheduling interaction. Trace logical token positions to physical blocks in one engine run and quantify fragmentation and memory-capacity effects.

  • LeetGPU - Inference Kernel SetAlphaGPU

    Choose three bottleneck-matched challenges from 74 GPT-2 Block, 83 Fused Residual Add RMS Norm, 84 SwiGLU MLP Block, 87 Speculative Decoding Verification, 93 Llama Transformer Block and 96 INT8 KV Cache Attention. Integrate one result locally rather than stopping at the hosted submission.

  • SGLangSGLang Authors

    Read the runtime and RadixAttention design, then inspect the repository path for one kernel or prefix-reuse interaction. Use it as an alternative architecture in the integration defense.

  • FlashInferFlashInfer Project

    Use the repository as the serving-kernel baseline and interface reference. Reconstruct workspace planning, layouts, dispatch and stream behavior for one selected operation before comparing your path.

  • GPU Microbenchmark and Kernel Suite - IntegrationRoadmap-Final

    Complete the real tensor or model-operation integration, dispatch and fallback requirements. Report compilation and invocation overhead, workload frequency, correctness or quality and the end-to-end no-benefit regime.

  • Orca (OSDI 2022)USENIX

    Read Sections 3 to 4 for iteration-level scheduling and selective batching, and Section 6 for the engine microbenchmark and end-to-end latency-throughput method. Use it as the continuous-batching mechanism behind the book summary.

  • Sarathi-ServearXiv

    Read Sections 3 to 4 for chunked-prefill stall-free batching and token-budget selection, and Section 5 for capacity and overhead method. Use it as the chunked-prefill mechanism behind the book summary.

  • Fast Inference from Transformers via Speculative DecodingPMLR

    Read Sections 2 to 3 for the draft-verify-accept loop, the acceptance rule and the walltime-versus-operations analysis. Use it for the verification cost model behind the engine guides.

  • AI Performance Engineering - Inference EnginesWafer

    A curated index. Use Section 4 only to find the introducing paper and implementation for the mechanism your measurement points to.

  • PyTorch 2.14 ProfilerPyTorch

    Read the Overview example plus the API reference for torch.profiler.profile (activities, schedule, on_trace_ready, record_shapes, with_stack), torch.profiler.record_function and export_chrome_trace. Use it for exact profiler and NVTX-range call contracts missing from the book.

  • vLLM Documentation - Automatic Prefix CachingvLLM Project

    Read Automatic Prefix Caching (vLLM v0.31.0) for hash-based block reuse, full-block caching, reverse-order freeing and the multimodal hashing example. Use it for engine behavior the papers do not version.

  • Transformer Inference ArithmeticKipply

    Read kv cache, capacity, latency calculations, batch sizes and flops counting for per-token KV bytes, weight-capacity arithmetic and memory-bound versus compute-bound latency floors. Use it to derive endpoint bounds before measuring.