Skip to content

[Feature][MRV2] sfa support dcp +pcp - #15809

Merged
Tflowers-0129 merged 5 commits into
vllm-project:mainfrom
weiguihua2:codex/pcp-dcp-sfa-stacking
Sep 9, 2026
Merged

Tflowers-0129 merged 5 commits into
vllm-project:mainfrom
weiguihua2:codex/pcp-dcp-sfa-stacking

Conversation

@weiguihua2

@weiguihua2 weiguihua2 commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

Model Runner v2 SFA DCP adapted for PCP.

This PR enables combined PCP and DCP support for SFA in Model Runner V2.
The main changes include:

  • Add AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl for combined PCP and DCP execution.
  • Adapt slot mappings and block tables for KV cache indexing under combined parallelism.
  • Add PCPDCPContext and update AscendPCPManager to track gathered-token layouts.
  • Update SFA metadata builder and implementation selection to dispatch to the combined execution path.
  • Update parallel configuration validation to support PCP and DCP stacking.
  • Extend unit tests for SFA context parallelism, configuration validation, backend selection, and PCP metadata management.

Does this PR introduce any user-facing change?

No

How was this patch tested?

@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 support for running Prefill Context Parallelism (PCP) and Data Context Parallelism (DCP) simultaneously within the Sparse Flash Attention (SFA) backend for Ascend hardware. By creating a unified metadata builder and implementation class, the changes enable efficient coordination between the two parallel strategies, ensuring correct KV cache indexing and token layout management. This integration includes necessary updates to the resolution logic, platform validation, and context management to support the combined execution path.

Highlights

  • Combined PCP and DCP Support: Implemented AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl to enable concurrent use of Prefill Context Parallelism (PCP) and Data Context Parallelism (DCP) in SFA.
  • Metadata and Context Management: Added PCPDCPContext and updated AscendPCPManager to track gathered token layouts, ensuring correct slot mapping and KV cache writes in the combined parallel mode.
  • Resolution Logic Updates: Updated resolve_sfa_metadata_builder and resolve_sfa_impl to correctly identify and select the combined implementation when both PCP and DCP are enabled.
  • Validation and Testing: Added robust validation in platform.py and comprehensive unit tests to ensure the combined parallel configuration is correctly handled and tested.
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. ↩

@github-actions

github-actions Bot commented Sep 4, 2026

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 [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!

@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:\n\nmarkdown\n[Attention][Feature] Support PCP and DCP simultaneously for SFA\n\n\nSuggested PR Summary:\n\nmarkdown\n### What this PR does / why we need it?\nThis PR enables simultaneous support for Prefill Context Parallel (PCP) and Decode Context Parallel (DCP) with Static Fine-grained Attention (SFA) on Ascend hardware. It introduces `AscendSFAPCPDCPMetadataBuilder` and `AscendSFAPCPDCPImpl` to handle the combined PCP and DCP execution path, manages PCP gathered-token layouts in DCP metadata, and updates parallel configuration validation to allow DCP overlaid on PCP.\n\nAdditionally, a critical bug was identified in `vllm_ascend/attention/context_parallel/sfa_cp.py` where using `elif` instead of `if` prevents `pcp_slot_mapping` from being set when `num_prefills == 0` in mixed batches, which can lead to assertion failures.\n\n### Does this PR introduce _any_ user-facing change?\nNo, this is an internal enablement of PCP and DCP simultaneous execution for SFA on Ascend.\n\n### How was this patch tested?\nTested with new and updated unit tests in `tests/ut/attention/test_sfa_cp.py`, `tests/ut/test_platform.py`, `tests/ut/worker/test_attn_utils_v2.py`, and `tests/ut/worker/test_pcp_manager_v2.py`.\n

Comment thread vllm_ascend/attention/context_parallel/sfa_cp.py Outdated
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch 4 times, most recently from ec5df49 to 8ebe59f Compare September 5, 2026 03:51
@weiguihua2
weiguihua2 marked this pull request as ready for review September 5, 2026 12:08
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch 5 times, most recently from ab388a1 to e29732d Compare September 7, 2026 02:48
@weiguihua2 weiguihua2 changed the title [Feature] sfa support dcp +pcp [Feature][MRV2] sfa support dcp +pcp Sep 7, 2026
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch 3 times, most recently from b78958f to cfe332e Compare September 7, 2026 05:03
@weiguihua2 weiguihua2 added the ready-precise run selected e2e test for pr label Sep 7, 2026
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch 3 times, most recently from fc085df to 8b7f5ee Compare September 8, 2026 07:52
@weiguihua2 weiguihua2 added the ready-all run all e2e test for pr label Sep 8, 2026
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch 3 times, most recently from af2e2dd to 4eddcf5 Compare September 8, 2026 13:46
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

Signed-off-by: weiguihua2 <984323595@qq.com>
Reuse the fused DCP combine operator and re-enable MRV2 accuracy CI. Validate the TP2 PCP2 DCP4 graph e2e against existing goldens.

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <984323595@qq.com>
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch from 4eddcf5 to 10a5fdb Compare September 9, 2026 01:07
Signed-off-by: weiguihua2 <weiguihua2@huawei.com>
@weiguihua2
weiguihua2 force-pushed the codex/pcp-dcp-sfa-stacking branch from 4096edc to 19ce722 Compare September 9, 2026 01:18
@weiguihua2

weiguihua2 commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

/rerun
[Bot]: rerun completed.

Rerun (failed jobs only):

  • E2E

@Tflowers-0129

Copy link
Copy Markdown
Collaborator

platform.py now advertises both dcp_size == pcp_size and dcp_size == tp_size * pcp_size, but the new PCP+DCP accuracy E2E only covers TP2/PCP2/DCP4.
But i think it is not blocking

Comment thread vllm_ascend/platform.py
@Tflowers-0129
Tflowers-0129 merged commit 3d84be3 into vllm-project:main Sep 9, 2026
47 of 49 checks passed
jiangli221 pushed a commit to jiangli221/vllm-ascend that referenced this pull request Sep 9, 2026
### What this PR does / why we need it?
Model Runner v2 SFA DCP adapted for PCP.

This PR enables combined PCP and DCP support for SFA in Model Runner V2.
The main changes include:
- Add AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl for
combined PCP and DCP execution.
- Adapt slot mappings and block tables for KV cache indexing under
combined parallelism.
- Add PCPDCPContext and update AscendPCPManager to track gathered-token
layouts.
- Update SFA metadata builder and implementation selection to dispatch
to the combined execution path.
- Update parallel configuration validation to support PCP and DCP
stacking.
- Extend unit tests for SFA context parallelism, configuration
validation, backend selection, and PCP metadata management.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?


- vLLM main:
vllm-project/vllm@b2f6858

---------

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <weiguihua2@huawei.com>
chen-commits pushed a commit to chen-commits/vllm-ascend that referenced this pull request Sep 10, 2026
### What this PR does / why we need it?
Model Runner v2 SFA DCP adapted for PCP.

This PR enables combined PCP and DCP support for SFA in Model Runner V2.
The main changes include:
- Add AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl for
combined PCP and DCP execution.
- Adapt slot mappings and block tables for KV cache indexing under
combined parallelism.
- Add PCPDCPContext and update AscendPCPManager to track gathered-token
layouts.
- Update SFA metadata builder and implementation selection to dispatch
to the combined execution path.
- Update parallel configuration validation to support PCP and DCP
stacking.
- Extend unit tests for SFA context parallelism, configuration
validation, backend selection, and PCP metadata management.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?


- vLLM main:
vllm-project/vllm@b2f6858

---------

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <weiguihua2@huawei.com>
sunny-rain-63 pushed a commit to sunny-rain-63/vllm-ascend that referenced this pull request Sep 12, 2026
### What this PR does / why we need it?
Model Runner v2 SFA DCP adapted for PCP.

This PR enables combined PCP and DCP support for SFA in Model Runner V2.
The main changes include:
- Add AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl for
combined PCP and DCP execution.
- Adapt slot mappings and block tables for KV cache indexing under
combined parallelism.
- Add PCPDCPContext and update AscendPCPManager to track gathered-token
layouts.
- Update SFA metadata builder and implementation selection to dispatch
to the combined execution path.
- Update parallel configuration validation to support PCP and DCP
stacking.
- Extend unit tests for SFA context parallelism, configuration
validation, backend selection, and PCP metadata management.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?


- vLLM main:
vllm-project/vllm@b2f6858

---------

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <weiguihua2@huawei.com>
like-0517 pushed a commit to like-0517/vllm-ascend that referenced this pull request Sep 15, 2026
### What this PR does / why we need it?
Model Runner v2 SFA DCP adapted for PCP.

This PR enables combined PCP and DCP support for SFA in Model Runner V2.
The main changes include:
- Add AscendSFAPCPDCPMetadataBuilder and AscendSFAPCPDCPImpl for
combined PCP and DCP execution.
- Adapt slot mappings and block tables for KV cache indexing under
combined parallelism.
- Add PCPDCPContext and update AscendPCPManager to track gathered-token
layouts.
- Update SFA metadata builder and implementation selection to dispatch
to the combined execution path.
- Update parallel configuration validation to support PCP and DCP
stacking.
- Extend unit tests for SFA context parallelism, configuration
validation, backend selection, and PCP metadata management.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?

- vLLM main:
vllm-project/vllm@b2f6858

---------

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: weiguihua2 <weiguihua2@huawei.com>
Signed-off-by: like-0517 <ithwlike@126.com>
lllyys pushed a commit to lllyys/vllm-ascend that referenced this pull request Sep 18, 2026
…t mapping (vllm-project#16597)

Partial backport of vllm-project#16597 to releases/v0.26.0rc: only the SFA DCP
replicated slot-mapping padding fix and its regression test are included.
_build_slot_mapping_replicated_view sized its repeat_interleave output by
num_input_tokens, which can include graph padding, while the repeated query
lengths cover only real tokens; this raises a RuntimeError whenever
num_input_tokens > sum(query_lens). The fix sizes it by the actual query
token count from query_start_loc_cpu.

The SFA-PCP / MTP-PCP feature work in the original commit requires MRV2 PCP
groundwork (vllm-project#15809, vllm-project#14960) that is not on this branch and is intentionally
not included.

(cherry picked from commit 0301ec6)

Signed-off-by: weiguihua2 <984323595@qq.com>
Signed-off-by: lllyys <221728326+lllyys@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants