Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python/sglang/srt/arg_groups/attention_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,18 @@ def handle_deterministic_inference(server_args: Any):
enable_aiter_allreduce_fusion=False,
)

# A mixed batch runs its decode tokens through the prefill (extend) kernels,
# so a decode step's result would depend on whether a prefill shares the batch.
if cfg.enable_mixed_chunk:
logger.warning(
"Disable --enable-mixed-chunk because deterministic inference is enabled."
)
declare_resolution(
server_args,
"_handle_deterministic_inference",
enable_mixed_chunk=False,
)

# Moved to the resolution pipeline (arg_groups/overrides.py:
# _deterministic_allreduce_fusion_disable), invoked here at its
# legacy slot.
Expand Down
17 changes: 17 additions & 0 deletions test/registered/unit/test_model_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,23 @@ def test_deterministic_inference_forces_pytorch_sampling(self):
)
self.assertEqual(self._leaf("attention_backend"), deterministic_fills[0])

def test_deterministic_inference_disables_mixed_chunk(self):
"""A mixed batch runs decode tokens through the extend kernels, so deterministic
mode must not put prefill and decode tokens in one batch."""
sa = self._construct(
"LlamaForCausalLM",
"llama",
enable_deterministic_inference=True,
enable_mixed_chunk=True,
)
self.assertFalse(resolution_result(sa, "enable_mixed_chunk"))
self.assertTrue(
resolution_result(
self._construct("LlamaForCausalLM", "llama", enable_mixed_chunk=True),
"enable_mixed_chunk",
)
)

def test_deterministic_incompatible_backend_raises(self):
from sglang.srt.arg_groups.overrides import (
ResolvedView,
Expand Down
Loading