Skip to content

feat: extend DCP to GQA and optimize query communication - #4995

Open
CUHKSZzxy wants to merge 17 commits into
InternLM:mainfrom
CUHKSZzxy:feat/dcp-optimizations
Open

CUHKSZzxy wants to merge 17 commits into
InternLM:mainfrom
CUHKSZzxy:feat/dcp-optimizations

Conversation

@CUHKSZzxy

@CUHKSZzxy CUHKSZzxy commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Depends on #4952. Merge that PR first. This extends its MLA DCP support to GQA models with replicated KV heads and adds opt-in optimized communication paths. The diff against main includes #4952 until it is merged.

Modification

  • Add GQA DCP prefill/decode with bounded cached-prefix gathering and shared DCP components.
  • Support unquantized and per-tensor FP8 KV cache, including sharded FP8 cache fill.
  • Propagate the allocated draft cache’s quantization policy into MTP attention to fix FP8 warmup failure.
  • Centralize DCP workspace and collective ownership.
  • Add opt-in optimized communication with --communication-backend auto, using symmetric-memory all-gather for query, LSE, top-k candidate, and cached-prefix payloads when eligible.
  • Preserve a process-group fallback when symmetric-memory communication is unavailable or unsupported.
  • Skip redundant query-gather entry synchronization.
  • Simplify CUDA communicator routing and remove the unused FlashInfer all-reduce provider.
  • Share KV workspace sizing and document supported layouts and restrictions.

Accuracy

Full GSM8K test split, zero-shot, thinking disabled, temperature 0, seed 20260921, output limit 2,048 tokens, concurrency 16. Both runs used FP8 KV and prefix caching on H200 GPUs.

Model Configuration Correct / total Accuracy Request / parser errors Truncated
Qwen3-235B-A22B TP8+DCP2 1253/1319 95.00% 0 / 0 1
Qwen3.5-397B-A17B-FP8 TP4+DCP2, MTP2, batch limit 128 1276/1319 96.74% 0 / 0 10

Both mini checks passed 8/8. Qwen3.5 MTP acceptance was 92.71%. Unspecified engine settings used CLI defaults. These are single runs without a TP-only baseline. Prefix caching was enabled, but no cache hits were observed. The optimized communication paths were not enabled in these accuracy runs.

Checklist

  • Pre-commit checks passed for the final head.
  • Focused speculative-decoding tests: 24 passed, one CUDA-only test skipped.
  • Focused communicator and MLA attention tests: 30 passed, 28 skipped.
  • Context-parallel documentation updated.

Assistance

Assisted with Codex + GPT-6-Astra High; reviewed manually.

@CUHKSZzxy
CUHKSZzxy force-pushed the feat/dcp-optimizations branch from 3ff3ca0 to 24ab1c7 Compare October 9, 2026 09:19
@CUHKSZzxy
CUHKSZzxy marked this pull request as ready for review October 12, 2026 09:11
Copilot AI balanced review requested due to automatic review settings October 12, 2026 09:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

GQA DCP currently permits configurations whose ALiBi or block-sparse semantics are silently discarded.

3 open findings
What changed in this PR

Extends PyTorch DCP from MLA to replicated-KV GQA models and introduces opt-in optimized CUDA communication.

Changes:

  • Adds GQA DCP prefill/decode with FP8 KV-cache support.
  • Centralizes DCP collectives and symmetric-memory workspaces.
  • Adds --communication-backend auto with native fallback.
