Class InterleavedMRope
java.lang.Object
smile.llm.model.qwen.InterleavedMRope
Interleaved multimodal RoPE for Qwen3.8 / Qwen3.5 VL text towers.
When T/H/W position planes are equal, the result matches classic 1D
partial RoPE (PartialRotaryEncoding.computeCosSin(int, int, double)).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordmRoPE position planes for one sequence. -
Method Summary
Modifier and TypeMethodDescriptionstatic PartialRotaryEncoding.CosSincomputeCosSin(int rotaryDim, double theta, int[] mropeSection, int[] posT, int[] posH, int[] posW) Builds cos/sin for a sequence from three position planes.getRopeIndex(int[] mmTokenTypeIds, int[][] imageGridThw, int[][] videoGridThw, int spatialMerge) Builds per-token mRoPE position planes for a multimodal prompt.
-
Method Details
-
computeCosSin
public static PartialRotaryEncoding.CosSin computeCosSin(int rotaryDim, double theta, int[] mropeSection, int[] posT, int[] posH, int[] posW) Builds cos/sin for a sequence from three position planes.- Parameters:
rotaryDim- even rotary feature count (e.g. 64).theta- RoPE base.mropeSection- half-freq section widths summing torotaryDim/2.posT- temporal positions lengthS.posH- height positions lengthS.posW- width positions lengthS.- Returns:
- cos/sin of shape
[S, rotaryDim]float32 (caller owns).
-
getRopeIndex
public static InterleavedMRope.MropePositions getRopeIndex(int[] mmTokenTypeIds, int[][] imageGridThw, int[][] videoGridThw, int spatialMerge) Builds per-token mRoPE position planes for a multimodal prompt.- Parameters:
mmTokenTypeIds- 0=text, 1=image, 2=video; lengthS.imageGridThw-[nImg][3]patch grids (T,H,W), or empty.videoGridThw-[nVid][3]patch grids, or empty.spatialMerge- spatial merge size.- Returns:
- planes and
rope_delta = max(pos)+1 - S.
-