[DSA] Stop forcing the per-step CPU seq_lens sync for the k-pool indexer (#41987)

Co-authored-by: Mohammad Angkad <mohammad.angkad@radixark.ai>
This commit is contained in:
Mohammad Miadh Angkad
2026-10-01 00:16:28 -07:00
committed by GitHub
co-authored by Mohammad Angkad
parent 3ed6367d3f
commit 42f2e4fcb7
3 changed files with 6 additions and 4 deletions
@@ -1693,9 +1693,10 @@ class IndexerKPool(MultiPlatformOp):
if metadata is None:
return None
assert forward_batch.seq_lens_cpu is not None
# Spec-v2 decode/verify batches may carry no CPU seq_lens mirror (the
# backend opts out of the D2H); test emptiness on the device shape.
mode = forward_batch.forward_mode
if mode.is_idle() or len(forward_batch.seq_lens_cpu) == 0:
if mode.is_idle() or forward_batch.seq_lens.shape[0] == 0:
return torch.full(
(x.shape[0], self.index_topk + self.index_kpool - 1),
-1,
@@ -349,7 +349,8 @@ class DeepseekSparseAttnBackend(
extend_dummy_seqs_capped_by_req_pool: bool = True
# Decode/verify/draft graph replay rebuilds metadata from static buffers
# (page-table width) and never reads seq_lens_cpu / seq_lens_sum; opt out of
# the D2H sync. The eager fallback derives lengths from GPU seq_lens.
# the D2H sync. The eager fallback derives lengths from GPU seq_lens, and the
# KPool indexer reads the host mirror only for extend, which always has it.
needs_cpu_seq_lens: bool = False
# init_cuda_graph_state sizes this for every backend, but only the TRT-LLM
# branch of __init__ allocates one.
@@ -380,7 +381,6 @@ class DeepseekSparseAttnBackend(
)
self.dsa_index_topk = get_dsa_index_topk(hf_config)
self.dsa_index_kpool = get_dsa_index_kpool(hf_config)
self.needs_cpu_seq_lens = self.dsa_index_kpool > 1
self._init_kpool_metadata_fusion()
self.max_context_len = model_runner.model_config.context_len
self._memory_saver_adapter = TorchMemorySaverAdapter.create(