Repository navigation
Simplify LinearAttention to single 6-input signature - #226
Merged
Merged
Conversation
Now that onnx-shape-inference >=0.1.9 accepts trailing optional inputs (matching ONNX C++ behavior), we no longer need per-variant arity specialization for LinearAttention. Changes: - Bump onnx-shape-inference minimum to >=0.1.9 - Declare all 6 inputs (query, key, value, past_state, decay, beta) unconditionally, using None for unused trailing inputs - Replace *args unpacking with named parameters in the body function - Remove the TODO about onnx-shape-inference strict arity check Call sites that omit trailing inputs (e.g. Mamba2Block with 'gated' update_rule passing only 5 inputs) now work correctly without needing a specialized function with fewer formal parameters. Co-authored-by: Copilot <[email protected]> Signed-off-by: G Ramalingam <[email protected]>
Performance Comparison
|
|
The author of this PR, gramalingam, is not an activated member of this organization on Codecov. |
Contributor
There was a problem hiding this comment.
Pull request overview
Simplifies the LinearAttention ONNX function signature now that onnx-shape-inference supports trailing optional inputs, aiming to avoid per-variant arity specialization.
Changes:
- Bump
onnx-shape-inferenceminimum version to>=0.1.9. - Refactor
LinearAttentionfunction input handling toward a single 6-input signature. - Replace
*argsparsing in the function body with named parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/mobius/functions/linear_attention.py | Adjusts function input declaration and body signature for LinearAttention. |
| pyproject.toml | Updates dependency floor for onnx-shape-inference. |
justinchuby
approved these changes
Apr 29, 2026
Address review comment: declare decay and beta as ir.Value unconditionally so the ir.Function signature is truly fixed at 6 inputs regardless of update_rule. The body's conditional logic simply ignores unused trailing inputs. Co-authored-by: Copilot <[email protected]> Signed-off-by: G Ramalingam <[email protected]>
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.
Now that onnx-shape-inference >=0.1.9 accepts trailing optional inputs (matching ONNX C++ behavior), we no longer need per-variant arity specialization for LinearAttention.
Changes:
Call sites that omit trailing inputs (e.g. Mamba2Block with 'gated' update_rule passing only 5 inputs) now work correctly without needing a specialized function with fewer formal parameters.