Skip to content

Main2main 0324#7610

Closed
22dimensions wants to merge 6 commits intovllm-project:mainfrom
22dimensions:main2main_0324
Closed

Main2main 0324#7610
22dimensions wants to merge 6 commits intovllm-project:mainfrom
22dimensions:main2main_0324

Conversation

@22dimensions
Copy link
Copy Markdown
Collaborator

@22dimensions 22dimensions commented Mar 24, 2026

What this PR does / why we need it?

main2main vllm update to 0324 commit 14acf429ac08b6d538ca6feb3e06b6d13895804d

  1. https://github.com/vllm-project/vllm/pull/32951/changes this pr refactor model runner and attention.

Does this PR introduce any user-facing change?

No

How was this patch tested?

CI

@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 primarily focuses on maintaining compatibility and updating documentation. It adjusts the initialization of certain token-related arrays in the NPU input batch worker to accommodate different vLLM versions, specifically handling changes introduced after version 0.18.0. Additionally, it updates the versioning policy documentation to reflect the latest compatible vLLM commit for the main branch.

Highlights

  • Documentation Update: The vLLM commit hash in the docs/source/community/versioning_policy.md file has been updated to reflect a newer version for the main branch compatibility.
  • Version-Specific Initialization: Conditional logic was introduced in vllm_ascend/worker/npu_input_batch.py to initialize num_tokens_no_spec and num_prompt_tokens differently based on whether the vLLM version is 0.18.0 or not, ensuring compatibility across versions.

🧠 New Feature in Public Preview: You can now enable Memory 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.

Ignored Files
  • Ignored by pattern: .github/workflows/** (6)
    • .github/workflows/_e2e_test.yaml
    • .github/workflows/bot_pr_create.yaml
    • .github/workflows/dockerfiles/Dockerfile.lint
    • .github/workflows/pr_test_full.yaml
    • .github/workflows/pr_test_light.yaml
    • .github/workflows/schedule_codecov_refresh.yaml
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 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 counter productive. 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 added documentation Improvements or additions to documentation ci/build labels Mar 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.

@22dimensions 22dimensions added ready read for review ready-for-test start test by label for PR and removed documentation Improvements or additions to documentation ci/build labels Mar 24, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 updates the compatible vLLM commit hash and introduces version-specific logic in NPUInputBatch to maintain compatibility with vLLM versions beyond v0.18.0. The change correctly adapts tensor initializations based on the vLLM version. However, the new code block introduces some duplication which could be refactored for better maintainability. Additionally, the pull request title and description do not conform to the repository's style guide. I have provided suggestions for both below.

Suggested PR Title:

[main][Worker][Compat] Add compatibility for vLLM versions beyond v0.18.0

Suggested PR Summary:

### What this PR does / why we need it?

This PR updates the compatible vLLM commit hash in the versioning policy documentation. It also modifies `NPUInputBatch` to handle differences in tensor initialization between vLLM v0.18.0 and later versions. Specifically, for versions other than v0.18.0, `num_tokens_no_spec` and `num_prompt_tokens` are now backed by pinned memory tensors to align with upstream changes, ensuring continued compatibility.

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

No, this is an internal refactoring to maintain compatibility with different versions of vLLM and does not introduce any user-facing changes.

### How was this patch tested?

CI should pass with existing tests.

Comment on lines +88 to +101
self.num_tokens_no_spec_cpu_tensor = torch.zeros(
(max_num_reqs,),
device="cpu",
dtype=torch.int32,
pin_memory=pin_memory,
)
self.num_tokens_no_spec = self.num_tokens_no_spec_cpu_tensor.numpy()
self.num_prompt_tokens_cpu_tensor = torch.zeros(
(max_num_reqs,),
device="cpu",
dtype=torch.int32,
pin_memory=pin_memory,
)
self.num_prompt_tokens = self.num_prompt_tokens_cpu_tensor.numpy()
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.

high

The initialization logic for num_tokens_no_spec_cpu_tensor and num_prompt_tokens_cpu_tensor is duplicated. This reduces maintainability, as any future changes to the tensor creation would need to be applied in two places, increasing the risk of errors. Please refactor this to remove the duplication by extracting the common arguments.

            tensor_args = dict(device="cpu", dtype=torch.int32, pin_memory=pin_memory)
            self.num_tokens_no_spec_cpu_tensor = torch.zeros((max_num_reqs,), **tensor_args)
            self.num_tokens_no_spec = self.num_tokens_no_spec_cpu_tensor.numpy()
            self.num_prompt_tokens_cpu_tensor = torch.zeros((max_num_reqs,), **tensor_args)
            self.num_prompt_tokens = self.num_prompt_tokens_cpu_tensor.numpy()

@22dimensions 22dimensions force-pushed the main2main_0324 branch 2 times, most recently from 9221c96 to ad6e516 Compare March 25, 2026 03:27
@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@github-actions
Copy link
Copy Markdown
Contributor

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

@22dimensions 22dimensions force-pushed the main2main_0324 branch 2 times, most recently from 0436fbc to 355d0c6 Compare March 30, 2026 08:43
22dimensions and others added 6 commits March 30, 2026 20:41
Signed-off-by: 22dimensions <waitingwind@foxmail.com>
Upstream vLLM has removed the vllm_is_batch_invariant() function from
batch_invariant.py and now uses envs.VLLM_BATCH_INVARIANT directly.

Create a compatibility wrapper in vllm_ascend/batch_invariant.py that
checks envs.VLLM_BATCH_INVARIANT and update all imports across the codebase
to use the local implementation instead of trying to import from vllm.

Changes:
- Add vllm_is_batch_invariant() function to vllm_ascend/batch_invariant.py
- Update imports in ascend_config.py, sample/sampler.py, and utils.py

Fixes: ImportError when running multicard tests

Co-Authored-By: Claude Code <noreply@anthropic.com>
caused by: vllm-project/vllm#32951

1. AscendEagleProposer missing runner attribute: Added self.runner
   assignment right after parent __init__ to ensure availability
   - Affected 32 test cases (spec_decode tests)

2. Tensor.gpu deprecated API: Added _get_device_tensor() compatibility
   wrapper to handle both CpuGpuBuffer and direct Tensor objects
   - Affected 5 test cases

3. PrefillNoCache mode doesn't need to read from key_cache, only write to it.
   Skip key_cache initialization requirement for PrefillNoCache mode.

4. For plain GPU tensors, fill the tensor directly instead of calling .cpu()
   which creates a separate CPU copy that won't affect the GPU tensor.

5. Fixed unprotected buffer property accesses that could cause garbage output:
   - Line 919: query_start_loc.gpu access for logits_indices calculation
   - Line 1071: input_ids.gpu access for draft token computation
   - Lines 1147-1149: pcp_manager buffer access
   - Lines 1171, 1207: input_ids.gpu slicing for target tokens
   - Line 1399: query_start_loc.np assignment
   - Lines 859-862: mrope_positions gpu/cpu access

6. These were causing non-deterministic/garbage output during generation.

7. Fix unprotected access to xdrope_positions.gpu for plain tensor compatibility.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…or and kv_offload import

Signed-off-by: leo-pony <nengjunma@outlook.com>
Root causes of main2main CI failures:
- NPUModelRunner missing query_pos attribute initialization fallback
- CpuGpuBuffer used for positions in PCP/DCP case instead of plain tensor
- KV offload import path compatibility

Changes:
1. Add fallback query_pos initialization in NPUModelRunner.__init__() if parent
   class doesn't initialize it (compatibility with different vLLM versions)
2. Use plain torch.zeros() instead of _make_buffer() for positions and input_ids
   in PCP/DCP cases to match upstream expectations (directly subscriptable)
3. Add fallback import handling for CPUOffloadingManager with version compatibility

These fixes address 89 of 152 failing tests across all test categories.

Fixes issues:
- AttributeError: 'NPUModelRunner' object has no attribute 'query_pos' (67 tests)
- TypeError: 'CpuGpuBuffer' object is not subscriptable (21 tests)
- ModuleNotFoundError: No module named 'vllm.v1.kv_offload.cpu.manager' (1 test)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Previous fix was too broad - we only need to use plain tensor for positions
(which needs to be subscriptable), but input_ids must remain as CpuGpuBuffer
because upstream code calls .copy_to_gpu() on it.

This matches the parent GPUModelRunner's initialization pattern:
- input_ids: CpuGpuBuffer (supports .copy_to_gpu() at line 1626)
- positions: plain tensor (supports subscripting at line 3271)

Fixes:
- AttributeError: 'Tensor' object has no attribute 'copy_to_gpu' (21 tests)
- Maintains subscriptable positions for long_sequence and chunked_prefill tests

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflicts ready read for review ready-for-test start test by label for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants