Skip to content

Main2main 0324#7610

Open
22dimensions wants to merge 4 commits intovllm-project:mainfrom
22dimensions:main2main_0324
Open

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

Conversation

@22dimensions
Copy link
Collaborator

@22dimensions 22dimensions commented Mar 24, 2026

What this PR does / why we need it?

Does this PR introduce any user-facing change?

How was this patch tested?

@gemini-code-assist
Copy link
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
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
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
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 and others added 2 commits March 25, 2026 11:10
fix: add missing num_prompt_tokens_cpu_tensor to NPUInputBatch

Adapt to upstream vLLM changes in InputBatch. The vLLM v1 refactored
InputBatch to use torch tensors for CPU data structures with numpy views,
matching the pattern used for other batch statistics.

- Added num_tokens_no_spec_cpu_tensor and num_tokens_no_spec
- Added num_prompt_tokens_cpu_tensor and updated num_prompt_tokens to be a numpy view
- Fixes AttributeError: 'NPUInputBatch' object has no attribute 'num_prompt_tokens_cpu_tensor'

Affects: All pooling model tests that access input batch metadata.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: 22dimensions <waitingwind@foxmail.com>
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>
Fixes CI failures in schedule_test_vllm_main (run 23528704656) caused by
upstream vLLM API changes and version incompatibilities:

1. VLLM_BATCH_INVARIANT attribute access: Added hasattr() check with
   fallback to os.getenv() for cross-version compatibility
   - Affected 83 test cases

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

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

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions
Copy link
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.

2 participants