Skip to content

fix odtsr rope#230

Merged
qzzz95 merged 2 commits intomainfrom
dev/qz/fix_odtsr_rope
Jan 29, 2026
Merged

fix odtsr rope#230
qzzz95 merged 2 commits intomainfrom
dev/qz/fix_odtsr_rope

Conversation

@qzzz95
Copy link
Copy Markdown
Contributor

@qzzz95 qzzz95 commented Jan 29, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @qzzz95, 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 addresses and optimizes the Rotational Positional Embedding (RoPE) calculation within the odtsr_forward function, specifically for the QwenEmbedRope component. The core objective is to enhance the accuracy and performance of positional encoding for multimodal inputs, such as video and text, by implementing a custom forward pass that includes caching mechanisms and tailored frequency generation based on input dimensions. This change is crucial for maintaining the integrity of positional information in models utilizing these embeddings, particularly in contexts like image upscaling or video processing.

Highlights

  • QwenEmbedRope Integration: The QwenEmbedRope class is now imported and its forward method is temporarily overridden within the odtsr_forward context to allow for custom positional embedding logic.
  • Optimized RoPE Calculation: A new optimized_rope_forward function has been introduced to handle the calculation of Rotational Positional Embeddings (RoPE) for both video and text data, including logic for caching frequencies.
  • Dynamic Frequency Generation: The optimized_rope_forward method dynamically generates and caches video and text frequencies based on input dimensions (frame, height, width) and a scale_rope flag, ensuring efficient and correct positional encoding.

🧠 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.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

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 aims to fix an issue with Rotary Positional Embeddings (RoPE) for ODTSR by monkey-patching QwenEmbedRope.forward. The overall approach is sound, but I've identified a few areas for improvement. There's a minor typo in a variable name and a loop that could be simplified for better readability. More critically, a monkey-patch is not being reverted in the finally block, which could lead to unintended side effects elsewhere in the application. Addressing this is crucial for maintaining the stability of the codebase.

"""
original_lora_forward = LoRALinear.forward
original_modulate = QwenImageTransformerBlock._modulate
original_repo_forward = QwenEmbedRope.forward
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.

medium

There's a typo in the variable name original_repo_forward. It should be original_rope_forward to align with the class QwenEmbedRope and the function optimized_rope_forward.

Suggested change
original_repo_forward = QwenEmbedRope.forward
original_rope_forward = QwenEmbedRope.forward

Comment on lines +61 to +62
for idx, fhw in enumerate(video_fhw):
idx = 0
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.

medium

The loop variable idx from enumerate is immediately overwritten with 0. This is redundant and can be simplified for better readability by initializing idx before the loop and iterating directly over video_fhw.

Suggested change
for idx, fhw in enumerate(video_fhw):
idx = 0
idx = 0
for fhw in video_fhw:

@modelscope modelscope deleted a comment from gemini-code-assist Bot Jan 29, 2026
@qzzz95 qzzz95 merged commit a3b1585 into main Jan 29, 2026
@qzzz95 qzzz95 deleted the dev/qz/fix_odtsr_rope branch January 29, 2026 08:43
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