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

Request identity and KV version across phasesChecksums and layout compatibility
1

Read

In this order, only the parts listed

0 of 3 done

  1. 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.

  2. 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.

  3. 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.

2

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.
3

Try it yourself

Closed-book, before checking anything

On CPU, build synthetic KV with two layers, three positions, two heads and head dimension four, using successive 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.
4

Quiz yourself

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

0 got · 0 missed

  1. 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. 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. 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. 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