[Spec decode] Support Kimi-K3 DCP with DSpark (#52188)

Signed-off-by: wzhao18 <wzhao18.sz@gmail.com>
This commit is contained in:
Wei Zhao
2026-08-17 13:08:45 -07:00
committed by GitHub
parent 9633933dd8
commit d1e3eee6fb
15 changed files with 341 additions and 51 deletions
+21
View File
@@ -59,3 +59,24 @@ def _dcp_local_seq_lens_kernel(
# For [num_reqs, max_num_reqs), pad with 0
local_seq_lens = tl.where(block < num_reqs, local_seq_lens, 0)
tl.store(out_ptr + block, local_seq_lens, mask=block < max_num_reqs)
@triton.jit
def cp_local_slot(
positions,
block_numbers,
block_size,
cp_rank,
CP_SIZE: tl.constexpr,
CP_INTERLEAVE: tl.constexpr,
PAD_ID: tl.constexpr,
):
"""Return rank-local KV slots, or PAD_ID for positions not owned by this rank."""
block_offsets = positions % (block_size * CP_SIZE)
if CP_SIZE == 1:
return block_numbers * block_size + block_offsets
is_local = block_offsets // CP_INTERLEAVE % CP_SIZE == cp_rank
rounds = block_offsets // (CP_INTERLEAVE * CP_SIZE)
remainder = block_offsets % CP_INTERLEAVE
local_offsets = rounds * CP_INTERLEAVE + remainder
return tl.where(is_local, block_numbers * block_size + local_offsets, PAD_ID)