-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[CI/Build][CPU] Fix CPU CI and remove all CPU V0 files #20560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: jiang1.li <[email protected]>
Signed-off-by: jiang1.li <[email protected]>
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @bigPYJ1151, 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 primarily focuses on stabilizing and advancing the CPU continuous integration (CI) pipeline by resolving prior merge conflicts and re-integrating critical fixes. It marks a significant step in the transition to the V1 CPU backend by adjusting the test suite to reflect V1 compatibility and limitations, and by consolidating the entire CPU attention backend implementation within a dedicated V1 file. This ensures that CPU-related development and testing are aligned with the new V1 architecture.
Highlights
- CPU CI Fixes & Test Adjustments: This PR addresses previous merge conflicts and re-applies a dropped commit to fix CPU CI tests. It updates the CPU test suite by disabling certain tests (e.g.,
test_cache.py
,test_mla_decode_cpu.py
,test_bart.py
,test_chunked_prefill.py
) and modifying others to align with the V1 CPU backend's current capabilities and limitations. - V1 CPU Backend Consolidation: The core CPU attention backend (
TorchSDPABackendImpl
and its associatedTorchSDPAMetadata
) has been fully implemented and consolidated withinvllm/v1/attention/backends/cpu_attn.py
. This includes the detailed logic for PagedAttention operations, with conditional support for Intel Extension for PyTorch (IPEX) for optimized performance. - Transition to V1 for CPU: Several test configurations have been updated to explicitly enforce the use of the V1 CPU backend, marking a clear deprecation of V0 for CPU-specific tests where applicable. This ensures that CPU-related tests are run against the intended V1 architecture.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize 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 is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
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. ↩
There was a problem hiding this comment.
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 fixes CPU CI tests by resolving merge conflicts and re-committing changes. It disables certain tests and introduces a new V1 CPU attention backend. There are a couple of high-severity issues in the new backend related to correctness and performance that should be addressed.
def get_supported_head_sizes(cls) -> list[int]: | ||
return PagedAttention.get_supported_head_sizes() | ||
if _use_ipex: | ||
return [] | ||
else: | ||
return _get_paged_attn_impl()\ | ||
.get_supported_head_sizes() # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When _use_ipex
is true, this function returns an empty list, indicating no supported head sizes. However, the TorchSDPABackendImpl
constructor still validates against a hardcoded list, potentially leading to a ValueError
at runtime if the head size isn't in that list. To avoid this inconsistency, the supported head sizes should be retrieved from _get_paged_attn_impl()
even when _use_ipex
is true.
def get_supported_head_sizes(cls) -> list[int]: | |
return PagedAttention.get_supported_head_sizes() | |
if _use_ipex: | |
return [] | |
else: | |
return _get_paged_attn_impl()\ | |
.get_supported_head_sizes() # type: ignore | |
@classmethod | |
def get_supported_head_sizes(cls) -> list[int]: | |
if _use_ipex: | |
return _get_paged_attn_impl().get_supported_head_sizes() | |
else: | |
return _get_paged_attn_impl().get_supported_head_sizes() # type: ignore |
for seq_len_q, seq_len_kv, mask in zip(seq_lens_q, seq_lens_kv, | ||
attn_masks): | ||
end_q = start_q + seq_len_q | ||
end_kv = start_kv + seq_len_kv | ||
sub_out = scaled_dot_product_attention( | ||
query[None, :, start_q:end_q, :], | ||
key[None, :, start_kv:end_kv, :], | ||
value[None, :, start_kv:end_kv, :], | ||
attn_mask=mask, | ||
dropout_p=0.0, | ||
is_causal=causal_attn and mask is None, | ||
scale=self.scale).squeeze(0).movedim(query.dim() - 2, 0) | ||
output[start_q:end_q, :, :] = sub_out | ||
start_q, start_kv = end_q, end_kv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop iterates through sequences one by one, which can be inefficient due to Python loop overhead and tensor slicing. scaled_dot_product_attention
is optimized for batched operations. Vectorizing this operation by constructing a single batch-level attention mask and calling scaled_dot_product_attention
once can improve performance.
if current_platform.is_cpu() and os.environ.get("VLLM_USE_V1", "0") == "0": | ||
pytest.skip("CPU only supports V1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@classmethod | ||
def get_supported_head_sizes(cls) -> list[int]: | ||
return PagedAttention.get_supported_head_sizes() | ||
if _use_ipex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest merging these two functions together. We only need validate_head_size
in V1 - get_supported_head_sizes
is just for convenience and only used by validate_head_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the Attention classes in this file can implement validate_head_size
instead of get_supported_head_sizes
Signed-off-by: jiang1.li <[email protected]>
Signed-off-by: jiang1.li <[email protected]>
Signed-off-by: jiang1.li <[email protected]>
Going to wait until the release is out before merging this |
docker exec cpu-test-"$NUMA_NODE" bash -c " | ||
set -e | ||
pytest -s -v -k cpu_model \ | ||
tests/basic_correctness/test_chunked_prefill.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove cpu_model from this test?
Signed-off-by: jiang1.li <[email protected]>
…20560) Signed-off-by: jiang1.li <[email protected]>
…20560) Signed-off-by: jiang1.li <[email protected]>
…20560) Signed-off-by: jiang1.li <[email protected]> Signed-off-by: Jinzhen Lin <[email protected]>
…20560) Signed-off-by: jiang1.li <[email protected]>
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
During the merging of #20412 , there were some conflicts and dropped the commit of #20437 accidently.
This PR resolves the conflicts and re-commits the commit to fix CPU CI tests.
Test Plan
Test Result
(Optional) Documentation Update