[feat][DCP] Optimize MLA DCP (Enable Prefix Cache / Chunked Prefill + FP8 KVCache) - #1701
Open
yitingw1 wants to merge 13 commits into
Open
[feat][DCP] Optimize MLA DCP (Enable Prefix Cache / Chunked Prefill + FP8 KVCache)#1701yitingw1 wants to merge 13 commits into
yitingw1 wants to merge 13 commits into
Conversation
Contributor
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model 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.
Expand the initial MLA DCP PR #847 with following:
1. Motivation
The base DCP PR (#847) enabled Decode Context Parallel for MLA decode only, bf16, no prefix cache.
config.pyhard-asserted DCP off whenever prefix caching, chunked prefill, or fp8 KVCache was enabled, so DCP could not be used in any realistic serving config.This PR removes those restrictions and makes DCP work end-to-end with prefix cache, chunked prefill, and fp8 KVCache, in both ATOM server and vllm-atom plugin modes. It also switches the DCP q/KV write off the slower 2-kernel workaround onto the fixed fused
fused_qk_rope_concat_and_cache_mla(see the companion aiter PR), and consolidates the DCP access boilerplate.Depends on the aiter PR ROCm/aiter#4342 "Fix fused_qk_rope_concat_and_cache_mla for DCP".
2. Usage
No new CLI flags — the existing
-dcp / --decode-context-parallel-size(from #847) now composes with prefix cache / chunked prefill / fp8 KVCache, which were previously rejected at startup.-dcp/--decode-context-parallel-sizetp_size--kv_cache_dtype {bf16,fp8}--enable-prefix-caching, chunked prefillVerify with
lm_eval --model local-completions --tasks gsm8k --num_fewshot 5 ....3. Design
3.1 What changes vs the DCP=1 / decode-only baseline
assert)block_size × dcpassert)assert)kv_b_projkv_b_projrotary_emb+concat_and_cache_mla)compute_all_q_rope=True(decode and prefill)world_size/group/rank)getattr+get_dcp_groupscatteredatom/distributed/dcp_utils.py3.2 Cached-prefix context under DCP (compressed-KV AllGather)
Under DCP the cached KV is interleaved across ranks (token
i→ ranki % dcp), so each rank holds only1/dcpof the prefix. To attend to the full prefix, each rank gathers its local compressed latent KV and AllGathers it (a copy-only collective, so fp8 payloads are safe — no fp8 arithmetic). Per cached-prefix chunk:3.3 Key design decisions
block_size × dcpglobal tokens (each rank stores itsblock_sizeinterleaved share), so block tables shrink bydcp.BlockManagerhashes / counts cached tokens at thishash_block_size = block_size × dcpgranularity; the scheduler computesnum_new_tokensagainst it. Why: prefix-cache reuse must be counted in whole virtual blocks or the interleaved slot math breaks.kv_b_proj, not the decompressed KV — minimizes cross-rank traffic and matches the vLLM plugin's chunked-context scheme.gather_and_maybe_dequant_cache(plugin); AG/RS + LSE merge run in bf16. Why: AllGather is copy-only (fp8 safe), halving wire traffic; only AllReduce would be unsafe for fp8.compute_all_q_rope. DCP passescompute_all_q_rope=Trueso the kernel RoPEs every query (all ranks need all queries after the head all-gather) while writing KV only for owned slots — replacing the 2-kernel workaround. Non-DCP passes the defaultFalse(early-return preserved → no perf regression). Integration: requires the companion aiter kernel change.dcp_utilsaccess layer.get_dcp_world_size/dcp_is_enabled/get_dcp_group/get_dcp_rank, mirroringpcp_utils.py, replacing scatteredgetattr(config, ...)+get_dcp_group().rank_in_groupin the attention / metadata-builder inits.4. Test Plan
test_concat_cache_mla.py.lm_eval --model local-completions --model_args model=/data1/models/DeepSeek-R1,base_url=… --tasks gsm8k --num_fewshot 5.5. Test Result
DeepSeek-R1, gsm8k (flexible / strict):
All within the run-to-run baseline band (bf16 ≈ 0.948–0.956, fp8 ≈ 0.955); no accuracy regression, no crashes, cudagraph capture OK, prefix-cache path hit.
Submission Checklist