Skip to content

Conversation

Xqle
Copy link
Contributor

@Xqle Xqle commented Sep 26, 2025

What does this PR do?

This PR fixes the propagation of rope_deltas in the Qwen2.5-VL model during generation.

Currently, the forward() method of Qwen2_5_VLForConditionalGeneration accepts rope_deltas as an argument, but the value is never passed to the underlying Qwen2_5_VLModel. As a result, users providing rope_deltas directly to forward() would see no effect.

Modifications

  1. Qwen2_5_VLForConditionalGeneration.forward() now passes rope_deltas to Qwen2_5_VLModel.forward().
  2. Qwen2_5_VLModel.forward() now accepts rope_deltas and updates its internal state accordingly.
  3. Updates prepare_inputs_for_generation() to store calculated rope_deltas
    in model_inputs, aligning its handling with position_ids.

Impact

  • Users can now explicitly provide rope_deltas during generation and have them correctly applied.
  • Ensures consistency between prefill and decoding phases in multi-modal generation.
  • Aligns the API behavior with documentation.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

- Forward rope_deltas from Qwen2_5_VLForConditionalGeneration to Qwen2_5_VLModel
- Update Qwen2_5_VLModel to accept rope_deltas and store internally
- Refactor prepare_inputs_for_generation to unify rope_deltas handling
- Ensure that passing rope_deltas in forward() now correctly affects position_ids calculation
This fixes an issue where passing rope_deltas directly to the model's forward() had no effect,
which could lead to inconsistencies between pre-fill generation and manual forward calls.
@Xqle Xqle changed the title Optimize rope_deltas propagation logic in Qwen2.5-VL ✅ Optimize rope_deltas propagation logic in Qwen2.5-VL Sep 26, 2025
@Rocketknight1
Copy link
Member

cc @zucchini-nlp for VLMs, @ArthurZucker for rope

Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: qwen2_5_vl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants