onnx: handle com.microsoft RotaryEmbedding contrib op#2284
Open
czoli1976 wants to merge 2 commits into
Open
Conversation
…ion, RotaryEmbedding op handlers Import handlers for four standardized ai.onnx operators, lowering to existing tract primitives: - LpNormalization (opset 1), MeanVarianceNormalization (opset 13) - GroupNormalization (opset 18 & 21; opset-aware affine, f32 stash_type) - RotaryEmbedding (opset 23; 3D/4D input, position_ids, partial + interleaved) Corresponding ONNX backend node tests enabled in suite-onnx/node.txt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
com.microsoft.RotaryEmbedding is identical math to the standardized ai.onnx op but orders its inputs (input, position_ids, cos, sin). tract resolves ops by name regardless of domain, so make the single handler domain-aware and remap inputs accordingly. Rejects the contrib-only scale != 1.0 and is_packed_batching attributes with clear errors. Verified bit-exact against onnxruntime (3D, 4D, interleaved); ai.onnx RotaryEmbedding conformance unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
kali
approved these changes
May 26, 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.
Summary
Adds support for the
com.microsoft.RotaryEmbeddingcontrib op (emitted by ONNX Runtime / GenAI / Olive LLM exports). It is identical math to the standardizedai.onnx.RotaryEmbeddingbut orders its inputs(input, position_ids, cos, sin). Since tract resolves operators by name regardless of domain, the existingRotaryEmbeddinghandler is made domain-aware and remaps inputs accordingly. The contrib-onlyscale != 1.0andis_packed_batchingattributes are rejected with clear errors.Validation
ai.onnxRotaryEmbedding conformance unchanged (32/32, both runtimes).com.microsoft==ai.onnxmath + input reorder (ORT vs ONNX ReferenceEvaluator, bit-exact for default and interleaved).Note — stacked on #2283
This branches off #2283 (the
ai.onnxop handlers), which introducesrotary_embedding.rs. The only new commit here is the com.microsoft handler; the first commit is shared with #2283 and will drop out of this diff once #2283 merges. Happy to rebase ontomainafter #2283 lands.