Unit 7 of 11 · about 2 hours · explain
Multimodal encoder and decoder co-execution
Images enter as embedding runs inside a text request. Their encoding and hashing decide both batch geometry and reuse safety.
You'll be able to
- Explain encoder and decoder co-execution and how encoder batches change decode geometry.
- State the multimodal prefix-hash rule and one false-sharing failure it prevents.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Multimodal throughput and reuse evidenceSGLang
Section 6.2 with Table 2: throughput for LLaVA-v1.5-7B images on one A10G 24 GB and LLaVA-NeXT-34B video on one 80 GB A100 (Appendix C), and the RadixAttention hit rates reported from deployment
- Multimodal block-hash rulevLLM Documentation - Automatic Prefix Caching
Automatic Prefix Caching (vLLM v0.31.0), hashing example with multi-modality inputs: placeholder runs, per-block image-hash extras, block size 16 with 41 placeholders
Focus on
- The encoder runs once per image or segment while the decoder steps per token. Co-execution shares the scheduler, KV pool and batch slots, so encoder work changes decode batch geometry.
- Image regions become placeholder token runs replaced by embeddings at prefill. Prefix identity must hash the image content, not just the placeholder IDs, or different images falsely share KV.
- Read Table 2 as a throughput comparison against the stated Transformers baseline on the stated GPUs, not as a universal speedup. The 52.4 and 74.1 percent hit rates come from a month of deployment, for LLaVA-NeXT-34B and the Vicuna-33B chat model, not from Table 2's runs.
Common mistakes · 3
- Batching images as if they were text tokens. Encoder capacity, placeholder expansion and embedding replacement follow different rules.
- Hashing only placeholder IDs. Different images then share KV and corrupt output.
- Reading a multimodal throughput table without its baseline, bench and hit rate. All three set the result.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Where does encoder work sit in the request lifecycle?Answer
It runs once per image input and feeds embeddings into prefill, while the decoder then steps token by token. Its batch slots and KV-pool share affect live decode geometry.
2.Do identical placeholder runs imply reusable KV?Answer
No. Placeholders are identical token IDs; the block hash must include the image hash so different images map to different KV.
3.Does the multimodal throughput table promise a general speedup?Answer
No. It compares stated model pairs on stated benches with stated hit rates. Different images, batch mixes or baselines change it.
You're done when
You can place encoder work on the lifecycle diagram and defend the prefix-hash rule for a shared-text, different-image pair.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 12 more in the section
- SGLangSGLang Authors · support
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.
- vLLM Documentation - Automatic Prefix CachingvLLM Project · reference
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.
Also in this section
- AI Systems Performance Engineering - Chapters 13, 15 and 16Chris Fregly · primary
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 · required
Use compatible examples from
code/ch12throughcode/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. - AI Performance Engineering - Inference EnginesWafer · reference
A curated index. Use Section 4 only to find the introducing paper and implementation for the mechanism your measurement points to.
- PagedAttention and vLLMvLLM Authors · required
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 · required
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.
- FlashInferFlashInfer Project · support
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 · support
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.
- PyTorch 2.14 ProfilerPyTorch · reference
Read the Overview example plus the API reference for
torch.profiler.profile(activities,schedule,on_trace_ready,record_shapes,with_stack),torch.profiler.record_functionandexport_chrome_trace. Use it for exact profiler and NVTX-range call contracts missing from the book. - Orca (OSDI 2022)USENIX · support
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 · support
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 · support
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.
- Transformer Inference ArithmeticKipply · reference
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.