Skip to content

[Feature] Bit-exact correctness coverage for Unified Radix Cache #34899

Closed

Description

@ispobock

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:

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:

  1. deterministic execution makes repeated computation batch-invariant;
  2. logprob consistency establishes an exact prefill/decode baseline;
  3. cache tests apply that baseline to each state restoration path;
  4. revert-then-red validation proves that each regression guard can detect the defect it claims to cover.

Supporting work:

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.

Activity

  1. 200lz commented on Aug 15, 2026

    @200lz
    Contributor

    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.

  2. added
    enhancement
    deterministic
    on Aug 17, 2026
  3. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    This issue has been automatically closed due to inactivity. Please feel free to reopen it if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

deterministicenhancementinactiveunified-radix-cache

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions