From 367e3700cfb6a0b03b2fa41a4524febf18ec1f15 Mon Sep 17 00:00:00 2001 From: inkcherry Date: Tue, 22 Sep 2026 16:20:49 +0800 Subject: [PATCH] avoid host sync in DSpark prefill slot expansion (#40111) --- .../speculative/dspark_components/dspark_worker_v2.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py b/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py index 70444fa686..f359a900e5 100644 --- a/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py +++ b/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py @@ -640,11 +640,16 @@ class DSparkWorkerV2(BaseSpecWorker): state_slot = final_pos = None if is_unified_kv_triton(): repeats = ctx_lens.to(torch.int64) + num_tokens = sum(batch.extend_lens) state_slot = torch.repeat_interleave( - batch.req_pool_indices.to(device=device, dtype=torch.int64), repeats + batch.req_pool_indices.to(device=device, dtype=torch.int64), + repeats, + output_size=num_tokens, ) final_pos = torch.repeat_interleave( - (draft_seq_lens + ctx_lens - 1).to(torch.int64), repeats + (draft_seq_lens + ctx_lens - 1).to(torch.int64), + repeats, + output_size=num_tokens, ) cache_loc = batch.out_cache_loc token_indices = logits_output.hidden_states_token_indices