From 30bdd09aed25b2f9d2b314de83a725008e38dd62 Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Wed, 14 Oct 2026 10:40:24 +0530 Subject: [PATCH] DSPARK enable for XPU (#33739) --- docs/docs/hardware-platforms/xpu.mdx | 2 +- .../attention/dsv4_attn_metadata_kernels.py | 4 +- .../sglang/srt/arg_groups/speculative_hook.py | 4 +- .../srt/layers/attention/xpu_backend.py | 25 ++-- python/sglang/srt/managers/schedule_batch.py | 4 +- python/sglang/srt/models/dspark.py | 5 +- .../dspark_block_accept_estimator.py | 6 +- .../dspark_components/dspark_observability.py | 9 +- python/sglang/srt/utils/common.py | 10 +- python/sglang/srt/utils/device_timer.py | 10 +- .../test/kits/basic_decode_correctness_kit.py | 3 + .../core/test_basic_sanity_dspark.py | 53 +++++-- .../e2e/xpu/test_dspark_intel_xpu.py | 134 ++++++++++++++++++ .../spec/dspark/test_dspark_kernel_parity.py | 4 +- .../test_dspark_stacked_ctx_kv_parity.py | 5 +- 15 files changed, 234 insertions(+), 44 deletions(-) create mode 100644 test/registered/e2e/xpu/test_dspark_intel_xpu.py diff --git a/docs/docs/hardware-platforms/xpu.mdx b/docs/docs/hardware-platforms/xpu.mdx index 831cb6cf61..8a208eac01 100644 --- a/docs/docs/hardware-platforms/xpu.mdx +++ b/docs/docs/hardware-platforms/xpu.mdx @@ -283,7 +283,7 @@ via `--cuda-graph-backend-prefill` or `--cuda-graph-config`. | Feature | Status | |---|---| | Two-batch overlap (`--enable-two-batch-overlap`) | Not yet supported | -| Speculative decoding | Not yet implemented | +| Speculative decoding | Supported | ## Decode Context Parallel (DCP) on Intel XPU [Experimental] diff --git a/python/sglang/kernels/ops/attention/dsv4_attn_metadata_kernels.py b/python/sglang/kernels/ops/attention/dsv4_attn_metadata_kernels.py index b34b98eca2..8989cd72cf 100644 --- a/python/sglang/kernels/ops/attention/dsv4_attn_metadata_kernels.py +++ b/python/sglang/kernels/ops/attention/dsv4_attn_metadata_kernels.py @@ -183,7 +183,9 @@ def _expand_prefill_causally_kernel( seq_len = tl.load(seq_lens_ptr + r, mask=mask, other=0).to(tl.int32) ext = tl.load(extend_seq_lens_ptr + r, mask=mask, other=0).to(tl.int32) - start_loc = tl.sum(tl.where(started, extend[None, :], 0).to(tl.int32), axis=1) - ext + # start_loc == start_locs[r]. `started` selects the contiguous prefix b <= r + # and start_locs is monotonic, so max-reduce over the selected cumsum yields start_locs[r]. + start_loc = tl.max(tl.where(started, start_locs[None, :], -1), axis=1) causal = (seq_len - ext + 1) + (t - start_loc) causal = tl.where(is_real, causal, 1) diff --git a/python/sglang/srt/arg_groups/speculative_hook.py b/python/sglang/srt/arg_groups/speculative_hook.py index 9c856e57fc..3b78d2f969 100644 --- a/python/sglang/srt/arg_groups/speculative_hook.py +++ b/python/sglang/srt/arg_groups/speculative_hook.py @@ -605,9 +605,9 @@ def _target_checkpoint_bundles_dspark_draft(server_args: ServerArgs) -> bool: def _handle_dspark(server_args: ServerArgs) -> None: cfg = resolving_view(server_args) _is_npu = cfg.device.startswith("npu") - if not cfg.device.startswith(("cuda", "npu")): + if not cfg.device.startswith(("cuda", "npu", "xpu")): raise ValueError( - "DSpark speculative decoding only supports CUDA or NPU device." + "DSpark speculative decoding only supports CUDA, NPU or XPU device." ) if cfg.attn_dp_size > 1: diff --git a/python/sglang/srt/layers/attention/xpu_backend.py b/python/sglang/srt/layers/attention/xpu_backend.py index 88ce2fcf54..c4c99ff554 100644 --- a/python/sglang/srt/layers/attention/xpu_backend.py +++ b/python/sglang/srt/layers/attention/xpu_backend.py @@ -426,18 +426,23 @@ class XPUAttentionBackend(AttentionBackend): self._init_local_attn_metadata(forward_batch, metadata, device) elif forward_batch.forward_mode.is_target_verify(): if self.topk <= 1: + # The DSpark draft block forward reuses TARGET_VERIFY but feeds + # spec_info.num_tokens_per_req queries/req (gamma), which differs + # from the global speculative_num_draft_tokens used by the target + # verify. Segment queries/keys by the per-request width the + # spec_info carries, not the global (mirrors the triton backend). + num_tokens_per_req = forward_batch.spec_info.num_tokens_per_req metadata.cache_seqlens_int32 = ( - forward_batch.seq_lens + self.speculative_num_draft_tokens + forward_batch.seq_lens + num_tokens_per_req ).to(torch.int32) - metadata.max_seq_len_q = self.speculative_num_draft_tokens + metadata.max_seq_len_q = num_tokens_per_req metadata.max_seq_len_k = ( - forward_batch.seq_lens_cpu.max().item() - + self.speculative_num_draft_tokens + forward_batch.seq_lens_cpu.max().item() + num_tokens_per_req ) metadata.cu_seqlens_q = torch.arange( 0, - batch_size * self.speculative_num_draft_tokens + 1, - self.speculative_num_draft_tokens, + batch_size * num_tokens_per_req + 1, + num_tokens_per_req, dtype=torch.int32, device=device, ) @@ -1583,9 +1588,11 @@ class XPUAttentionBackend(AttentionBackend): past ``seq_lens`` for each spec mode. """ if is_verify: - # Packs speculative_num_draft_tokens rows, attending past seq_lens - # over those draft positions. - return self.speculative_num_draft_tokens, self.speculative_num_draft_tokens + # DSpark's draft block reuses TARGET_VERIFY but packs + # spec_info.num_tokens_per_req rows/req (gamma), not the gamma+1 the + # real target verify packs; segment by the width spec_info carries so + # the graph path matches the eager verify branch (mirrors triton). + return spec_info.num_tokens_per_req, spec_info.num_tokens_per_req if is_draft_extend: # seq_lens already includes the extend tokens (standard extend # convention), so no KV offset is needed. diff --git a/python/sglang/srt/managers/schedule_batch.py b/python/sglang/srt/managers/schedule_batch.py index 6bc0dbf6a4..e100386662 100755 --- a/python/sglang/srt/managers/schedule_batch.py +++ b/python/sglang/srt/managers/schedule_batch.py @@ -2920,8 +2920,10 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin): ) if self.return_logprob: + # Pin so the non_blocking H2D copy in ForwardBatch.init_new is stream-ordered extend_input_logprob_token_ids = torch.tensor( - extend_input_logprob_token_ids + extend_input_logprob_token_ids, + pin_memory=is_pin_memory_available(self.device), ) # Clamp placeholder or out-of-range token IDs (e.g., multimodal hashes) # so they stay within the vocab boundary before being sent to GPU. diff --git a/python/sglang/srt/models/dspark.py b/python/sglang/srt/models/dspark.py index 91f17f9bed..81ceb973ab 100644 --- a/python/sglang/srt/models/dspark.py +++ b/python/sglang/srt/models/dspark.py @@ -9,6 +9,7 @@ import torch import torch.nn.functional as F from torch import nn +from sglang.kernels.ops.memory.ptr_table import make_ptr_table from sglang.srt.distributed.communication_op import tensor_model_parallel_all_gather from sglang.srt.environ import envs from sglang.srt.layers.linear import ReplicatedLinear @@ -598,7 +599,9 @@ class DSparkDraftMixin: device = weights[0].device w_all = torch.cat(weights, dim=0).contiguous() knw = torch.stack(knws).to(device) - meta = torch.tensor(meta_rows, dtype=torch.int64, device=device) + # k_buf/v_buf data_ptr() can set the top bit on XPU (USM addresses), + # which dtype=torch.int64 rejects while unpacking; pack unsigned and view. + meta = make_ptr_table(meta_rows, device=device) cos_sin = rotary.cos_sin_cache.to(device) return (w_all, meta, knw, cos_sin, eps, len(layers), kv_size, head_dim) diff --git a/python/sglang/srt/speculative/dspark_components/dspark_block_accept_estimator.py b/python/sglang/srt/speculative/dspark_components/dspark_block_accept_estimator.py index 831c21ed44..f3e00c6c55 100644 --- a/python/sglang/srt/speculative/dspark_components/dspark_block_accept_estimator.py +++ b/python/sglang/srt/speculative/dspark_components/dspark_block_accept_estimator.py @@ -13,6 +13,7 @@ import torch from sglang.srt.environ import envs from sglang.srt.kv_canary.runner.future_tensor import DelayedDeviceHostHandler from sglang.srt.speculative.ragged_verify import RaggedVerifyLayout +from sglang.srt.utils.common import is_pin_memory_available logger = logging.getLogger(__name__) @@ -762,7 +763,10 @@ class BlockAcceptEstimateRecorder: def _host_to_device_async( self, values: List[int], *, device: torch.device ) -> torch.Tensor: - host = torch.tensor(values, dtype=torch.long, pin_memory=device.type == "cuda") + # Pin so the non_blocking H2D is stream-ordered + host = torch.tensor( + values, dtype=torch.long, pin_memory=is_pin_memory_available(device) + ) self._retained_h2d.append(host) return host.to(device=device, non_blocking=True) diff --git a/python/sglang/srt/speculative/dspark_components/dspark_observability.py b/python/sglang/srt/speculative/dspark_components/dspark_observability.py index ed961b1315..ce3395ee61 100644 --- a/python/sglang/srt/speculative/dspark_components/dspark_observability.py +++ b/python/sglang/srt/speculative/dspark_components/dspark_observability.py @@ -193,9 +193,10 @@ class DsparkInfoDumper: self._pending: Optional[_PendingStep] = None self._prev_stamp: Optional[float] = None - self._d2h_stream: Optional[torch.cuda.Stream] = None + self._device_module = torch.get_device_module(device) + self._d2h_stream = None if self.enabled and InfoComponent.REQS in self._components: - self._d2h_stream = torch.cuda.Stream(device=device) + self._d2h_stream = self._device_module.Stream(device=device) self._current_segments: dict[ InfoSegment, tuple[torch.cuda.Event, torch.cuda.Event] @@ -303,7 +304,7 @@ class DsparkInfoDumper: return False def _open_segment(self, segment: InfoSegment) -> None: - start = torch.cuda.Event(enable_timing=True) + start = self._device_module.Event(enable_timing=True) start.record() self._open_segments[segment] = start @@ -311,7 +312,7 @@ class DsparkInfoDumper: start = self._open_segments.pop(segment, None) if start is None: return - end = torch.cuda.Event(enable_timing=True) + end = self._device_module.Event(enable_timing=True) end.record() self._current_segments[segment] = (start, end) diff --git a/python/sglang/srt/utils/common.py b/python/sglang/srt/utils/common.py index c97fd10787..6202fd7019 100644 --- a/python/sglang/srt/utils/common.py +++ b/python/sglang/srt/utils/common.py @@ -593,12 +593,14 @@ def async_h2d(args: List, *, dtype: torch.dtype, device: torch.device) -> torch. def async_d2h(tensor: torch.Tensor) -> torch.Tensor: - """Enqueue a CUDA-to-pinned-host copy on the current stream.""" - if not tensor.is_cuda: - return tensor.to("cpu", non_blocking=True) + """Enqueue an accelerator-to-pinned-host copy on the current stream.""" + if tensor.device.type == "cpu": + return tensor + if not is_pin_memory_available(tensor.device): + return tensor.to("cpu") host = torch.empty(tensor.shape, dtype=tensor.dtype, pin_memory=True) host.copy_(tensor, non_blocking=True) - tensor.record_stream(torch.cuda.current_stream(tensor.device)) + tensor.record_stream(torch.get_device_module(tensor.device).current_stream()) return host diff --git a/python/sglang/srt/utils/device_timer.py b/python/sglang/srt/utils/device_timer.py index aa035bfbcf..104a5e405f 100644 --- a/python/sglang/srt/utils/device_timer.py +++ b/python/sglang/srt/utils/device_timer.py @@ -95,8 +95,8 @@ class GapTimer(DeviceTimer): @dataclass class _TimingInterval: - start_event: torch.cuda.Event - end_event: Optional[torch.cuda.Event] = None + start_event: torch.Event + end_event: Optional[torch.Event] = None metadata: Optional[Dict] = None _started: bool = False _completed: bool = False @@ -117,12 +117,14 @@ class _TimingInterval: @staticmethod def create(): - start_event = torch.cuda.Event(enable_timing=True) + device_module = torch.get_device_module() + start_event = device_module.Event(enable_timing=True) start_event.record() return _TimingInterval(start_event=start_event) def end(self, metadata: Dict): - end_event = torch.cuda.Event(enable_timing=True) + device_module = torch.get_device_module() + end_event = device_module.Event(enable_timing=True) end_event.record() assert self.end_event is None diff --git a/python/sglang/test/kits/basic_decode_correctness_kit.py b/python/sglang/test/kits/basic_decode_correctness_kit.py index 29b94893fa..e1dfc456d2 100644 --- a/python/sglang/test/kits/basic_decode_correctness_kit.py +++ b/python/sglang/test/kits/basic_decode_correctness_kit.py @@ -40,7 +40,10 @@ class BasicDecodeCorrectnessMixin: self.assertIn("paris", out.lower()) def test_basic_math(self): + # Qwen3 greedy is a near-tie between narrating and answering at the first + # token; a one-shot exemplar makes the bare answer the clear greedy choice. out = self._decode_generate( + "Q: What is 12 multiplied by 12? Reply with just the number.\nA: 144\n" "Q: What is 17 multiplied by 23? Reply with just the number.\nA:", self.sanity_max_new_tokens_short, ) diff --git a/test/registered/core/test_basic_sanity_dspark.py b/test/registered/core/test_basic_sanity_dspark.py index 583f8de8d1..86d9ce116d 100644 --- a/test/registered/core/test_basic_sanity_dspark.py +++ b/test/registered/core/test_basic_sanity_dspark.py @@ -1,6 +1,6 @@ import unittest -from sglang.srt.utils import is_sm100_supported, kill_process_tree +from sglang.srt.utils import is_sm100_supported, is_xpu, kill_process_tree from sglang.test.ci.ci_register import register_cuda_ci from sglang.test.kits.basic_api_contract_kit import BasicAPIContractMixin from sglang.test.kits.basic_decode_correctness_kit import BasicDecodeCorrectnessMixin @@ -27,14 +27,14 @@ DRAFT_MODEL = "deepseek-ai/dspark_qwen3_14b_block7" # trtllm_mha prefill requires SM100 (Blackwell); use the Hopper-native pair elsewhere. if is_sm100_supported(): - ATTENTION_BACKEND = "trtllm_mha" - DRAFT_ATTENTION_BACKEND = "fa4" + CUDA_ATTENTION_BACKEND = "trtllm_mha" + CUDA_DRAFT_ATTENTION_BACKEND = "fa4" else: - ATTENTION_BACKEND = "fa3" - DRAFT_ATTENTION_BACKEND = "fa3" + CUDA_ATTENTION_BACKEND = "fa3" + CUDA_DRAFT_ATTENTION_BACKEND = "fa3" -class TestBasicSanityDSpark( +class _DSparkSanityMixin( BasicAPIContractMixin, BasicDecodeCorrectnessMixin, BasicSchedulerStressMixin, @@ -44,8 +44,12 @@ class TestBasicSanityDSpark( SpecGrammarKit, SpecLogprobKit, SpecSamplingMaskKit, - CustomTestCase, ): + """DSpark sanity coverage shared by every backend pairing. Concrete + subclasses add CustomTestCase, set the (attention_backend, + draft_attention_backend) pair, and any per-backend launch overrides. + Not a TestCase itself, so it is never collected on its own.""" + served_model_name = TARGET_MODEL model = TARGET_MODEL @@ -56,8 +60,18 @@ class TestBasicSanityDSpark( mmlu_score_threshold = 0.70 mmlu_accept_length_thres = 3.0 - attention_backend = ATTENTION_BACKEND - draft_attention_backend = DRAFT_ATTENTION_BACKEND + # Set per concrete subclass. + attention_backend: str = None + draft_attention_backend: str = None + page_size: str = "1" + mem_fraction_static: str = "0.7" + # None leaves the scheduler uncapped; XPU classes cap it (see below). + max_running_requests: str = None + # None keeps the server default (4096). return_logprob over a long prompt + # materializes a [chunk_tokens, vocab] logits tensor; XPU classes shrink the + # chunk so that transient fits the 24GB B60 (see below). + chunked_prefill_size: str = None + extra_launch_args: list = [] process = None @@ -81,11 +95,22 @@ class TestBasicSanityDSpark( "--cuda-graph-max-bs-decode", "4", "--mem-fraction-static", - "0.7", + cls.mem_fraction_static, "--page-size", - "1", + cls.page_size, "--enable-metrics", "--cuda-graph-backend-prefill=disabled", + *( + ["--max-running-requests", cls.max_running_requests] + if cls.max_running_requests is not None + else [] + ), + *( + ["--chunked-prefill-size", cls.chunked_prefill_size] + if cls.chunked_prefill_size is not None + else [] + ), + *cls.extra_launch_args, ], env={ "SGLANG_ENABLE_METRICS_DEVICE_TIMER": "1", @@ -99,5 +124,11 @@ class TestBasicSanityDSpark( kill_process_tree(cls.process.pid) +@unittest.skipIf(is_xpu(), "CUDA/AMD backend pairing; XPU is covered separately") +class TestBasicSanityDSpark(_DSparkSanityMixin, CustomTestCase): + attention_backend = CUDA_ATTENTION_BACKEND + draft_attention_backend = CUDA_DRAFT_ATTENTION_BACKEND + + if __name__ == "__main__": unittest.main() diff --git a/test/registered/e2e/xpu/test_dspark_intel_xpu.py b/test/registered/e2e/xpu/test_dspark_intel_xpu.py new file mode 100644 index 0000000000..6c84bc1784 --- /dev/null +++ b/test/registered/e2e/xpu/test_dspark_intel_xpu.py @@ -0,0 +1,134 @@ +"""DSPARK speculative decoding on Intel XPU.""" + +import os +import sys +import unittest + +from sglang.srt.utils import is_xpu, kill_process_tree + +# Put the `test/` root on sys.path so `registered.<...>` resolves regardless of +# cwd: CI runs each file as `python3 ` (only the file's own dir is on +# the path), and pytest inserts only the file's dir too. `test/` is three levels +# up from this file's dir (test/registered/e2e/xpu/). +_TEST_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) +if _TEST_ROOT not in sys.path: + sys.path.insert(0, _TEST_ROOT) + +# Reference the shared mixin as a module attribute rather than importing the +# Test* names: pytest collects by class __name__, so importing the base module's +# CUDA TestBasicSanityDSpark here would re-collect it under the XPU file. Only the +# XPU subclasses below should run. +from registered.core import test_basic_sanity_dspark as _dspark_base + +from sglang.test.ci.ci_register import register_xpu_ci +from sglang.test.kits.spec_server_kits import SpecLogprobKit +from sglang.test.test_utils import ( + DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, + DEFAULT_URL_FOR_TEST, + CustomTestCase, + popen_launch_server, +) + +register_xpu_ci(est_time=3000, suite="nightly-xpu-kernel-main-2-gpu", nightly=True) + + +@unittest.skipUnless(is_xpu(), "Intel XPU required") +class TestBasicSanityDSparkXpuTriton(_dspark_base._DSparkSanityMixin, CustomTestCase): + attention_backend = "triton" + draft_attention_backend = "triton" + max_running_requests = "2" + mem_fraction_static = "0.75" + chunked_prefill_size = "1024" + extra_launch_args = ["--tp", "2", "--dtype", "bfloat16", "--base-gpu-id", "1"] + + +@unittest.skipUnless(is_xpu(), "Intel XPU required") +class TestBasicSanityDSparkXpuIntelXpu(_dspark_base._DSparkSanityMixin, CustomTestCase): + attention_backend = "intel_xpu" + draft_attention_backend = "intel_xpu" + page_size = "128" + mem_fraction_static = "0.85" + max_running_requests = "2" + chunked_prefill_size = "512" + extra_launch_args = ["--tp", "2", "--dtype", "bfloat16", "--base-gpu-id", "1"] + + def test_logprob_decode_match_prefill(self): + # intel_xpu bf16 matmul is not batch-invariant, so the decode (verify, + # M-rows) and prefill-rescore (full-length) paths drift in the deep logit + # tail here (sampled / top-k tokens still match). Skipped on production + # numerics; run under --enable-deterministic-inference to assert equality. + self.skipTest("intel_xpu decode-vs-prefill deep-tail drift is batch-variance") + + +@unittest.skipUnless(is_xpu(), "Intel XPU required") +class TestBasicSanityDSparkXpuIntelXpuDecodeGraph(TestBasicSanityDSparkXpuIntelXpu): + extra_launch_args = TestBasicSanityDSparkXpuIntelXpu.extra_launch_args + [ + "--cuda-graph-backend-decode", + "full", + ] + + +@unittest.skipUnless(is_xpu(), "Intel XPU required") +class TestDSparkXpuIntelXpuLogprobDeterministic(SpecLogprobKit, CustomTestCase): + """Run only the shared logprob checks (SpecLogprobKit) on an intel_xpu DSPARK + server launched with --enable-deterministic-inference. + + intel_xpu bf16 matmul is not batch-invariant, so decode (verify) vs + prefill-rescore drift in the deep logit tail on production numerics -- which + is why test_logprob_decode_match_prefill is skipped on the production classes. + Deterministic inference pins the reductions so the two paths agree, letting the + logprob suite (including the decode-vs-prefill check) run here. + """ + + model = _dspark_base.TARGET_MODEL + process = None + + @classmethod + def setUpClass(cls): + cls.base_url = DEFAULT_URL_FOR_TEST + # Reuse the production intel_xpu launch config; add only the deterministic + # flag here so it stays scoped to this logprob-consistency class. + src = TestBasicSanityDSparkXpuIntelXpu + cls.process = popen_launch_server( + _dspark_base.TARGET_MODEL, + cls.base_url, + timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, + other_args=[ + "--trust-remote-code", + "--attention-backend", + src.attention_backend, + "--speculative-draft-attention-backend", + src.draft_attention_backend, + "--speculative-algorithm", + "DSPARK", + "--speculative-draft-model-path", + _dspark_base.DRAFT_MODEL, + "--cuda-graph-max-bs-decode", + "4", + "--mem-fraction-static", + src.mem_fraction_static, + "--page-size", + src.page_size, + "--enable-metrics", + "--cuda-graph-backend-prefill=disabled", + "--max-running-requests", + src.max_running_requests, + "--chunked-prefill-size", + src.chunked_prefill_size, + "--enable-deterministic-inference", + *src.extra_launch_args, + ], + env={ + "SGLANG_ENABLE_METRICS_DEVICE_TIMER": "1", + "SGLANG_RAGGED_VERIFY_MODE": "compact", + }, + ) + + @classmethod + def tearDownClass(cls): + if cls.process is not None: + kill_process_tree(cls.process.pid) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/registered/spec/dspark/test_dspark_kernel_parity.py b/test/registered/spec/dspark/test_dspark_kernel_parity.py index 5c2fe92057..b80b9cef2c 100644 --- a/test/registered/spec/dspark/test_dspark_kernel_parity.py +++ b/test/registered/spec/dspark/test_dspark_kernel_parity.py @@ -28,11 +28,11 @@ from sglang.srt.speculative.dspark_components.dspark_planner import ( ) from sglang.srt.speculative.ragged_verify import RaggedVerifyLayout from sglang.test.ci.ci_register import register_cuda_ci -from sglang.test.test_utils import CustomTestCase +from sglang.test.test_utils import CustomTestCase, get_device register_cuda_ci(est_time=11, stage="base-b", runner_config="1-gpu-small") -DEVICE = torch.device("cuda") +DEVICE = get_device() VOCAB = 129280 diff --git a/test/registered/spec/dspark/test_dspark_stacked_ctx_kv_parity.py b/test/registered/spec/dspark/test_dspark_stacked_ctx_kv_parity.py index c3891d027a..e3059c7f6c 100644 --- a/test/registered/spec/dspark/test_dspark_stacked_ctx_kv_parity.py +++ b/test/registered/spec/dspark/test_dspark_stacked_ctx_kv_parity.py @@ -17,11 +17,11 @@ from sglang.srt.models.dflash import DFlashAttention from sglang.srt.models.dspark import DSparkDraftMixin from sglang.srt.server_args import ServerArgs, set_global_server_args_for_scheduler from sglang.test.ci.ci_register import register_cuda_ci -from sglang.test.test_utils import CustomTestCase +from sglang.test.test_utils import CustomTestCase, get_device register_cuda_ci(est_time=14, stage="base-b", runner_config="1-gpu-small") -DEVICE = torch.device("cuda") +DEVICE = get_device() HEAD_DIM = 64 NUM_KV_HEADS = 2 NUM_Q_HEADS = 4 @@ -89,7 +89,6 @@ def _per_layer_reference(model, ctx_hidden, positions): return ks, vs -@unittest.skipUnless(torch.cuda.is_available(), "CUDA required") class TestDSparkStackedCtxKvParity(CustomTestCase): def setUp(self): super().setUp()