diff --git a/python/sglang/kernels/ops/attention/fla/fused_sigmoid_gating_recurrent.py b/python/sglang/kernels/ops/attention/fla/fused_sigmoid_gating_recurrent.py index 03a628bcfb..84da616fd0 100644 --- a/python/sglang/kernels/ops/attention/fla/fused_sigmoid_gating_recurrent.py +++ b/python/sglang/kernels/ops/attention/fla/fused_sigmoid_gating_recurrent.py @@ -581,6 +581,14 @@ def fused_sigmoid_gating_delta_rule_update( "match_cutedsl_decode is defined for the KDA softplus gate only " "(is_kda=True, lower_bound=None)." ) + if match_cutedsl_decode and _is_hip: + # The parity branch emits PTX (ex2/lg2.approx) to reproduce FlashInfer's + # CuTe DSL decode kernel. AMDGCN rejects it at compile time but the launch + # still runs, so without this check ROCm silently returns wrong values. + raise NotImplementedError( + "match_cutedsl_decode reproduces an NVIDIA-only kernel and is not " + "available on ROCm." + ) B, T, H, K, V = *k.shape, v.shape[-1] stride_q = q.stride()[1] stride_k = k.stride()[1] diff --git a/test/registered/attention/test_kda_kernels.py b/test/registered/attention/test_kda_kernels.py index dae5b0f733..e685e3990d 100644 --- a/test/registered/attention/test_kda_kernels.py +++ b/test/registered/attention/test_kda_kernels.py @@ -790,6 +790,7 @@ class TestKDAVerifyDecodeParity(CustomTestCase): ) return decode_output, decode_state, verify_output, verify_state[slots] + @unittest.skipIf(torch.version.hip, "match_cutedsl_decode is NVIDIA-only") def test_bf16_state_verify_matches_single_token_launches(self): for K in (128, 64): with self.subTest(head_dim=K): @@ -818,6 +819,7 @@ class TestKDAVerifyDecodeParity(CustomTestCase): verify_output.float(), decode_output.float(), atol=2e-2, rtol=1e-2 ) + @unittest.skipIf(torch.version.hip, "match_cutedsl_decode is NVIDIA-only") def test_fp32_state_pool_is_not_rounded(self): _, decode_state, _, verify_state = self._run_decode_loop_and_verify( B=2, T=16, H=4, K=128, state_dtype=torch.float32, match_decode=True @@ -826,6 +828,13 @@ class TestKDAVerifyDecodeParity(CustomTestCase): rounded = verify_state.to(torch.bfloat16).to(torch.float32) self.assertFalse(torch.equal(verify_state, rounded)) + @unittest.skipUnless(torch.version.hip, "ROCm rejects the parity mode") + def test_parity_mode_is_rejected_on_rocm(self): + with self.assertRaises(NotImplementedError): + self._run_decode_loop_and_verify( + B=1, T=1, H=1, K=64, state_dtype=torch.bfloat16, match_decode=True + ) + if __name__ == "__main__": unittest.main()