What happens when an instance accepts a draft token whose KV-cache provenance diverges from the verifier's positional encoding
**Date of Record:** 2026 December 1 **Scope:** Applies to federated speculative-decoding setups where a small drafter agent emits candidate tokens and a larger verifier agent accepts/rejects them, with KV-cache blocks shared (or transferred) across heterogeneous runtimes (e.g., different RoPE scaling configs, different `max_position_embeddings`, different attention kernels). Does not apply to single-runtime co-located speculative decoding where drafter and verifier share one KV-cache namespace.
Core Distinction
The failure is not a *token* mismatch — the drafter's candidate tokens are lexically identical to what the verifier would have produced. The failure is a *positional-encoding provenance* mismatch on the KV blocks the verifier reuses. Speculative decoding's correctness proof assumes the verifier recomputes attention over the drafted tokens using KV entries whose position IDs are consistent with the verifier's own RoPE base and scaling. In a federated setup, the drafter (say, a 7B model on runtime A with RoPE base 10,000 and linear scaling 1.0) writes KV entries tagged with position IDs derived from *its* encoding. The verifier (70B on runtime B, RoPE base 500,000, dynamic NTK scaling, `max_position_embeddings` 131,072) ingests those blocks and, if the handoff protocol carries only token IDs and a coarse `seq_offset`, reconstructs position IDs from *its own* scheme.
For short contexts the two schemes agree closely enough that acceptance rates look normal and logit deltas stay inside the tolerance band. The boundary condition is a *positional* one, not a semantic one: once the shared prefix crosses the region where the two RoPE schemes' phase rotations diverge by more than the verifier's acceptance epsilon, the verifier begins accepting draft tokens that it would have rejected had it recomputed from scratch — because the corrupted KV entries bias the verifier's own logits toward the drafter's proposal. The verifier's rejection sampler is no longer independent of the drafter. Speculative decoding collapses into ordinary autoregressive decoding with a poisoned cache, and the poisoning is silent because every individual check (token match, logit tolerance, schema validity) passes.
What Was Observed
A three-node federation: drafter D (runtime A, 7B, RoPE θ=10,000, no scaling), verifier V (runtime B, 70B, RoPE θ=500,000, YaRN scaling factor 4), auditor A (runtime C, 70B, recomputes from scratch as ground truth). Cache blocks transferred over MCP with a payload of `{block_id, token_ids, pos_start, pos_end, k, v, dtype, rope_tag}` where `rope_tag` was a free-form string that D populated with `"default"` and V's ingestion code treated as advisory only.
Observed across ~40k speculative steps on a long-document summarization workload:
- **Acceptance rate drift.** V's acceptance rate on D's drafts rose monotonically with absolute position: 0.61 at pos < 2k, 0.78 at pos 2k–8k, 0.94 at pos > 16k. A rising acceptance rate is the opposite of the expected degradation curve and is the first tell — a correctly federated verifier should reject *more* as the drafter's distribution drifts, not less.
- **Auditor divergence.** A, recomputing the same positions from scratch with V's config, disagreed with V on 3.1% of tokens in the pos > 16k region, versus 0.2% below 2k. The disagreements clustered at token boundaries immediately following a cache-block handoff, not uniformly.
- **Logit tolerance false-pass.** V's per-token logit-delta check against D's proposal (tolerance 0.35 nats) passed on 99.7% of accepted tokens, including the 3.1% that A flagged. The check compared V's logits *computed with the poisoned cache* against D's logits *computed with D's own cache* — both were internally consistent, so the delta was small. The check was measuring agreement between two identically-wrong computations.
- **Block-boundary amplification.** The per-token error was small, but errors compounded across chained handoffs: a block accepted at pos 16k carried forward into pos 16k+512, whose KV entries were then conditioned on the corrupted attention output. After four chained handoffs the effective RoPE phase error at the query position exceeded π, at which point the verifier's attention pattern inverted (attending to the wrong half of the context) rather than merely degrading.
The trigger condition is precise: **federated speculative decoding is unsound the moment the verifier's position-ID reconstruction for a transferred KV block differs from the position IDs under which those K/V tensors were originally rotated, by more than the verifier's acceptance epsilon in phase space.** The epsilon is not a fixed number — it depends on θ ratio, scaling function, and query position — but it can be bounded per (drafter_config, verifier_config) pair at handshake time.
Condition of Validity
The invariant that must hold for federated speculative decoding to preserve its correctness guarantee:
> For every KV block `b` transferred from runtime R_d to runtime R_v, the position IDs `p_d(i)` used to rotate `b.k[i]` and `b.v[i]` must satisfy `|p_d(i) - p_v(i)| < ε_phase(θ_d, θ_v, scaling_d, scaling_v, i)` for all `i` in the block, where `p_v(i)` is the position ID R_v would assign if it recomputed block `b` from scratch under its own config.
`ε_phase` is not a constant. For RoPE with base θ and position `p`, the rotation angle is `p·θ^(-2k/d)` for dimension pair `k`. Two runtimes with bases θ_d, θ_v diverge in angle by `p·|θ_d^(-2k/d) - θ_v^(-2k/d)|`, which grows linearly in `p` and is largest for the low-`k` (high-frequency) dimension pairs. For θ_d=10,000, θ_v=500,000, d=128, the divergence at p=16,384 exceeds π/2 for the k=0 pair — meaning the highest-frequency attention channel is rotated nearly a quarter-turn out of phase. That is the boundary.
Three further conditions the handoff must satisfy, each of which the observed system violated:
- **Provenance must be cryptographic, not advisory.** `rope_tag` as a free-form string is not a provenance record; it is a comment. The block must carry a signed tuple `(θ, scaling_fn, scaling_factor, max_pos, pos_ids_hash)` and the verifier must *reject* blocks whose tuple does not match its own, not warn.
- **Acceptance must be recomputed, not inherited.** The verifier's rejection sampler must run against logits computed from *re-derived* KV entries, not from the transferred entries directly. If the verifier reuses transferred entries to compute its own logits, its sampler is conditioned on the drafter's encoding and is no longer an independent check.
- **Chained handoffs must not compound.** If block `b_n` was accepted conditioned on `b_{n-1}`'s corrupted attention output, the corruption is now in `b_n`'s K/V regardless of `b_n`'s own provenance tuple. The invariant must be applied to the *attention output* that produced the block, not just the block's position tags — which means chained handoffs require either full recomputation at each hop or a verified Merkle chain over attention outputs.
Decision Boundary
The operational question is not "is the drafter and verifier config identical?" — they never are in a heterogeneous federation. The question is: **at what position does the phase divergence exceed the verifier's tolerance, and does the workload cross it?**
A workable decision procedure:
- At handshake, both runtimes exchange `(θ, scaling_fn, scaling_factor, max_pos, d_head)`.
- Compute `p_crit = min over k of (ε_phase / |θ_d^(-2k/d) - θ_v^(-2k/d)|)`, where `ε_phase` is set by the verifier's logit tolerance mapped through the attention softmax sensitivity (empirically, `ε_phase ≈ 0.3` radians for a 0.35-nat tolerance at typical attention temperatures).
- If the workload's expected sequence length exceeds `p_crit`, federated speculative decoding is unsound and must be disabled for that pair — fall back to co-located decoding or to a drafter that shares the verifier's config.
- If `p_crit` is not exceeded but chained handoffs are used, cap chain depth at `floor(p_crit / block_size)` and force full recomputation at the cap.
- Never trust `rope_tag` as a string; reject on tuple mismatch.
For the observed pair (θ_d=10,000, θ_v=500,000, d=128, ε_phase=0.3), `p_crit ≈ 4,100`. The workload routinely ran to 32k. The system was operating 8× past its soundness boundary for the entire measurement window, and every individual check passed.
Operational Effect
The downstream effects are not random degradation; they are a specific, directional bias. Because the verifier's sampler is conditioned on the drafter's encoding, the federation converges toward the *drafter's* distribution rather than the verifier's. On the summarization workload this manifested as:
- **Drafter-voice bleed.** Summaries adopted the 7B drafter's stylistic and factual tendencies (shorter clauses, higher hallucination rate on named entities) despite the 70B verifier being nominally in control. The verifier was, in effect, a 70B model running on a 7B model's world-model.
- **Silent failure.** No exception, no schema violation, no logit-tolerance breach. The only signal was the *rising* acceptance rate and the auditor's 3.1% disagreement — both of which require an independent from-scratch recomputation to detect.
- **Non-reproducibility.** Re-running the same workload produced different outputs because the phase-divergence point depends on token boundaries, which depend on the drafter's sampling, which is stochastic. The failure was real but not replayable from logs alone.
The guardrail is architectural, not statistical: **the verifier must own position-ID derivation for every KV block it attends over, and must reject — not warn on — any block whose provenance tuple it cannot verify against its own config.** Speculative decoding's acceptance guarantee is a statement about a *single* model's distribution; federating it across runtimes requires re-establishing that guarantee per handoff, and the only way to do that is to make the verifier's positional encoding the sole authority over the cache it reads.
import hashlib
from dataclasses import dataclass
class KVProvenanceError(RuntimeError):
"""Raised when a transferred KV block's positional-encoding provenance
diverges from the verifier's own config beyond the phase tolerance."""
pass
@dataclass(frozen=True)
class RopeConfig:
theta: float
scaling_fn: str # "none" | "linear" | "yarn" | "ntk"
scaling_factor: float
max_pos: int
d_head: int
@dataclass(frozen=True)
class KVBlock:
block_id: str
pos_start: int
pos_end: int
provenance: RopeConfig
provenance_sig: str # signature over (theta, scaling_fn, factor, max_pos, d_head)
k: bytes
v: bytes
# Empirical phase tolerance: 0.3 rad maps to ~0.35 nats logit delta
# at typical attention temperatures. Tune per verifier.
EPS_PHASE = 0.3
def _sign(cfg: RopeConfig) -> str:
payload = f"{cfg.theta}|{cfg.scaling_fn}|{cfg.scaling_factor}|{cfg.max_pos}|{cfg.d_head}"
return hashlib.sha256(payload.encode()).hexdigest()
def critical_position(drafter: RopeConfig, verifier: RopeConfig) -> int:
"""Smallest position at which any RoPE dimension pair's phase
divergence exceeds EPS_PHASE. Returns 0 if configs are incompatible."""
if drafter.d_head != verifier.d_head:
raise KVProvenanceError(
f"head dim mismatch: drafter d={drafter.d_head} verifier d={verifier.d_head}"
)
worst = float("inf")
for k in range(drafter.d_head // 2):
exp = -2 * k / drafter.d_head
d_theta = abs(drafter.theta ** exp - verifier.theta ** exp)
if d_theta < 1e-12:
continue
p = EPS_PHASE / d_theta
worst = min(worst, p)
if worst == float("inf"):
return 1 << 62 # configs identical in phase space
return int(worst)
def accept_block(
block: KVBlock,
verifier: RopeConfig,
workload_len: int,
chain_depth_so_far: int,
block_size: int,
) -> None:
"""Verify a transferred KV block before the verifier attends over it.
Raises KVProvenanceError on any provenance or phase violation."""
if block.provenance_sig != _sign(block.provenance):
raise KVProvenanceError(
f"block {block.block_id}: provenance signature invalid "
f"(declared {block.provenance})"
)
p_crit = critical_position(block.provenance, verifier)
if block.pos_end > p_crit:
raise KVProvenanceError(
f"block {block.block_id}: pos_end={block.pos_end} exceeds "
f"phase-soundness boundary p_crit={p_crit} for "
f"drafter theta={block.provenance.theta} vs "
f"verifier theta={verifier.theta}"
)
max_chain = max(1, p_crit // block_size)
if chain_depth_so_far > max_chain:
raise KVProvenanceError(
f"block {block.block_id}: chain depth {chain_depth_so_far} "
f"exceeds cap {max_chain}; attention-output corruption has "
f"compounded past the phase boundary — force full recompute"
)
if workload_len > p_crit:
raise KVProvenanceError(
f"workload length {workload_len} exceeds p_crit={p_crit}; "
f"federated speculative decoding is unsound for this pair — "
f"disable or co-locate drafter"
)