Fix MUSA detection in compiled prefill path (#39061)
This commit is contained in:
@@ -121,6 +121,24 @@ class TestCPStrategyUnit(CustomTestCase):
|
||||
):
|
||||
self.assertFalse(is_dsa_enable_prefill_cp())
|
||||
|
||||
def test_disabled_dsa_cp_skips_platform_probes(self):
|
||||
parallel = SimpleNamespace(attn_cp_size=1)
|
||||
|
||||
with (
|
||||
patch(
|
||||
"sglang.srt.layers.attention.dsa.utils.get_parallel",
|
||||
return_value=parallel,
|
||||
),
|
||||
patch("sglang.srt.layers.attention.dsa.utils.is_hip") as mock_is_hip,
|
||||
patch("sglang.srt.layers.attention.dsa.utils.is_npu") as mock_is_npu,
|
||||
patch("sglang.srt.layers.attention.dsa.utils.is_musa") as mock_is_musa,
|
||||
):
|
||||
self.assertFalse(is_dsa_enable_prefill_cp())
|
||||
|
||||
mock_is_hip.assert_not_called()
|
||||
mock_is_npu.assert_not_called()
|
||||
mock_is_musa.assert_not_called()
|
||||
|
||||
|
||||
class TestPrefillCPBCGReplay(CustomTestCase):
|
||||
def tearDown(self):
|
||||
|
||||
@@ -7,6 +7,7 @@ from sglang.srt.utils.common import (
|
||||
flatten_arrays_to_int64_tensor,
|
||||
get_device_sm_nvidia_smi,
|
||||
get_nvidia_driver_version_str,
|
||||
is_musa,
|
||||
)
|
||||
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
@@ -15,6 +16,20 @@ register_cuda_ci(est_time=10, stage="base-b", runner_config="1-gpu-small")
|
||||
register_amd_ci(est_time=5, stage="stage-b", runner_config="1-gpu-small-amd")
|
||||
|
||||
|
||||
class TestMusaDetection(CustomTestCase):
|
||||
def test_is_musa_is_torch_compile_safe(self):
|
||||
is_musa.cache_clear()
|
||||
|
||||
@torch.compile(backend="eager", fullgraph=True)
|
||||
def add_platform_offset(value):
|
||||
return value + 1 if is_musa() else value - 1
|
||||
|
||||
value = torch.zeros(1)
|
||||
actual = add_platform_offset(value)
|
||||
expected = torch.ones(1) if is_musa() else -torch.ones(1)
|
||||
torch.testing.assert_close(actual, expected)
|
||||
|
||||
|
||||
@unittest.skipUnless(torch.cuda.is_available(), "requires CUDA")
|
||||
class TestFlattenArraysToInt64Tensor(CustomTestCase):
|
||||
"""`flatten_arrays_to_int64_tensor` is invoked by `prepare_for_extend`
|
||||
|
||||
Reference in New Issue
Block a user