Repository navigation
docs(2778): land the KV-contents reproducer and its spec - #3077
Conversation
Add examples/kv_history_divergence.rs, the target-only harness that compares logits and KV contents of plain and block-built histories for lablup#2778, and docs/kv-contents-reproducer-spec.md, which states what a decisive answer requires and what the measurements so far do and do not license. Update docs/temperature-0-block-history-flip.md: the harness is now in the tree, so drop the "not in this tree" note, scope the document's own claim to "its own evidence never touches the cache", and record the width-axis and 448-token-span results together with their exact scopes. Refs lablup#2778
…gence The harness decoded every 2-byte KV element as fp16, so a bf16 cache (the common case for mlx-community checkpoints) produced meaningless kv_max_abs, kv_rms and kv_rms_rel values. It also read int8 as unsigned, compared byte runs of possibly different shapes by truncating zip, and reported "no divergence" when the model owns its caches and the snapshot held no KV at all. The example now names the dtype from the MLX code and decodes float16, bfloat16, float32 and signed int8, rejecting anything else. It requires matching layer counts, dtypes and shapes in both arms, and errors when no layer exposes readable KV. Docs: the spec is unwrapped, em dashes removed, stale cache.rs line anchors replaced by symbol names, and its status line now says the harness exists while the dump and comparator are still proposals. Corrected two factual errors: the harness traces every W-th history length (the 28 positions at W = 16 over 448 tokens are all traced positions, not a filtered subset), and the quoted "left open" status comment was not written by the reporter. Non-byte-identical KV rules out outcome 1 but does not trip the reopening trigger by itself; both docs now say so. Refs lablup#2778
Hardening summaryMerged current Harness fixes in
Doc corrections:
Validation (M3 Ultra, Metal, under the GPU lock): example builds and passes clippy This PR delivers the harness, not the criterion: the pos 197 swing is still unreproduced, so it stays |
What
Two deliverables that were prepared for #2778 but never committed, plus the
doc update that becomes correct once the harness is in the tree.
examples/kv_history_divergence.rs— the target-only harness the issue asksfor: it compares logits and KV contents of a plain one-token-append
history against a block-built history, instead of holding the cache fixed.
Auto-discovered by Cargo (no manifest change; same as
logit_trace.rs).docs/kv-contents-reproducer-spec.md— what a decisive answer requires,the three admissible outcomes for block width
Mvs decodeM = 1(equal / rounding-equivalent / corrupted), the measurement method, and
explicit limits on what the numbers license.
docs/temperature-0-block-history-flip.md— the harness was previouslydescribed as "posted on Explain the temperature 0 flip between plain and block-built KV history #2778, not in this tree". It is in this tree now,
so the bullet is rewritten to say that, to scope this document's own claim
correctly ("its own evidence never touches the cache"), and to point at the
spec.
Measured (each figure names its own run)
Width-axis sweep, Qwen3-0.6B-4bit, M1 Pro, 64-token context, 64-token span:
Second run,
W = 16, 64-token context, 448-token span: 28 of the 448positions carry differing KV bytes,
kv_rms_relreaches 0.0455 with up to73.97% of elements perturbed, and a whole-vocabulary logit delta of
2.757812 at pos 352. Across all 28 diverging positions the top-1 logit
consumes at most 5.455% of its top-2 margin;
margin_consumed_positionsis 0.
What this does and does not claim
positions_with_flipis 0 overthe 448-token span. An absolute reproduction needs the reporter — the
original
Qwen3 copyprompt text, token ids and length are not in theissue, and the reported condition is M1 Ultra Metal while these
measurements are M1 Pro Metal.
corrupted KV contents, live on the width axis: plain and block-built float
KV histories are not byte-identical beyond rounding.
proves both arms wrote the same token to the same slot.
arm_repeats_identicalproves one arm reproduces itself, and the zerorow at
W <= 8proves the harness does not manufacture divergence —both necessary, neither sufficient.
Note for anyone consuming the trace output: the schema is 17 columns;
d_top1is field 11 and
flipmoved from 16 to 17.Refs #2778