[Model] Drop the 4x M-RoPE cache headroom for Qwen3-VL, Qwen3.5 and Qwen3.8 (#59853)

Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@gmail.com>
Co-authored-by: lesj0610 <lesj0610@users.noreply.github.com>
This commit is contained in:
SeongJun Lee
2026-10-10 06:51:52 +00:00
committed by GitHub
co-authored by lesj0610
parent c1692c85f1
commit a98247ab4d
11 changed files with 56 additions and 6 deletions
@@ -315,8 +315,9 @@ class MRotaryEmbedding(RotaryEmbeddingBase):
dtype: torch.dtype,
mrope_section: list[int] | None = None,
mrope_interleaved: bool = False,
# YaRN parameters.
*,
positions_factor: int = 4,
# YaRN parameters.
scaling_factor: float | None = None,
beta_fast: int = 32,
beta_slow: int = 1,
@@ -345,8 +346,9 @@ class MRotaryEmbedding(RotaryEmbeddingBase):
# In Qwen2.5-VL, the maximum index value is related to the duration of
# the input video. We enlarge max_position_embeddings to 4 times to get
# a larger the cos and sin cache.
self.cache_max_position_num = max_position_embeddings * 4
# a larger the cos and sin cache. Models whose positions never exceed
# the token count pass `positions_factor=1`.
self.cache_max_position_num = max_position_embeddings * positions_factor
super().__init__(
head_size,
rotary_dim,