Repository navigation
Conversation
ListenJ
marked this pull request as ready for review
November 4, 2026 16:59
This comment has been minimized.
This comment has been minimized.
2 of 3 tasks
Author
|
CI status note for reviewers:
Could a maintainer add the |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Fix] deterministic: replay hybrid Mamba prefix instead of restoring donated state
Motivation
Hybrid linear-attention (Gated DeltaNet) models return different greedy logprobs
and tokens for the same prompt depending on whether it was served cold or from
the radix cache. Reproduced on SGLang 0.5.23 with
Qwen/Qwen3.5-4B(hybrid GDN,24 GDN layers + 8 full-attention layers) on an RTX 4090:
temperature=0, seed=0, max_tokens=192, logprobs=true--disable-radix-cache: 0/5 divergent, logprob maxdiff 0.0--enable-deterministic-inference(radix on): still 3/5 divergent (positions 22/45/142), maxdiff 0.0691–1.3964#47213reports the same class on Qwen3.5-9BRoot cause (consistent with #47213 / #41351 / #33515): a radix hit can restore a
Mamba checkpoint that was produced by an earlier, differently shaped prefill
(decode-time tracking), and the persisted state went through a BF16 boundary while
the cold path kept FP32 internally. The restored state is not numerically
interchangeable with a cold prefill, so greedy logprobs/tokens drift even under
--enable-deterministic-inference. #46351 / FlashInfer #2830 fix the separateFA2 tile/batch-composition issue, not this recurrent-state path (maintainer note
in #46351: "hybrid GDN (Qwen3.5) drift ... is a separate path, covered by neither fix").
Change
In
arg_groups/overrides.py::_mamba_radix_cache_resolution, when the strategy isleft on
auto, the model supports the Mambaextra_bufferradix cache, anddeterministic inference is enabled:
no_bufferreplays the recurrent computation instead of restoring donated Mambastate, so a cache hit follows the same recurrent path as a cold prefill for the
hybrid state (
no_bufferrequires overlap scheduling off). Attention KV cachehandling is unchanged.
If the user explicitly opts into
--mamba-radix-cache-strategy extra_buffertogether with
--enable-deterministic-inference, the choice is kept but a loudwarning explains that cold/cache-hit logprobs can differ (#47213), instead of
silently breaking the deterministic contract.
Behavior / cost
--enable-deterministic-inference; default mode unchanged.cold/hit equivalence (cost: prefix reuse for the recurrent state).
fast through the existing
validate_mamba_no_buffer(page_size=1, no overlap,no trtllm_mha).
Tests
test/registered/unit/managers/test_mamba_radix_cache_deterministic.py:deterministic auto ->
no_buffer+ overlap off; non-deterministic auto ->extra_buffer; explicit strategy preserved; explicit extra_buffer warns underdeterministic;
--disable-radix-cachetakes precedence. 5/5 pass locally.main(patch -p1 --dry-run, offset -9).Validation (pre-PR matrix, RTX 4090 24GB / driver 610.57.04 / CUDA 13.4 / SGLang 0.5.23)
20 prompts (needle/math/code/JSON/translation/table/compare/error-check), greedy
(
temperature=0, seed=0, max_tokens=192, logprobs=true), 1 cold + 4 cache-hitrepeats per prompt:
--disable-radix-cachecontrolDefault (non-deterministic) mode is intentionally out of scope here and still
shows drift (consistent with #41351); it needs the deeper recurrent-state fix
(#47213/#33515 direction), not this deterministic-contract workaround.
Concurrency and long-context variants are left for follow-up testing.
CI States
Latest PR Test (Base): ❌ Run #41874359113
Latest PR Test (Extra): ❌ Run #41874359261
Latest PR Test (AMD ROCm 10): ❌ Run #41874358649
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: