Skip to content

Conversation

@DarkLight1337
Copy link
Member

@DarkLight1337 DarkLight1337 commented Oct 22, 2025

Purpose

Some methods were still defined as classmethods, contrary to the interface.

Follow up to #24172

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 22, 2025
@mergify mergify bot added the qwen Related to Qwen models label Oct 22, 2025
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 correctly changes get_mrope_input_positions from a classmethod to an instance method across multiple models to align with the SupportsMRoPE interface. While reviewing, I noticed that the type hints for image_grid_thw in these methods do not match the interface, which expects them to be optional. The current implementations would raise an error if None is passed. I've added comments with high severity to correct the type hints and suggest adding None checks to prevent potential runtime errors.

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, image_grid_thw.tolist() at line 1430 will raise an AttributeError if image_grid_thw is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, image_grid_thw.tolist() at line 644 will raise an AttributeError if image_grid_thw is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, len(image_grid_thw) at line 641 will raise a TypeError if image_grid_thw is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, torch.tensor(image_grid_thw) at line 1035 will raise an error if image_grid_thw is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list or tensor.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, indexing image_grid_thw at line 1128 will raise a TypeError if it is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

self,
input_tokens: list[int],
hf_config: PretrainedConfig,
image_grid_thw: list[list[int]] | torch.Tensor,
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 get_mrope_input_positions method signature in the SupportsMRoPE interface specifies that image_grid_thw can be None. This implementation's type hint should be updated to reflect this by adding | None.

Additionally, the method body does not correctly handle the case where image_grid_thw or video_grid_thw are None. For example, indexing image_grid_thw at line 1529 will raise a TypeError if it is None. Please add checks to handle None values at the beginning of the method, for instance by initializing them to an empty list.

Suggested change
image_grid_thw: list[list[int]] | torch.Tensor,
image_grid_thw: list[list[int]] | torch.Tensor | None,

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) October 22, 2025 13:28
@vllm-bot vllm-bot merged commit 14e2f12 into vllm-project:main Oct 22, 2025
53 of 58 checks passed
@DarkLight1337 DarkLight1337 deleted the fix-mrope-method-type branch October 22, 2025 15:38
usberkeley pushed a commit to usberkeley/vllm that referenced this pull request Oct 23, 2025
albertoperdomo2 pushed a commit to albertoperdomo2/vllm that referenced this pull request Oct 23, 2025
kingsmad pushed a commit to kingsmad/vllm that referenced this pull request Oct 25, 2025
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
0xrushi pushed a commit to 0xrushi/vllm that referenced this pull request Oct 26, 2025
ilmarkov pushed a commit to neuralmagic/vllm that referenced this pull request Nov 7, 2025
rtourgeman pushed a commit to rtourgeman/vllm that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants