Skip to content

[Feat][NVIDIA] DeepSeek-V4.1: Prefill support CP with multistream forward prepare (4/N) - #40179

Open
SYChen123 wants to merge 27 commits into
sgl-project:mainfrom
SYChen123:v4.1/cp-multistream
Open

SYChen123 wants to merge 27 commits into
sgl-project:mainfrom
SYChen123:v4.1/cp-multistream

Conversation

@SYChen123

@SYChen123 SYChen123 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Issue #39700. When using CP on deepseek v4.1, _forward_prepare_low_ratio_multi_stream will be disabled. This PR supports their compatibility.

Modifications

Developed based on #40548 and need #40548 to be merged first. The implementaion is similar with #39588.

  1. Do CP allgather in advance on the default stream. And the multistream forward prepare accepts the pre-gathered kv score as input. No CP allgather will be performed inside the multistream forward prepare.
  2. After cp materialization, store_swa_k, compressor and indexer(operations before mqa_logits computation) are overlapped in multiple streams.
  3. In BCG for DSV4.1, enable the indexer and compressor to be captured into graph.

Accuracy Tests

image

Speed Tests and Profiling

image

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #38354933523
Latest PR Test (Extra): ❌ Run #38354933180
Latest PR Test (AMD ROCm 10): ❌ Run #38354933330

BJWang-ant and others added 24 commits October 13, 2026 12:18
V4.1 consumer layers currently dequantize the same compressed KV on every attention call. Keep a separate workspace per compression ratio and reuse its compressed prefix within one forward, keyed by source layer and allocation address. Refresh on producer execution or allocation replacement, while updating SWA and top-k for every layer.

Limit reuse to CP sparse BF16 prefill with compression ratios 1 and 2. Per-forward gather recreation invalidates the keys across batches and BCG replays. Add a GPU regression covering source changes, source re-execution, ratio interleaving, new batches, and workspace growth/shrink against forced dequantization.

Validation: B200 TP4/EP4 with CP, BCG, MegaMoE and DSPARK; GPU regression passed; 16/16 long/short arithmetic outputs match baseline. Six-step traces reduce compressed dequant calls from 228 to 24. Three unchanged test.sh trials improve median output throughput by 3.20% at concurrency64 and 4.11% at96. Concurrency32 has overlapping timing ranges and a smaller median change.
@SYChen123
SYChen123 force-pushed the v4.1/cp-multistream branch from f458a0d to e44e29a Compare October 13, 2026 06:06
@SYChen123 SYChen123 changed the title [DSV4.1][PD][4/N] Prefill support CP with multistream forward prepare [Feat][NVIDIA] Prefill support CP with multistream forward prepare (4/N) Oct 20, 2026
@SYChen123 SYChen123 changed the title [Feat][NVIDIA] Prefill support CP with multistream forward prepare (4/N) [Feat][NVIDIA] DeepSeek-V4.1: Prefill support CP with multistream forward prepare (4/N) Oct 20, 2026
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Required checks failed on e44e29a; this PR cannot be merged until they pass.

PR title (run)

PR title must use "[Type] scope: title" or "[Type] [Hardware] scope: title". Type must be one of: Feat, Fix, Refactor, Perf, Doc, Test, CI, Chore. Scope is required and may be any module or model name, with unrestricted letter case (letters, numbers, dots, underscores, slashes, or hyphens). Hardware is optional; use a single tag without spaces. Use uppercase hardware tags (AMD, NVIDIA, NPU, MI300X), except for exactly these four spellings: Intel, Apple, Huawei, Ascend. Reverts must use GitHub's default format: Revert "original title". Use one space between fields and after the colon, with a non-empty title and no leading or trailing whitespace. Examples: "[Fix] attention: Fix KV cache indexing", "[Feat] qwen3: Add model support", "[Perf] [AMD] flash-attn: Optimize decode performance".
Edit the title; the check reruns on its own.

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

blackwell SM100/SM120 deepseek jit-kernel Multi-modal multi-modal language model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants