Repository navigation
Fix fused_qk_rope_concat_and_cache_mla for DCP - #4342
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
|
LGTM |
|
General decode kernel not covered. fuse_qk_rope_concat_and_cache_mla_kernel_general_kernel still has a hard if (slot_idx < 0) return;. If compute_all_q_rope=true is passed but dispatch falls into this path (kv_lora_rank != 512 or pe_dim != 64), the flag is silently ignored. Suggest either threading the param through, or adding a host-side guard: |
Done by adding a host-side guard. |
Motivation
Both decode variants (
..._per_head_kernel_impl,..._kernel_opt) start withif (slot_idx < 0) return;, which also skips Q RoPE +q_out. Under DCP a non-owned token hasslot_mapping = -1but its query still needs RoPE (every rank attends all queries after the head all-gather) →q_outuninitialized → wrong accuracy. But making Q RoPE unconditional would regress non-DCP: cudagraph-padded tokens (slot = -1) would pointlessly compute Q RoPE +q_outinstead of early-returning.Fix
Add
compute_all_q_ropeas the last param (defaultfalse), threaded through impl → wrapper → CALL macros → host → pybind → Python stub:false(default, non-DCP):if (!compute_all_q_rope && slot_idx < 0) return;— original early-return kept → no non-DCP regression; callers need no change (stub default +bound.apply_defaults()).true(DCP): compute Q RoPE +q_outunconditionally; guard only KV-cache writes withslot_idx >= 0.max_position+clamp(pos)(padded tokens may carry stale positions).slot_idx >= 0path byte-identical; only per_head + opt decode variants change (prefill untouched).Test
Submission Checklist