Skip to content

feat(xla): add multimodal RoPE position state - #894

Merged
inureyes merged 3 commits into
mainfrom
feature/issue-864-multimodal-rope
Jul 23, 2026
Merged

inureyes merged 3 commits into
mainfrom
feature/issue-864-multimodal-rope

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

  • Add an explicit 1D versus three-axis M-RoPE prepared-position contract and validate Qwen section layouts.
  • Thread signed per-request decode deltas through StableHLO, the C ABI, single sessions, and continuous-batch slot lifecycle.
  • Preserve byte-exact 1D graphs and add MLX coordinate, eager Q/K, mixed-slot, and real-IREE regression gates.

Validation

  • cargo test -p mlxcel-core --lib multimodal --quiet
  • cargo test -p mlxcel-xla --lib --quiet
  • cargo clippy -p mlxcel-core -p mlxcel-xla --lib --tests -- -D warnings
  • cargo clippy -p mlxcel-xla --lib --tests --features iree -- -D warnings
  • cargo check -p mlxcel-xla --lib --features iree with the pinned IREE CUDA toolchain
  • local_task_mrope_prefill_decode_and_per_slot_deltas_execute against real IREE
  • Existing local_task_prefill_and_decode_execute token/prepared mixed-slot gate against real IREE

Closes #864

Represent 1D and three-axis prepared positions explicitly across StableHLO and the IREE C ABI. Track signed M-RoPE decode deltas independently per session and batch slot while preserving physical KV offsets and byte-exact 1D modules.
@inureyes inureyes added type:enhancement New features, capabilities, or significant additions priority:medium Medium priority area:architecture Architecture and code structure changes area:inference Generation, sampling, decoding (incl. speculative, DRY) status:review Under review labels Jul 23, 2026
Build text-only position buffers from the runtime position mode so ragged M-RoPE slot prefill always uploads all three axes. Reuse the same contract for single and diagnostic prefill, and exercise text token admission, decode, cancellation, and mixed slot reuse against real IREE.
@inureyes

Copy link
Copy Markdown
Member Author

Addressed the central HIGH finding in 83bd62b.

  • Ragged token prefill now builds positions from the loaded position mode, so an M-RoPE bundle always uploads a row-major [3, context_capacity] buffer instead of exposing a one-axis allocation to the C shim.
  • Single, ragged, and diagnostics token prefill share the same canonical text-position helper; the diagnostics C path now also sizes rank and bytes from the explicit position mode.
  • All other raw position pointers were audited: prepared-prefill descriptors carry validated mode/rank/shape, and single/ragged decode validate their scalar or three-coordinate lengths before FFI.
  • Accepting Sequential or zero-based 1D Explicit positions in an M-RoPE bundle is intentional text-only canonicalization: the same logical coordinate is repeated on temporal/height/width and rope_delta is zero. Multimodal callers must use the explicit Mrope3D variant. This contract is now documented and unit-tested.

Validation:

  • cargo test -p mlxcel-xla --lib --quiet (194 passed, 6 ignored)
  • cargo clippy -p mlxcel-core -p mlxcel-xla --lib --tests -- -D warnings
  • IREE-feature clippy and pinned-IREE C shim compile
  • Real-IREE M-RoPE text token prefill/decode, sequential prepared parity, vision mixed/cancel, and text/positive-delta slot reuse
  • Existing real-IREE 1D token/prepared mixed-slot regression

An explicit mrope rope type previously fell through to the one-dimensional position schema when its section table was missing, silently changing multimodal semantics at load time.

Require mrope_section for the explicit mrope type while preserving Qwen configurations that carry the section table with a default or omitted rope type. Cover the rejected and accepted schema variants in the config parser tests.

Validation: focused M-RoPE config test, full mlxcel-xla library suite, Clippy with warnings denied, formatting, and diff checks.

Refs #864
@inureyes

Copy link
Copy Markdown
Member Author

Addressed the M-RoPE config fail-open gap in fc4ed97:

  • An explicit rope_type: "mrope" now requires mrope_section and returns a config-load error when the table is absent.
  • A present mrope_section remains accepted with rope_type: "default" or an omitted rope type, matching real Qwen-style configuration variants.
  • Regression coverage pins the rejected explicit/incomplete form and both accepted section-bearing forms.

Validation:

  • focused M-RoPE config parser test: 1 passed
  • full mlxcel-xla library suite: 194 passed, 6 ignored
  • mlxcel-xla library/test Clippy with -D warnings: passed
  • cargo fmt --all -- --check: passed
  • git diff --check: clean
  • CSV changes: none

Real-IREE impact review: this commit changes only config loading and its unit test; it does not modify StableHLO emission, the C ABI, VMFB execution, or runtime position state. The existing exact M-RoPE local-task gates use valid section-bearing configs, and the new regression confirms those configs still reach the same typed M-RoPE schema, so the existing real-IREE evidence remains applicable.

@inureyes
inureyes merged commit e739ca1 into main Jul 23, 2026
4 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Jul 23, 2026
@inureyes
inureyes deleted the feature/issue-864-multimodal-rope branch July 23, 2026 22:00
@inureyes inureyes self-assigned this Aug 31, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
* feat(xla): add multimodal RoPE position state

Represent 1D and three-axis prepared positions explicitly across StableHLO and the IREE C ABI. Track signed M-RoPE decode deltas independently per session and batch slot while preserving physical KV offsets and byte-exact 1D modules.

* fix(xla): canonicalize ragged M-RoPE positions

Build text-only position buffers from the runtime position mode so ragged M-RoPE slot prefill always uploads all three axes. Reuse the same contract for single and diagnostic prefill, and exercise text token admission, decode, cancellation, and mixed slot reuse against real IREE.

* fix(xla): reject incomplete explicit M-RoPE configs

An explicit mrope rope type previously fell through to the one-dimensional position schema when its section table was missing, silently changing multimodal semantics at load time.

Require mrope_section for the explicit mrope type while preserving Qwen configurations that carry the section table with a default or omitted rope type. Cover the rejected and accepted schema variants in the config parser tests.

Validation: focused M-RoPE config test, full mlxcel-xla library suite, Clippy with warnings denied, formatting, and diff checks.

Refs lablup#864
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:architecture Architecture and code structure changes area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(xla): support multimodal 3D RoPE positions and decode deltas

1 participant