Repository navigation
[Fix] deterministic: Disable mixed chunked prefill - #44701
aarnetalman wants to merge 1 commit into
Conversation
With --enable-mixed-chunk, a batch can hold prefill chunks and decode tokens together, and the whole batch runs the prefill (extend) attention path. A decode token's result then depends on whether a prefill happened to share its step, which deterministic inference must not allow: the extend and decode kernels reduce in different orders (the prefill vs decode difference that test_deterministic's p_vs_d mode measures), and with per-phase backends they can be different backends. Deterministic mode now switches --enable-mixed-chunk off with a warning, as it already does for --enable-aiter-allreduce-fusion.
rkarhila-amd
left a comment
There was a problem hiding this comment.
Another small safety catch to make sure user does not use wrong configuration for deterministic inference. I guess even smallest holes should be blocked. Can't see this causing any harm.
|
Not a stopper, but why a warning instead of raising error? |
Thanks, good question. I followed what deterministic mode already does with options it can't honour: in the same function, |
Motivation
Deterministic inference promises the same output for a request whatever else is in the batch, but
--enable-mixed-chunkbreaks that. With it, the scheduler can put a prefill chunk and decode tokens into one batch, and the whole batch runs the prefill (extend) attention path. So a decode token's result depends on whether a prefill happened to share its step:test_deterministic --test-mode p_vs_dmeasures);--prefill-attention-backend/--decode-attention-backend), they can even be different backends.Mixed chunked prefill is off by default, so this only bites users who turn it on together with
--enable-deterministic-inference. Found in the review of #44489 (AITER decode attention in deterministic mode), where a mixed batch would run its decode tokens on the prefill backend.Modifications
arg_groups/attention_hook.py(handle_deterministic_inference): in deterministic mode,--enable-mixed-chunkis switched off with a warning, as deterministic mode already does for--enable-aiter-allreduce-fusion.test_model_overrides.py: deterministic mode resolvesenable_mixed_chunktoFalse; without it, the flag is kept.--enable-mixed-chunk.Accuracy Tests
MI350X,
rocm/sgl-dev:v0.5.21-rocm724-mi35x-20261013,SGLANG_USE_AITER=1, Qwen3-8B TP1. Deterministic mode with Triton attention and--enable-mixed-chunk, with the open fixes #43788 and #34543 applied (deterministic mode on MI350X needs them):python3 -m sglang.test.test_deterministic --test-mode {single,prefix,radix_cache} --n-trials 50,--test-mode prefix --return-logprob, and a bitwise batch-size check (the same prompt in batches of 1 to 50, 1,275 responses; token IDs and logprobs compared exactly with the batch-size-1 response), each on a fresh server:enable_mixed_chunk: True)enable_mixed_chunk: False)Before, the 511-character prompt of
prefixmode, sent with other prompts of different lengths, produced two different outputs across 293 samples: its decode steps sometimes shared a batch with a prefill chunk.singleand the bitwise check send one prompt per batch, so nothing is mixed there.Unit tests,
python3 -m pytest test/registered/unit/test_model_overrides.py -k deterministic(same image): before, the new test fails (1 failed, 3 passed); after, 4 passed.Speed Tests and Profiling
No change without
--enable-mixed-chunk. With it, deterministic mode now runs without mixed batches, as when the flag is not given.Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #38869885037
Latest PR Test (Extra): ❌ Run #38869885002
Latest PR Test (AMD ROCm 10): ❌ Run #38869885162