Migrate op_multi_out to __getattr__ dispatch with _outputs - #294
Conversation
Performance Comparison
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This pull request updates Mobius’ ONNX rewrite rules to stop using the soon-to-be-removed op.op_multi_out() helper by switching to standard OpBuilder.__getattr__ dispatch with _outputs=N. In addition, it introduces and registers a new hy_v3 (Hy3-preview) MoE causal LM and extends HuggingFace config-field alias handling to support that model family.
Changes:
- Migrated custom-op multi-output calls in rewrite rules from
op.op_multi_out(...)toop.<OpName>(..., _domain=..., _outputs=N, **attrs). - Added
Hy3CausalLMModelimplementation and registeredhy_v3in the model registry and test config set. - Extended
ArchitectureConfig.from_transformers()to recognize additional HF config aliases (e.g.,qk_norm,router_scaling_factor,moe_router_use_sigmoid,num_shared_experts).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/_test_configs.py | Adds a tiny hy_v3 config entry for coverage in graph-building tests. |
| src/mobius/rewrite_rules/_unpack_qkv.py | Replaces op_multi_out usage with _domain/_outputs dispatch for GroupQueryAttention. |
| src/mobius/rewrite_rules/_skip_norm.py | Replaces op_multi_out usage for SkipSimplifiedLayerNormalization with _outputs. |
| src/mobius/rewrite_rules/_skip_layer_norm.py | Replaces op_multi_out usage for SkipLayerNormalization with _outputs. |
| src/mobius/rewrite_rules/_separate_rope.py | Replaces op_multi_out usage for GroupQueryAttention with _outputs. |
| src/mobius/rewrite_rules/_group_query_attention.py | Replaces multiple GroupQueryAttention op_multi_out calls with _domain/_outputs dispatch. |
| src/mobius/models/hy_v3.py | Adds the Hy3-preview model implementation and weight remapping/splitting logic. |
| src/mobius/models/init.py | Exports/imports Hy3CausalLMModel from the models package. |
| src/mobius/_registry.py | Registers hy_v3 for fallback detection and default model ID mapping. |
| src/mobius/_configs.py | Adds HF config alias support for qk-norm and MoE routing/shared-expert fields. |
|
Thanks for the PR! The Required before merge:
Recommended (this PR or follow-up):
Cosmetic:
Positive note: The |
Replace all 9 op.op_multi_out() calls across 5 rewrite rule files
with the standard __getattr__ dispatch pattern:
op.op_multi_out('OpName', inputs=[a, b], domain='com.microsoft',
attributes=attrs, num_outputs=N)
→
op.OpName(a, b, _domain='com.microsoft', _outputs=N, **attrs)
This prepares for the upcoming removal of op_multi_out from
onnxscript/onnx_ir. The __getattr__ dispatch on Builder handles
_outputs internally and will be updated to not depend on
op_multi_out.
Files changed:
- _group_query_attention.py (4 calls)
- _skip_layer_norm.py (2 calls)
- _skip_norm.py (1 call)
- _unpack_qkv.py (1 call)
- _separate_rope.py (1 call)
All 2718 tests pass. Verified GQA/SkipNorm/RoPE rewrite rules
produce correct output on Qwen2.5-0.5B with CUDA EP.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>
4e9bdf4 to
a6178f2
Compare
|
@titaiwangms hy_v3 removed and isolated to another PR. Thanks |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
Problem
op.op_multi_out()is being removed from onnxscript/onnx_ir. 9 call sites across 5 rewrite rule files use this API.Fix
Replace all
op.op_multi_out()calls with the standard__getattr__dispatch pattern using_outputs=N:Files Changed (5 files, 9 calls)
_group_query_attention.py: 4 calls_skip_layer_norm.py: 2 calls_skip_norm.py: 1 call_unpack_qkv.py: 1 call_separate_rope.py: 1 callTesting