Unit 9 of 11 · about 4 hours · explain, implement
Request identity, KV versions, checksums and layout compatibility
A successful transfer can deliver perfectly intact KV for the wrong request or model. Decode needs both byte integrity and a compatible, live request identity before it can publish or consume that state.
You'll be able to
- Implement a handoff envelope that binds request attempt, model and KV version, tensor geometry, positions and tenant scope.
- Check serialized payload integrity independently from semantic and layout compatibility.
- Repartition synthetic KV between different phase layouts without losing, duplicating or reordering layer/head/position data.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Cross-phase request and layout identityTensorRT-LLM Disaggregated Serving and KV Cache Exchange
Disaggregated Serving, TensorRT-LLM commit cc63e66: KV Cache Exchange - Cache Layout Transformation and Unique Global Request ID, Figure 5 (page read 2026-10-14)
Read the need for a shared unique ID, not the snowflake generator as a universal uniqueness guarantee. Node/process identity assignment and restart behavior still need a deployment contract.
- Peer mapping and the missing version negotiationTensorRT-LLM Disaggregated Serving and KV Cache Exchange
Introduction to KV Cache Transmission, TensorRT-LLM commit cc63e66: Peer Registrar and Mappers; Page Table; Supporting a New Cache Layout; Current Limitations (page read 2026-10-14)
The page says peer metadata carries no version tag and both sides need the same build and runtime. Your versioned servelab envelope is a protective design exercise, not a claim that this engine negotiates versions.
- Digest the declared byte representationPython 3.14 hashlib - byte digests for KV integrity checks
Usage and Hash Objects: SHA-256 construction, incremental update, digest and hexdigest
Stop before SHAKE, file hashing, key derivation and BLAKE2. This unit checks accidental corruption, not a security protocol.
Focus on
- Build on Exact prefix identity, version scope and tenant privacy scope. Bind prompt token IDs, tokenizer/model/adapter revision, positions, cache dtype and format, tenant scope and request attempt to the handoff; a request ID alone cannot prove compatible KV.
- Describe layer, head and token-position ranges plus valid length, page ordering and destination mapping. A producer using head shards and a consumer using layer shards need a redistribution, not merely a byte copy.
- Define a canonical byte order and dtype for the checksum, or explicitly check raw source fragments before conversion. Lossless layout conversion preserves values but may change raw byte ordering; lossy dtype conversion requires its own numerical contract.
- Publish destination KV only after metadata checks, complete payload validation and ownership transition. A matching digest does not establish freshness, authorization or absence of an adversarial substitution.
Common mistakes · 3
- Using a payload checksum as the cache-identity key. The same bytes can be intact yet belong to a stale attempt or an unauthorized tenant.
- Treating matching tensor shapes as matching layouts. Head-major and token-major buffers can have equal element counts and different meanings.
- Installing a received block table before validating every fragment. A partial transfer then becomes visible to attention.
Try it yourself
Closed-book, before checking anything
float32 values in layer-position-head-feature order. Split by head into two producer fragments, then reconstruct two consumer fragments split by layer and stored in layer-head-position-feature order. Round-trip to the canonical order and require exact value recovery. Digest the canonical bytes with hashlib.sha256, flip one payload bit, and reject it before publication. Reject an intact payload with a mismatched model revision or attempt too.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.An old-model KV payload has the expected checksum. Should decode accept it?Answer
No. The digest checks the declared bytes, not the model revision or semantic compatibility. Reject incompatible metadata before using the cache.
2.Should raw digests match after a head-position transpose?Answer
Not generally. The byte order changed. Compare in an agreed canonical order, or validate raw fragments separately and check the mapping by value.
3.Why does a retry need an attempt identity as well as a logical request ID?Answer
A late callback or payload from the previous attempt must not install state into the new attempt. The attempt identity lets the receiver fence that stale work.
4.Does SHA-256 alone authenticate who produced KV?Answer
No. Anyone able to replace both data and digest can supply a new matching pair. Authentication and tenant authorization are separate requirements.
You're done when
Your lossless mapping round-trip preserves every KV value, and corrupt, incomplete, stale or incompatible envelopes are rejected before destination KV becomes visible.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 11 more in the section
- TensorRT-LLM Disaggregated Serving and KV Cache ExchangeNVIDIA · required
Study the KV exchange abstraction, unique request identity, layout conversion, overlap and fleet-worker model. Use its reproducible benchmark sections only on supported hardware and pin the release.
- Python 3.14 hashlib - byte digests for KV integrity checksPython Software Foundation · reference
Usage and Hash Objects only: compute and compare a SHA-256 digest over a declared canonical KV payload. Add request/version checks separately; a byte digest is not cache compatibility or authentication.
Also in this section
- DistServe: Disaggregating Prefill and Decoding for Goodput-Optimized LLM ServingPeking University and Microsoft Research · primary
Read the interference model, independent phase parallelism, placement, KV transfer and goodput evaluation. Reuse the break-even method with your workload and topology; do not transfer the paper's speedups to different hardware.
- AI Systems Performance Engineering - Chapters 15 and 17, distributed and disaggregated inferenceChris Fregly (O'Reilly) · required
Read the disaggregated prefill and decode architecture and the MoE parallelism strategies in Chapter 15, then Chapter 17 on disaggregated pools, routing policies and scalability. Reproduce every communication and KV-transfer estimate for a small declared topology.
- AI Systems Performance Engineering companion code - Chapters 15 and 17Chris Fregly · required
Use the single-device KV-handoff and simulation paths before the multi-GPU pairs. Then choose one disaggregation, routing or MoE target compatible with available hardware and keep bundled results separate from newly captured evidence.
- Hands-On LLM Serving and Optimization - Chapter 7, multi-GPU and disaggregationChi Wang and Peiheng Hu (O'Reilly) · support
Read "Multi-GPU and Multi-Node Inferencing" (data, tensor, pipeline and expert parallelism) and "Prefill-Decode Disaggregation" (architecture, KV transfer, when to use it) in Chapter 7.
- NVIDIA Dynamo - Disaggregated Serving and KV-Aware RoutingNVIDIA · required
Trace frontend, prefill router, prefill worker, KV transfer, decode routing and decode worker. Record how load, cache overlap, worker discovery and transfer metadata affect placement; implement only a small simulated or available-hardware slice.
- SGLang documentation - PD DisaggregationSGLang Project · support
Use the transfer backends, router integration, heartbeat, timeout and cleanup behavior as a second engine's view of the same handoff.
- Mooncake: A KVCache-Centric Disaggregated Architecture for LLM ServingMoonshot AI · support
Read the KV-centric architecture, transfer engine and scheduling sections to understand remote cache pools. Compare its assumptions with DistServe and your simpler handoff; defer reproduction requiring a large cluster.
- 100 Days of LLM Inference - Days 12, 17 and 18Elizabeth Thomas · support
Use the Dynamo, model-parallelism and disaggregation notebooks for a compact topology simulator and request-handoff trace. Label notebook outputs as local analytical or simulated evidence unless real devices were used.
- TensorTonic Language Modeling from Scratch - Route Cache-Aware Prefill RequestsTensorTonic · support
Solve after the routing unit and compare its cost rule with your own placement model.
- LLM Inference: From scratch, one token at a time - Module 09Tushar Amrit · support
Work the Distributed Inference module's communication arithmetic before the tensor and pipeline parallel units.
- AI Performance Engineering - Distributed InferenceWafer · reference
A curated index. Use Section 5 only to find a distributed-serving paper the other entries lack.