Repository navigation
Description
Motivation
Cache correctness is difficult to verify from model output alone. A corrupted KV block or recurrent-state checkpoint can still produce fluent text, and the resulting numerical drift can remain far below the tolerance used by accuracy and KL tests. These failures have shipped because the existing signals are approximate.
Bit-exact logprob consistency turns one of these approximate signals into a correctness oracle. kl_test_utils evaluates the same token through prefill and decode. If both paths are batch-invariant and compute the same function, they must produce identical logprobs. Once that baseline is established, the contract for every cache-reuse path becomes:
Any nonzero KL is a KV/state reuse bug.
This is stronger than threshold-based testing. It does not ask whether the error is large enough to matter to a benchmark. It asks whether restoring cached state is exactly equivalent to recomputing it. Bugs that previously sat below a model-specific noise floor become unambiguous regressions.
Examples:
- Incorrect reused state: [srt] Fix sconv state memory corruption on specdec #34043, Fix stale track rows corrupting conv checkpoints under the prefill graph #34184, Fix Mamba track-boundary bookkeeping under overlap scheduling #29792
Foundation
Bit-exactness depends on the model and execution path. Deterministic inference can remove batch-dependent kernel and communication behavior, but it cannot make two mathematically different algorithms identical. For example, Qwen3-Next uses different GDN kernels for prefill and decode, and retains a nonzero numerical floor.
Inkling provides the combination needed for continuous gating. Its prefill and decode paths compute the same function, so under deterministic inference its prefill-versus-decode KL is exactly 0. A shrunken checkpoint runs on one GPU. The model also contains FULL, SWA, and MAMBA cache components, so one test process exercises full KV, sliding-window, and recurrent-state reuse together.
The resulting foundation has four layers:
- deterministic execution makes repeated computation batch-invariant;
- logprob consistency establishes an exact prefill/decode baseline;
- cache tests apply that baseline to each state restoration path;
- revert-then-red validation proves that each regression guard can detect the defect it claims to cover.
Supporting work:
- Inkling deterministic execution: Fix deterministic inference for Inkling #33417, Fix deterministic inference all-reduce for tp>1 #34159
- Workflow tools: KL consistency test skill, Add skill for the logprob consistency tests #34169
- Real-weight consistency coverage: Add deterministic logprob-consistency test for inkling-small nvfp4 #34168, Add bit-exact hicache logprob-consistency test #34356
- Per-commit guards: Add bit-exact unified radix cache KL test for hybrid SWA + mamba #34607
- Calibration and follow-up validation: Fix flaky decode cache-hit check in Inkling test #34405, Enable unified cache out-of-window slot freeing by default #34653
Roadmap
The remaining work is coverage, not a new testing method. Every feature that can save, move, or restore model state introduces a distinct correctness boundary and needs its own exact-KL test class.
- Base cache path
- Mamba
extra_buffer - Mamba
extra_buffer_lazy - HiCache multi-turn
- Speculative decoding
- Unified memory
Activity
200lz commentedon Aug 15, 2026
The revert-then-red requirement is especially strong. For the remaining speculative/cache arms, would it help if each exact-KL result also emitted a compact manifest of the resolved state path — cache mode, speculative method/backend, checkpoint revision, and restore generation? Then any nonzero KL could be tied directly to the exact reuse path that produced it.
github-actions commentedon Oct 20, 2026
This issue has been automatically closed due to inactivity. Please feel free to reopen it if needed.