File Description
tests/​pytorch/​test_cuda_communicator.py Expands communicator and workspace tests.
tests/​pytorch/​spec_decode/​test_spec_agent.py Tests backend propagation to draft contexts.
tests/​pytorch/​kernel/​test_mla_attention.py Updates shared DCP manager tests.
tests/​pytorch/​kernel/​test_fill_kv_cache.py Tests sharded FP8 cache filling.
tests/​pytorch/​engine/​test_executor_base.py Updates DCP workspace fixture.
lmdeploy/​pytorch/​third_party/​flash_attn_interface.py Normalizes optional FA3 LSE returns.
lmdeploy/​pytorch/​spec_decode/​proposers/​base.py Propagates draft-cache quantization policy.
lmdeploy/​pytorch/​spec_decode/​base.py Propagates communication backend.
lmdeploy/​pytorch/​nn/​norm.py Removes deferred fused all-reduce handling.
lmdeploy/​pytorch/​nn/​linear/​base.py Routes reductions through the wrapper.
lmdeploy/​pytorch/​nn/​embedding.py Uses communicator-managed logits gathering.
lmdeploy/​pytorch/​models/​deepseek_v32.py Removes deferred reduction configuration.
lmdeploy/​pytorch/​kernels/​cuda/​symm_mem_allgather.py Generalizes symmetric all-gather dimensions.
lmdeploy/​pytorch/​kernels/​cuda/​pagedattention.py Adds natural-log LSE output.
lmdeploy/​pytorch/​kernels/​cuda/​fill_kv_cache.py Adds sharded FP8 cache writes.
lmdeploy/​pytorch/​kernels/​cuda/​dcp.py Vectorizes prefix reordering.
lmdeploy/​pytorch/​envs.py Removes legacy communicator environment flags.
lmdeploy/​pytorch/​engine/​executor/​ray_executor.py Updates symmetric-memory device setup.
lmdeploy/​pytorch/​engine/​executor/​base.py Accounts for GQA KV width.
lmdeploy/​pytorch/​engine/​executor/​__init__.py Validates GQA DCP quantization.
lmdeploy/​pytorch/​distributed.py Centralizes communicator and DCP ownership.
lmdeploy/​pytorch/​config.py Adds backend configuration and GQA validation.
lmdeploy/​pytorch/​backends/​dlinfer/​op_backend.py Removes obsolete CUDA-option handling.
lmdeploy/​pytorch/​backends/​default/​linear.py Uses optimized reduction routing.
lmdeploy/​pytorch/​backends/​default/​embedding.py Uses optimized reduction routing.
lmdeploy/​pytorch/​backends/​cuda/​op_backend.py Propagates communicator group names.
lmdeploy/​pytorch/​backends/​cuda/​nsa.py Uses shared candidate gathering.
lmdeploy/​pytorch/​backends/​cuda/​comm/​symm_mem_allreduce.py Revises provider preparation and fallback.
lmdeploy/​pytorch/​backends/​cuda/​comm/​symm_mem_allgather.py Generalizes reusable gather workspaces.
lmdeploy/​pytorch/​backends/​cuda/​comm/​flashinfer_allreduce.py Removes the FlashInfer provider.
lmdeploy/​pytorch/​backends/​cuda/​comm/​communicator.py Implements automatic collective selection.
lmdeploy/​pytorch/​backends/​cuda/​attention/​sparse_mla.py Uses shared DCP collectives.
lmdeploy/​pytorch/​backends/​cuda/​attention/​mla.py Uses centralized DCP workspaces.
lmdeploy/​pytorch/​backends/​cuda/​attention/​cp.py Adds GQA DCP attention.
lmdeploy/​pytorch/​backends/​cuda/​attention/​__init__.py Selects GQA DCP implementation.
lmdeploy/​pytorch/​backends/​cp_utils.py Shares KV-width-based workspace planning.
lmdeploy/​pytorch/​backends/​communicator.py Adds generic all-gather APIs.
lmdeploy/​pytorch/​backends/​base.py Extends communicator construction.
lmdeploy/​messages.py Exposes communication backend configuration.
lmdeploy/​cli/​utils.py Defines the backend CLI option.
lmdeploy/​cli/​serve.py Wires the option into API serving.
lmdeploy/​cli/​cli.py Wires the option into interactive chat.
docs/​en/​advance/​context_parallel.md Documents GQA DCP support and restrictions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lmdeploy/pytorch/backends/cuda/attention/__init__.py
Comment thread lmdeploy/pytorch/backends/cuda/attention/cp.py
Comment thread lmdeploy/pytorch/backends/cuda/attention/cp.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants