Model and Inference EngineeringKV cache and capacityPrincipal
What compatibility contract is required when prefill and decode exchange a KV cache?
By Amit Kumar3 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
A disaggregated service processes prompts on prefill workers and continues generation on decode workers. Prefill is upgraded to checkpoint B while decode still runs A, and transfer succeeds because shapes match. Explain why this may be wrong, design a semantic compatibility check and a safe rollout, and handle a change in FP8 scale representation even when both workers use checkpoint B.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
Prefill computes attention keys and values for an input prompt. Decode uses those states to continue generating tokens. The transferred cache therefore represents a particular model’s computation, not just tensors of a convenient size. Model A and model B can have identical dimensions but different weights, so B’s keys need not be the keys A would have computed. A checksum establishes transport integrity, not that the recipient interprets those bytes as the same state.
Suppose a hypothetical layer computes a key as k=Wk×h. A deployment changes Wk but leaves its shape unchanged. Transferring B’s key into A makes A’s next query attend to a history generated by another transformation. A conversion could be safe only under a proved compatible representation, with all required metadata, or by recomputing history under A. Retagging the tensor or observing grammatical output supplies neither proof.
I would make the router bind a request to an immutable compatibility group before prefill. The group includes the exact model and adapter revision, tokenizer and chat template identity, attention and position configuration, KV dtype and scaling scheme, serving engine or connector compatibility, and the tenant and prefix scope. The transfer carries a request identity, prompt token count, cache layout and version fingerprint. Prefill and decode check the contract before any KV is consumed. The documented vLLM NixlConnector compatibility check includes engine and connector versions, model geometry and dtype, attention backend, KV dtype and transfer mode. Application-level tokenizer, template and authorization identity still need their own checks. Do not pretend that the connector's hash covers them automatically.
For a rollout, create B-to-B prefill and decode capacity, warm it, then route a small new-request cohort there. Keep A-to-A for existing streams. Do not transfer an A live cache into B or casually retag a prompt prefix. If B decode capacity is unavailable, queue new B requests within a deadline, route eligible ones entirely through A, or refuse them. Recompute prefill on a compatible B worker if that is cheaper and safe than waiting. A mixed request must never be declared successful because it produced grammatical text.
The FP8 probe is subtle. In the current NixlConnector documentation, matching KV dtypes are required, static scales from the checkpoint are supported, and dynamic per-block scales are not supported because those scales are not transferred with the cache blocks. The same documentation separately supports packed layouts whose scales travel inline with the cache blocks. Compatibility therefore depends on the actual representation and transferred metadata, not a blanket rule about every runtime-computed scale. Both sides saying “FP8” is insufficient for that configuration. This is an implementation-specific limit to recheck when the engine version changes. Test handshake rejection, transfer timeout, retries, partial cache reuse, wrong tenant, tokenizer change, and a mid-rollout decode drain. Compare token-level outputs on fixed prefixes against a nondisaggregated B baseline. A compatibility failure should be visible before generation, not discovered by a customer's wrong answer.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux