From 51624199b405f0962a3ef2cfb7060ae1647a865a Mon Sep 17 00:00:00 2001 From: "minke.yu" Date: Mon, 19 Oct 2026 10:35:29 +0800 Subject: [PATCH] PR #41294: use the fused low-ratio compressor on Hopper (sm90 gate) Source: https://github.com/sgl-project/sglang/pull/41294 (applied via GitHub .diff, 3way) Skipped: test_dsv41_fused_compress.py (file not in v0.5.21 base). --- .../sglang/srt/layers/attention/dsv4/dsv41_sparse.py | 12 +++++++----- .../ops/attention/dsv4/test_c2_prefill_ring.py | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/python/sglang/srt/layers/attention/dsv4/dsv41_sparse.py b/python/sglang/srt/layers/attention/dsv4/dsv41_sparse.py index 2ffce44b4a..b2347658f5 100644 --- a/python/sglang/srt/layers/attention/dsv4/dsv41_sparse.py +++ b/python/sglang/srt/layers/attention/dsv4/dsv41_sparse.py @@ -87,12 +87,14 @@ def rope_tail( def fused_low_ratio_compress_supported() -> bool: - """The fused c1 / c2 / index-K decode kernels pack fp4 with - `cvt.rn.satfinite.e2m1x2`, an sm100+ instruction; the answer also fixes the - ratio-2 weight layout (`wkv_gate`, or `wkv` plus `wgate`).""" - if not torch.cuda.is_available() or torch.version.hip is not None: + """The fused c1 / c2 / index-K decode kernels need sm90+ on CUDA or gfx950 on + ROCm; the answer also fixes the ratio-2 weight layout (`wkv_gate`, or `wkv` + plus `wgate`).""" + if not torch.cuda.is_available(): return False - return torch.cuda.get_device_capability()[0] >= 10 + if torch.version.hip is not None: + return is_gfx95_supported() + return torch.cuda.get_device_capability()[0] >= 9 class DeepseekV41Compressor(nn.Module): diff --git a/test/registered/kernels/ops/attention/dsv4/test_c2_prefill_ring.py b/test/registered/kernels/ops/attention/dsv4/test_c2_prefill_ring.py index 598011ca31..5ff2a11d1f 100644 --- a/test/registered/kernels/ops/attention/dsv4/test_c2_prefill_ring.py +++ b/test/registered/kernels/ops/attention/dsv4/test_c2_prefill_ring.py @@ -22,9 +22,10 @@ from sglang.srt.utils import is_cuda from sglang.test.ci.ci_register import register_cuda_ci from sglang.test.test_utils import CustomTestCase -# The c2 JIT kernels are the SM100 build; the only Blackwell runner config is the +# The c2 JIT kernels serve SM90 and SM100; the only Blackwell runner config is the # four-GPU one. register_cuda_ci(est_time=60, stage="base-b-kernel-unit", runner_config="4-gpu-b200") +register_cuda_ci(est_time=60, stage="base-b-kernel-unit", runner_config="1-gpu-large") HEAD_DIM = 512 ROPE_DIM = 64 @@ -36,8 +37,8 @@ EPS = 1e-6 SLOT_BASE = 64 -def _sm100() -> bool: - return is_cuda() and torch.cuda.get_device_capability()[0] == 10 +def _fused_c2_device() -> bool: + return is_cuda() and torch.cuda.get_device_capability()[0] in (9, 10) class Stream: @@ -167,7 +168,7 @@ class TestC2PrefillRing(CustomTestCase): ) return caches, latents - @unittest.skipUnless(_sm100(), "the c2 JIT kernels are the SM100 build") + @unittest.skipUnless(_fused_c2_device(), "the c2 JIT kernels need SM90 or SM100") def test_chunked_extend_matches_decode(self): # Request 0 starts even, request 1 odd and spans more rows than the ring, # request 2 odd with a single row in its first chunk.