feat: support decode context parallelism for PyTorch MLA - #4952
Draft
CUHKSZzxy wants to merge 19 commits into
Draft
feat: support decode context parallelism for PyTorch MLA#4952CUHKSZzxy wants to merge 19 commits into
CUHKSZzxy wants to merge 19 commits into
Conversation
Count speculative verification rows in DCP top-k workspace estimates and clarify the reserved buffer scope. Extend cached-prefill numerical coverage to DCP2/DCP4 and BF16/FP8 caches. Validation: 53 executor/DCP CPU tests and 14 DCP attention tests passed on one H200 GPU. Ruff and git diff --check passed.
Preserve DCP cache ownership and metadata alongside upstream piecewise CUDA graph entry points. Retain both DCP and TileLang numerical coverage, reject the unsupported TileLang attention plus DCP combination, and remove the requested MTP loader test. Validation: 233 CPU tests passed (16 skipped); all 40 MLA/indexer tests passed on one H200 GPU.
Fuse rank-local index filtering and ordered compaction, avoid packing contiguous queries before all-gather, and clarify DCP helper names. Remove full-score NaN sanitation while preserving index masks and empty-shard attention handling. Widen candidate score addressing to int64 for large CUDA graph buffers and cover the affected paths with regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Reduce replicated MLA KV-cache storage within attention tensor parallelism by adding opt-in decode context parallelism (DCP) to the PyTorch backend. DCP reuses existing TP ranks instead of increasing the model world size.
Modification
--dcp/PytorchEngineConfig(dcp=...), DCP process groups, interleaved cache ownership, and scheduler accounting for logical blocks spanning multiple ranks.deepseek_mtpfor dense and sparse MLA with per-query causal lengths and CUDA-graph-compatible metadata.dcp=1remains the default. TurboMind's existing--cpoption is unchanged.Supported scope and remaining work
Validation
On the published head:
pytest tests/pytorch/engine/test_executor_base.py tests/pytorch/test_dcp.py -q: 53 passed on CPU.pytest tests/pytorch/kernel/test_mla_attention.py -k dcp -q: 14 passed on one H200 GPU. Cached-prefill tests execute real cache-writing and attention kernels against an independent reference; DCP collectives are simulated in these single-GPU tests.Earlier full-model validation during branch development used GLM-5.2-FP8, TP8/DCP4, MTP5, and CUDA graphs. GSM8K scored 1268/1319 (96.1334%) with prefix caching off and 1266/1319 (95.9818%) with it enabled. The prefix-enabled dataset run had zero cache hits, so these scores do not validate reused-prefix correctness. Separate full-model replay controls exercised actual cache hits and exposed the parity caveat above. These were single runs, not a statistically established accuracy or performance comparison, and were not rerun for the final accounting-only change.
The full downstream dependency-version matrix has not been validated.
Assistance
Assisted with Codex + GPT-6-Astra High, reviewed manually