[Fix] Keep deterministic GDN prefill on Triton (#35632)

This commit is contained in:
Mohammad Miadh Angkad
2026-08-20 19:38:53 +08:00
committed by GitHub
parent 82c6fc2db9
commit a4ffb996db
2 changed files with 60 additions and 2 deletions
@@ -11,15 +11,20 @@ from sglang.srt.layers.attention.linear import gdn_backend
from sglang.srt.layers.attention.linear.gdn_backend import (
GDNAttnBackend,
GDNKernelDispatcher,
_validate_gdn_linear_attn_backends,
flashinfer_gdn_prefill_default,
)
from sglang.srt.layers.attention.linear.kernels.gdn_flashinfer import (
maybe_build_flashinfer_checkpoint_plan,
)
from sglang.srt.layers.attention.linear.kernels.gdn_triton import TritonGDNKernel
from sglang.srt.layers.attention.linear.utils import LinearAttnKernelBackend
from sglang.srt.layers.attention.linear.utils import (
LinearAttnKernelBackend,
resolve_linear_attn_backends,
)
from sglang.srt.runtime_context import get_context
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
@@ -73,7 +78,7 @@ def make_runner(
)
class TestFlashInferGDNPrefillBackendPolicy(unittest.TestCase):
class TestFlashInferGDNPrefillBackendPolicy(CustomTestCase):
def apply_policy(
self,
runner,
@@ -119,6 +124,44 @@ class TestFlashInferGDNPrefillBackendPolicy(unittest.TestCase):
runner = make_runner(self, linear_attn_prefill_backend=backend)
self.assertIsNone(self.apply_policy(runner))
def test_declines_when_deterministic_inference_is_enabled(self):
"""Batch-sensitive GDN prefill must not bypass deterministic inference."""
runner = make_runner(
self,
state_dtype=torch.float32,
enable_deterministic_inference=True,
)
self.assertIsNone(
self.apply_policy(
runner,
capability=(9, 0),
cuda_version="12.9",
)
)
def test_rejects_explicit_flashinfer_prefill_in_deterministic_mode(self):
"""Explicit backend precedence must not bypass deterministic GDN startup."""
cases = (
{"linear_attn_prefill_backend": "flashinfer"},
{"linear_attn_backend": "flashinfer"},
)
for fields in cases:
with self.subTest(fields=fields):
make_runner(
self,
enable_deterministic_inference=True,
**fields,
)
backends = resolve_linear_attn_backends()
with self.assertRaisesRegex(
ValueError,
"FlashInfer GDN prefill is not supported with "
"--enable-deterministic-inference",
):
_validate_gdn_linear_attn_backends(backends)
def test_rejects_unsupported_capability(self):
cases = (
("non_cuda", {}, {"cuda": False}),