Skip to content

[Feature][KV Pool] Enable Mooncake layerwise pooling for DeepSeek V4.1 - #22988

Merged
weijinqian0 merged 1 commit into
vllm-project:mainfrom
Eric-dot:dsv4.1-layerwise
Nov 26, 2026
Merged

weijinqian0 merged 1 commit into
vllm-project:mainfrom
Eric-dot:dsv4.1-layerwise

Conversation

@Eric-dot

@Eric-dot Eric-dot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

DeepSeek V4.1 Prefill can use Mooncake layerwise KV pooling with the same composite callbacks, execution-layer slots, and kv_source_layer_ids prefetch schedule introduced for Memcache in #21949. Layers without poolable cache groups advance the schedule without I/O. Mooncake continues to use its existing batched range GET/PUT, object layout, and commit/revoke handling.

Lookahead stays asynchronous without a DS4.1 attention-start gate. A device event orders upcoming reads against earlier compute, and save-only shared-source steps skip this fence. Eligible Mooncake layerwise Prefill workers prefetch up to two shared KV source layers ahead by default. On an empty execution layer, the receive thread waits on the device event while the model can keep running.

This overlaps #22256. This branch also checks and skips the no-load device fence.

The follow-up performance commits keep eligible full-attention prefixes resident across uninterrupted DSv4.1 Prefill chunks. The worker skips repeat Mooncake reads when the running-request metadata confirms that the saved prefix is already computed. Requests can reuse resident full-attention blocks with local automatic prefix caching (APC) on or off. An explicit external load still fetches the missing range, and resumed requests wait until a later uninterrupted chunk to qualify. The commits also batch session-tracker updates, vectorize range address calculation, and reuse range argument arrays when all rows remain active. On independent Store TE workers that contribute memory, preferred_segment uses the segment returned by the Store when available.

Does this PR introduce any user-facing change?

Yes. For DeepSeek V4.1 Prefill on Model Runner V2 in eager mode, set "backend": "mooncake" and "use_layerwise": true on AscendStoreConnector. In a P/D composite deployment, the separate MooncakeConnectorV2 extra config controls P/D Push.

How was this patch tested?

  • 254 focused CPU tests passed (83 subtests) in the AscendStore connector, shared-source hook and layout, Mooncake, and layerwise key/range suites. The new cases check byte-for-byte restore, source and draft submission order, SWA replay on/off, duplicate load callbacks at the replay cut, the save-only fence, and failed-load cleanup.
  • The local CPU run used the repository mocks on Windows with test-launcher compatibility shims for upstream get_pp_indices and has_connector_metadata. The broader mock run reported the same 50 failure IDs as the unmodified baseline 3f33f0d263, with 928 passing tests on the patch and 925 on the baseline. Three other modules could not be collected with the local mocks.
  • Ruff lint and format, Markdown lint, targeted mypy with missing external imports ignored, and git diff --check passed. The full bash format.sh ci run passed the formatter and ActionLint hooks, with Windows launcher and ShellCheck availability failures in other hooks.

Follow-up performance validation (14ad098251)

  • 313 focused AscendStore CPU tests passed (142 subtests), and 6 targeted scheduler tests passed. The regressions cover resident KV with APC on and off, the fallback when residency is unconfirmed, and partial HBM hit plus explicit Mooncake restore followed by a new chunk that saves only its new blocks without another GET.
  • A CPU probe matched the previous session-tracker implementation over 10,000 mixed updates in 0865c8b866. Ruff lint, Ruff format, and git diff --check passed for the latest change.

Read preparation follow-up (e31e6d122)

  • 457 focused AscendStore CPU tests and 13 targeted worker and scheduler tests passed. New cases verify that the receive thread waits for the recorded device event before issuing GETs, and that independent Store TE preference uses the registered segment with an older-SDK fallback.
  • Ruff lint and format, Markdown lint, release-note YAML parsing, and git diff --check passed. The full format script still reported Windows launcher and ShellCheck availability failures.
  • NPU validation for this follow-up remains pending.

Default read-ahead validation (f288f62c1)

  • 234 focused CPU tests passed (186 subtests) using repository mocks on Windows. The shared-source tests verify the default submission order with SWA bounded replay on and off, KV round-trip contents, and the receive-thread compute boundary.
  • Ruff lint and format and git diff --check passed. NPU validation on this commit remains pending.

Previously reported DSv4.1 performance results

Case 1 uses the HBM prefix cache. Case 2 uses Mooncake layerwise pooling. Positive relative degradation denotes higher latency or lower throughput.

Metric Case 1 · HBM prefix cache Case 2 · Mooncake + layerwise Case 2 relative degradation Strict acceptance threshold
Mean TTFT 5,945.9 ms 6,237.2 ms +4.8992% < 6,243.195 ms
P90 TTFT 7,099.7 ms 6,886.2 ms −3.0072% < 7,454.685 ms
Request throughput 4.7666 req/s 4.6435 req/s +2.5826% > 4.52827 req/s

