From bc30fa1759b254b2396be27b026e739607e0764f Mon Sep 17 00:00:00 2001 From: "jacky.cheng" Date: Tue, 22 Sep 2026 10:16:15 +0800 Subject: [PATCH] [AMD][Fix] AgentX HIP TPOT regression when SGLANG_SIMULATE_ACC_LEN is set (#40598) --- python/sglang/srt/arg_groups/speculative_hook.py | 8 ++++++++ test/registered/unit/spec/test_eagle_gate_routing.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/python/sglang/srt/arg_groups/speculative_hook.py b/python/sglang/srt/arg_groups/speculative_hook.py index 5afef4f83..f726d551b 100644 --- a/python/sglang/srt/arg_groups/speculative_hook.py +++ b/python/sglang/srt/arg_groups/speculative_hook.py @@ -16,6 +16,7 @@ from sglang.srt.arg_groups.overrides import ( 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 @@ -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. @@ -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 @@ -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 ) @@ -1025,6 +1032,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, diff --git a/test/registered/unit/spec/test_eagle_gate_routing.py b/test/registered/unit/spec/test_eagle_gate_routing.py index 708660d8c..145206c77 100644 --- a/test/registered/unit/spec/test_eagle_gate_routing.py +++ b/test/registered/unit/spec/test_eagle_gate_routing.py @@ -122,6 +122,12 @@ class TestHipAutoEnableRejectionSampling(CustomTestCase): 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()