Skip to content
Merged
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
8 changes: 8 additions & 0 deletions python/sglang/srt/arg_groups/speculative_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
resolving_view,
run_post_process_pass,
)
from sglang.srt.environ import envs
from sglang.srt.platforms import current_platform
from sglang.srt.runtime_context import get_platform

Expand All @@ -35,6 +36,7 @@ def _should_auto_enable_hip_rejection_sampling(
accept_threshold_single: float,
accept_threshold_acc: float,
enable_deterministic_inference: bool,
simulate_acc_len: float = -1.0,
) -> bool:
"""Whether HIP may default ``speculative_use_rejection_sampling`` on.

Expand All @@ -43,6 +45,10 @@ def _should_auto_enable_hip_rejection_sampling(
would crash configs that previously ran greedy on HIP, including EAGLE3
stage-a ``test_basic_sanity_eagle3`` (draft 32000 vs target 128256). Skip
EAGLE3 and any EAGLE run that already has a token map.

Also skip when ``SGLANG_SIMULATE_ACC_LEN`` is on: AgentX throughput still
runs the real EAGLE verify then overwrites accept length, so the Triton
chain sampler is paid for and thrown away.
"""
return (
is_hip
Expand All @@ -53,6 +59,7 @@ def _should_auto_enable_hip_rejection_sampling(
and accept_threshold_single == 1.0
and accept_threshold_acc == 1.0
and not enable_deterministic_inference
and simulate_acc_len <= 0
)


Expand Down Expand Up @@ -1005,6 +1012,7 @@ def _handle_eagle_family(server_args: ServerArgs) -> None:
accept_threshold_single=cfg.speculative_accept_threshold_single,
accept_threshold_acc=cfg.speculative_accept_threshold_acc,
enable_deterministic_inference=cfg.enable_deterministic_inference,
simulate_acc_len=float(envs.SGLANG_SIMULATE_ACC_LEN.get()),
):
declare_resolution(
server_args,
Expand Down
6 changes: 6 additions & 0 deletions test/registered/unit/spec/test_eagle_gate_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def test_cuda_never_flips(self):
def test_already_on_is_a_no_op(self):
self.assertFalse(_hip_auto_enable(use_rejection_sampling=True))

def test_simulate_acc_len_stays_off(self):
# AgentX throughput overwrites accept after real verify; skip the
# Triton chain sampler so HIP stays on the greedy argmax path.
self.assertFalse(_hip_auto_enable(simulate_acc_len=3.39))
self.assertTrue(_hip_auto_enable(simulate_acc_len=-1.0))


if __name__ == "__main__":
unittest.main()
Loading