Case 2 passed all three thresholds.

Checklist

  • Boundary / edge-case coverage

  • Regression test

  • Error / failure path coverage

  • Meaningful & reliable tests

  • NPU performance validation for the previously reported comparison

  • NPU performance validation for the read preparation follow-up

  • vLLM main: vllm-project/vllm@c410543

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for DeepSeek V4.1 Prefill using the Mooncake backend with layerwise transfer. It updates the AscendStoreConnector and pool worker to support composite KV loads and saves when using the block_key layerwise data plane, and refines prefetching and fencing logic for shared-source segments. It also adds corresponding unit tests and updates the user guide documentation. The reviewer noted that because this PR introduces user-facing changes, a release notes fragment must be added under the release_notes/fragments directory in accordance with the repository style guide.

@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [Feature] tag, indicating a bug fix or new feature.

Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:

  • Fixes #<issue_number>
  • Closes #<issue_number>
  • Resolves #<issue_number>
  • Refs #<rfc_or_issue_number> (for RFCs)

🙏 Thanks for helping us keep the project well-organized!

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 158815 lines 133 lines
Missing 45168 lines 2 lines
Coverage 72% 98%

More info see: Summary

@Eric-dot
Eric-dot marked this pull request as ready for review November 24, 2026 11:02
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-26 02:24 UTC+8 for commit df841b6.

ci-gate failed Resolved: the ci-gate passed for commit df841b6. Keeping this comment so the history stays visible; it will be updated again if a later run on this commit fails.

@weijinqian0 weijinqian0 added the ready-precise run selected e2e test for pr label Nov 25, 2026
@weijinqian0
weijinqian0 enabled auto-merge (squash) November 25, 2026 06:42
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run

[Bot]: run command accepted. E2E has been queued on the latest commit 4877d64ce8d7c1a29dee2dee05bfc55c19928d30 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added the ci-run E2E requested manually on the latest commit label Nov 25, 2026
auto-merge was automatically disabled November 25, 2026 08:22

Head branch was pushed to by a user without write access

@github-actions github-actions Bot removed the documentation Improvements or additions to documentation label Nov 25, 2026
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run

[Bot]: run command accepted. E2E has been queued on the latest commit 189d5d3642cf9f514052f038f6eec5b72c2fc4b5 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 29b814ce0b09f9195b2e40cc47a01fa70b2c234d of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@weijinqian0
weijinqian0 enabled auto-merge (squash) November 25, 2026 13:54
auto-merge was automatically disabled November 25, 2026 14:16

Head branch was pushed to by a user without write access

@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 61b3565d5c70d238b6338fab9c54f015e05b0145 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@Eric-dot
Eric-dot force-pushed the dsv4.1-layerwise branch 2 times, most recently from ce30c8f to ca3f071 Compare November 25, 2026 14:35
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit ca3f071671af585c201391a6c86146c055be585a of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run

[Bot]: run command could not start E2E on commit 6a1c864a49914a93d7c02389ad93595937c079dd. Reason: Failed to add the ci-run label (HTTP 502), so no labeled event was emitted and E2E was not triggered.

Nothing has been queued for this PR. Details are in the handler run log. Please retry /run in a moment; if it keeps failing, a maintainer can add the ci-run label to this PR manually to trigger the same E2E run.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 6a1c864a49914a93d7c02389ad93595937c079dd of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
Enable shared-source callbacks, asynchronous read-ahead, resident prefill prefixes, and batched Mooncake range/session preparation. Preserve main load/save gates and boundary publication metadata.

Rebase onto current main and retain its scoped PP collective test fixture instead of duplicating the previous fixture fix. Keep linear history compatible with the CI source-snapshot rebase.

Validation: forced local rebase onto main passes; Ruff lint/format, Python compilation and git diff --check pass for all 13 changed files. CPU/mock PP lookup probe passes 2 tests and 16 subtests using host-supplied resolved single-group metadata. Layerwise range/key suites pass 35 tests and 34 subtests with host-only upstream compatibility shims. Full vLLM and NPU validation remains for CI.

Signed-off-by: fangrongcan <17343701736@163.com>
Signed-off-by: fangrongcan <60131170+Eric-dot@users.noreply.github.com>
@Eric-dot

Eric-dot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

/run

[Bot]: run command accepted. E2E has been queued on the latest commit df841b6e94313eca0c53731f3c4390ea136330bc of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 25, 2026
@weijinqian0
weijinqian0 merged commit e302012 into vllm-project:main Nov 26, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-run E2E requested manually on the latest commit module:tests ready-precise run selected e2e test for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants