Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes RoPE inverse-frequency (inv_freq) initialization across several PyTorch model/backends to match the default rotary embedding implementation, aiming to reduce CPU vs GPU numerical differences that can cause RL training/inference inconsistencies.
Changes:
- Update Qwen3.5 default RoPE parameter computation to compute
inv_freqin float on CPU first, then move to the target device. - Update Qwen2-VL / Qwen2.5-VL vision rotary embeddings to follow the same
arange(int64) -> float -> move devicepattern. - Update dlinfer rotary embedding initialization to follow the same pattern before moving to CUDA.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lmdeploy/pytorch/models/qwen3_5.py | Adjusts default RoPE inv_freq initialization to align numerically with the default backend implementation. |
| lmdeploy/pytorch/models/qwen2_vl.py | Aligns vision rotary embedding inv_freq init pattern (CPU float compute, then .to(device)). |
| lmdeploy/pytorch/models/qwen2_5_vl.py | Same alignment for Qwen2.5-VL vision rotary embedding inv_freq. |
| lmdeploy/pytorch/backends/dlinfer/rotary_embedding.py | Aligns dlinfer base rotary embedding inv_freq init pattern (then moves to CUDA). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lvhan028
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Align all rope initialization with
lmdeploy/lmdeploy/pytorch/backends/default/rotary_embedding.py
Line 89 in 90245a3
There is a slight difference in numerical precision between CPU and GPU, which leads to inconsistencies between training and inference in RL.