Refactor data type handling and fix convolution bias initialization - #10
Conversation
…zation in convolution
…or compatibility with serializer
Performance Comparison
|
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
There was a problem hiding this comment.
Pull request overview
This PR improves dtype consistency for mixed-precision execution (notably float16) by ensuring scalar constants are cast to the same dtype as their operand tensors, and fixes an ONNX ir.Function configuration detail that can break function-node matching during serialization.
Changes:
- Removed the
overloadfield from theCausalConv1DWithStateir.Functiondefinition to avoid serialization mismatches with call sites. - Cast scalar constants via
op.CastLikein Gated DeltaNet (conv bias, attention scale, L2-norm epsilon) to match operand dtypes. - Updated the Qwen3.5 text-generation example to build the text-only model in
f16by default.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/mobius/functions/causal_conv.py |
Removes function overload to ensure ONNX serializer can match nodes to the function definition. |
src/mobius/components/_gated_deltanet.py |
Uses CastLike on scalar constants to keep computations dtype-consistent under mixed precision. |
examples/qwen35_text_generation.py |
Switches default dtype for the text-only example build from f32 to f16. |
You can also share your feedback on Copilot code review. Take the survey.
|
For some reason I still get |
- #8: Add comment in registry noting Fun-ASR requires build_from_module() with manual config (config.yaml, not auto-detected by build()) - #10: Document audio_token_id=0 collision in embedding model docstring, advising callers to bypass for decode steps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
- #8: Add comment in registry noting Fun-ASR requires build_from_module() with manual config (config.yaml, not auto-detected by build()) - #10: Document audio_token_id=0 collision in embedding model docstring, advising callers to bypass for decode steps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
- #8: Add comment in registry noting Fun-ASR requires build_from_module() with manual config (config.yaml, not auto-detected by build()) - #10: Document audio_token_id=0 collision in embedding model docstring, advising callers to bypass for decode steps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
- #8: Add comment in registry noting Fun-ASR requires build_from_module() with manual config (config.yaml, not auto-detected by build()) - #10: Document audio_token_id=0 collision in embedding model docstring, advising callers to bypass for decode steps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
This pull request primarily focuses on improving numerical stability and dtype consistency in the codebase, particularly for operations involving mixed-precision (such as
float16). The changes ensure that constants used in computations match the data types of the operands, which helps prevent potential issues during inference or training. Additionally, there is a small fix to avoid setting function overloads that could interfere with serialization.Improvements for dtype consistency and numerical stability:
op.CastLike, ensuring they match the dtype of associated tensors (e.g.,float16). This affects the bias in convolution, scaling in attention, and epsilon in normalization.Model and function configuration updates:
overloadattribute from their.Functiondefinition incausal_conv1d_with_stateto prevent issues with node-function matching during serialization.