Skip to content

[BugFix][KV Offload] Sync PCP snapshots and validate shared-buffer reuse fences - #22068

Open
Zyang123123 wants to merge 12 commits into
vllm-project:mainfrom
Zyang123123:fix/glm53-prefill-offload-compat
Open

Zyang123123 wants to merge 12 commits into
vllm-project:mainfrom
Zyang123123:fix/glm53-prefill-offload-compat

Conversation

@Zyang123123

@Zyang123123 Zyang123123 commented Nov 16, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

Fixes shared-buffer Prefill offload safety for GLM-5.3-Flash with PP/PCP and MultiConnector.

  • Drain local deferred saves, then synchronize TP and PCP workers before reading previous-step snapshots. All ranks participate based on configuration, including ranks with empty local batches, so readers cannot query snapshots before another rank finishes publishing them.
  • Reject MultiConnector configurations that enable layerwise buffer reuse without a slot-release fence for every PD connector.
  • Extend the snapshot publication regression to cover TP and PCP synchronization, including empty local batches.

Uses the existing Mooncake Push buffer-reuse fencing implementation.

Does this PR introduce any user-facing change?

Yes. Prevents missing-snapshot failures with PCP layerwise offload and reports unsafe connector combinations during initialization. No new configuration options are introduced.

How was this patch tested?

An earlier revision of the patch was validated with CPU unit tests in the existing A5 container environment; NPU operations were mocked:

TORCH_DEVICE_BACKEND_AUTOLOAD=0 python3 -m pytest -q \
  tests/ut/distributed/ascend_store \
  tests/ut/kv_offload/mooncake_v2
  • 1929 passed, 12 skipped.

  • Ruff check/format, spelling, Markdown, workflow and Python custom checks passed. The logger check also passed on Linux.

  • Full local format validation encountered Windows-specific limitations: ShellCheck reported CRLF shell files, and the Gitleaks hook could not resolve /bin/bash. CI validation remains required.

  • NPU inference and performance tests have not been rerun for the rebased patch.

  • vLLM main: vllm-project/vllm@c410543

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces critical fixes for KV cache offload when using Mooncake Push with combined pipeline and prefill context parallelism. It addresses discrepancies in shared-cache layout access and corrects layer-range calculations that previously failed under specific rank arithmetic. These changes ensure reliable fence registration and accurate offload keys, improving stability for complex distributed configurations.

Highlights

  • Shared-Cache Layout Alignment: Updated the Push facade and worker to use a shared accessor for the cache layout, resolving a mismatch between dependency-provided fields and the current planner's output.
  • PP Offset and Layer Count Correction: Fixed the offload PP offset and layer count calculation to use the planner's actual global layer IDs, ensuring correctness when combining pipeline and prefill context parallelism.
  • Regression Testing: Added new unit tests to cover reuse scenarios, stage offsets, and multi-rank configurations to prevent future regressions in layout publication and connector registration.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@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

Suggested PR Title:

[Ops][Feature] Refactor layerwise KV cache offload and buffer reuse planning

Suggested PR Summary:

### What this PR does / why we need it?
This PR refactors the layerwise KV cache offloading and buffer reuse planning mechanism. It introduces a structured `LayerwiseCachePlanner` and `LayerwiseReuseLayout` to replace the old layout building logic. This enables more robust planning of layerwise cache reuse from native cache groups, supports shared-buffer offloading, tracks execution-local snapshot keys, and ensures correct handling of pipeline parallel (PP) and context parallel (PCP) rank offsets.

### Does this PR introduce _any_ user-facing change?
No, these are internal performance optimizations and architectural refactorings for KV cache transfer and offloading on Ascend platforms.

### How was this patch tested?
New unit tests have been added in `tests/ut/kv_offload/mooncake_v2/test_push_offload_layout.py` and `tests/ut/kv_transfer/test_layerwise_offload_pp_pcp.py` to verify the push offload layout and correct PP stage indexing under PCP.

I have reviewed the changes and found no issues. There are no review comments to address, so I have no further feedback to provide.

@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.


Tip

💡 Consider Linking a Related Issue or RFC

Your PR title contains the [BugFix] 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 16, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-25 15:56 UTC+8 for commit e802a86.

ci-gate failed. Reason:

CODEOWNERS approval gate failed: at least one changed file has no approval from its owner(s). Open the 'CODEOWNERS' steps above to see which files are missing approvals and who can approve.

See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted).

Missing owner approvals. Every changed file needs one approval from its CODEOWNERS owner(s):

  • release_notes/fragments/22068.yaml: changes requested by @zhenwenqi2024; address the feedback, then ask them to re-review (approve or dismiss)

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@Zyang123123 Zyang123123 changed the title [BugFix][KV Offload] Align Push reuse layout and PP offsets with PCP [BugFix][KV Offload] Fix Push reuse layout, PP offsets and PCP snapshot fencing Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Zyang123123 added a commit to Zyang123123/vllm-ascend that referenced this pull request Nov 19, 2026
Merge PR vllm-project#22068 at 00ff032 with upstream main f603ba5 in an isolated validation branch. Preserve the upstream unified cache allocator and remove obsolete test monkeypatches while retaining the PR reuse layout and buffer alignment.

Signed-off-by: Zyang123123 <jiaoziyang0123@163.com>
@Zyang123123 Zyang123123 changed the title [BugFix][KV Offload] Fix Push reuse layout, PP offsets and PCP snapshot fencing [BugFix][KV Offload] Fence Mooncake Push reads and sync PCP snapshots for GLM-5.3-Flash Nov 21, 2026
@Zyang123123
Zyang123123 marked this pull request as ready for review November 21, 2026 08:14
@Zyang123123 Zyang123123 changed the title [BugFix][KV Offload] Fence Mooncake Push reads and sync PCP snapshots for GLM-5.3-Flash [BugFix][KV Offload] Sync PCP snapshots and validate shared-buffer reuse fences Nov 24, 2026

Zyang123123 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 6d93e60c4846a7e4794552bc3c9c6169ffd5110b 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
…-20261124

Signed-off-by: Zyang123123 <jiaoziyang0123@163.com>
Signed-off-by: Zyang123123 <jiaoziyang0123@163.com>
@Zyang123123

Zyang123123 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit e802a86ba3899a3e8a36eef59fcc178c033cfa41 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
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 156203 lines 12 lines
Missing 44695 lines 5 lines
Coverage 71% 58%

More info see: Summary

@Tflowers-0129 Tflowers-0129 added the ready-precise run selected e2e test for pr label Nov 25, 2026
Comment thread release_notes/fragments/22068.yaml Resolved
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: Zyang123123 <jiaoziyang0123@163.com>
@Zyang123123

Zyang123123 commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit be07c600e02320aa73eed2c4cdb947c23ba37cc7 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 26, 2026

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants