Conversation
Summary of ChangesHello, 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
🧠 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
Using Gemini Code AssistThe 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
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 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
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
There was a problem hiding this comment.
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.0Suggested 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.| 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() |
There was a problem hiding this comment.
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()3623f11 to
9221c96
Compare
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>
9221c96 to
ad6e516
Compare
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>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
What this PR does / why we need it?
Does this PR introduce any user-facing change?
How was this patch tested?