mstar.model.qwen3_5.components.rope#
Qwen3.5’s interleaved 3D MRoPE, over a partial rotary dim.
Model-side because the position resource serves only 1D RoPE. The three grids
are interleaved [T,H,W,T,H,W,...] over the frequency dims, and only
head_dim * partial_rotary_factor of each head is rotated (64 of 256 for
every released size).
TODO: this duplicates qwen3_omni/components/rope.py apart from the partial
rotation. Both belong in model/components/rope.py.
Functions
|
Rotate the leading |
|
cos/sin of shape |
|
|
|
|
|
How far one image moves the position cursor. |
|
|
- mstar.model.qwen3_5.components.rope.apply_partial_mrope(q, k, cos, sin, unsqueeze_dim=1)[source]#
Rotate the leading
cos.shape[-1]dims of each head, pass the rest.q/kare[tokens, heads, head_dim]; cos/sin are[tokens, rotary_dim]and broadcast over the head axis.
- mstar.model.qwen3_5.components.rope.compute_3d_cos_sin(position_ids_3d, inv_freq, mrope_section, target_dtype=None)[source]#
cos/sin of shape
[seq_len, rotary_dim]from[3, seq_len]positions.
- mstar.model.qwen3_5.components.rope.compute_inv_freq(rotary_dim, rope_theta, device=None)[source]#
1 / theta^(2i/d)over the rotated dims only;[rotary_dim // 2].
- mstar.model.qwen3_5.components.rope.text_position_ids(seq_len, start_pos=0, device=None)[source]#
[3, seq_len]for a pure-text span: all three grids advance together.
- mstar.model.qwen3_5.components.rope.vision_position_advance(grid_thw, spatial_merge_size)[source]#
How far one image moves the position cursor.
max(h', w')positions, not itst * h' * w'tokens: the grids run in parallel.
- mstar.model.qwen3_5.components.rope.vision_position_ids(grid_thw, spatial_merge_size, start_pos=0, device=None)[source]#
[3, t * h' * w']for one image, whereh' = h // merge.T is constant across a frame while H and W sweep the merged patch grid, all based at
start_pos; row-major over(t, h', w'), the merger’s token order.