Skip to content

cleanup: prefer standard ops over com.github.onnxruntime.genai; relocate DSV4 design doc - #429

Merged
justinchuby merged 2 commits into
mainfrom
cleanup/blockquant-standard-expr
Jul 25, 2026
Merged

cleanup: prefer standard ops over com.github.onnxruntime.genai; relocate DSV4 design doc#429
justinchuby merged 2 commits into
mainfrom
cleanup/blockquant-standard-expr

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

Two cleanup tasks on already-merged work.

Task 1 — Remove the com.github.onnxruntime op namespace

Justin's directive: "I don't want ops in the com.github.onnxruntime namespace unless there is NO other way to express it."

Which formats route to BlockQuantizedMatMul? 10 GGUF IQ/MXFP4 formats via BlockQuantizedLinear / _repacker._NATIVE_BLOCK_SPECS: mxfp4, iq4_nl, iq4_xs, iq3_s, iq3_xxs, iq2_xxs, iq2_xs, iq2_s, iq1_s, iq1_m. Integer GGUF formats (Q4_0/Q4_1/Q8_0/Q4_K/Q1_0) already use com.microsoft.MatMulNBits and were never on the custom op.

Can any switch to a standard expression the runtime can execute? No — verified against the nxrt runtime (onnx-genai):

Format(s) Candidate standard expression Runtime-executable?
MXFP4 (E2M1 float4 + E8M0 block scales) DequantizeLinear(FLOAT4E2M1, block_size)MatMul ❌ Runtime CPU DequantizeLinear kernel only dequantizes Int8/Uint8/Int32 — rejects FLOAT4E2M1. Affine MatMulNBits can't represent E2M1 either.
IQ4_NL & other IQ (non-linear codebooks / super-blocks) Gather(codebook) dequant → MatMul ❌ No runtime kernel; affine DequantizeLinear/MatMulNBits cannot express a non-linear codebook.

onnx 1.22 / onnxscript 0.7.1 in this repo can emit FLOAT4E2M1 + block DequantizeLinear, but the runtime cannot run it — so emitting it would produce an unrunnable graph. All 10 formats genuinely have "no other way."

Key finding (also fixes a latent bug): the runtime renamed the domain com.github.onnxruntime.genaipkg.nxrt (onnx-genai commit de99b73e) and now registers the CPU+CUDA kernel only under pkg.nxrt (no alias — normalize_domain only maps ai.onnx""). Mobius still emitted the old name, so current mobius output is unrunnable by the current runtime.

Change: rename the emitted domain com.github.onnxruntime.genaipkg.nxrt (_ONNX_GENAI_DOMAIN_NXRT_DOMAIN) in _quantized_linear.py, repacker docstring, and tests. Added a code comment documenting why the custom op is retained and why it uses pkg.nxrt rather than com.github.onnxruntime. Op attributes/inputs are unchanged and already runtime-compatible (K, N, format, block_layout_version=1; activation fp32, packed uint8 weight, optional fp32 bias).

This both satisfies the directive (no com.github.onnxruntime namespace) and realigns mobius with the runtime's registered domain.

Would a runtime change fully eliminate the custom domain? (Justin decides) To drop even pkg.nxrt, the runtime would need standard-op kernels for (a) block DequantizeLinear with FLOAT4E2M1 input (MXFP4) and (b) a codebook Gather-dequant path (IQ formats) + MatMul fusion. Not done here — this is a coordinated runtime change out of scope for a mobius-only cleanup.

Task 2 — Relocate stray root design doc

Moved DSV4_FLASH_EXPORT.mddocs/design/deepseek-v4-flash-export.md (repo convention) and added it to docs/design/index.md.

Validation

  • lintrunner --all-filesclean
  • pytest -n auto -m 'not integration and not arch_validation' --cov=src4813 passed, 338 skipped, 62 xfailed
  • Targeted: _quantized_linear_test.py, integrations/gguf/_builder_test.py, _repacker_test.py all pass and assert the new pkg.nxrt domain.

⚠️ Please do not merge — Justin merges new mobius PRs himself.

…ate DSV4 design doc

Remove the com.github.onnxruntime custom op namespace per Justin's directive
("no ops in com.github.onnxruntime unless there is no other way to express it").

Investigation: the 10 GGUF IQ/MXFP4 formats routed to BlockQuantizedMatMul
(mxfp4, iq4_nl, iq4_xs, iq3_s, iq3_xxs, iq2_xxs, iq2_xs, iq2_s, iq1_s, iq1_m)
genuinely have no standard-op expression the onnx-genai (nxrt) runtime can
execute: MXFP4 is E2M1 float4 (the runtime DequantizeLinear kernel only handles
Int8/Uint8/Int32, not FLOAT4E2M1) and the IQ families use non-linear codebooks
/ super-block layouts, neither representable by affine MatMulNBits. Integer GGUF
formats already use com.microsoft.MatMulNBits and were never on the custom op.

So the custom op is retained, but no longer in the forbidden namespace: the
runtime renamed its domain com.github.onnxruntime.genai -> pkg.nxrt (onnx-genai
commit de99b73e) and now registers the kernel only under pkg.nxrt. Mobius still
emitted the old name, producing graphs the current runtime cannot run. This
switches the emitted domain to pkg.nxrt, both satisfying the directive and
fixing the domain mismatch. Attributes/inputs are unchanged and already
runtime-compatible.

Also relocate the stray root-level DSV4_FLASH_EXPORT.md into docs/design/
per repo convention and add it to the design index.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 6ebe8eeb0dbf81

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 60 60 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 68 68 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 107 107 +0.0%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 62 62 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 58 58 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 98 98 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 60 60 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 56 56 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 62 62 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 58 58 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 166 166 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs two cleanup tasks in mobius: (1) it removes usage of the com.github.onnxruntime.* op namespace by updating the BlockQuantizedMatMul custom-op domain to the runtime-registered pkg.nxrt, and (2) it relocates the DeepSeek-V4-Flash export design document into the docs design area and wires it into the design index.

Changes:

  • Update the emitted custom-op domain for BlockQuantizedMatMul from com.github.onnxruntime.genai to pkg.nxrt, including an explanatory comment and updated opset import handling.
  • Update GGUF and component tests to assert the new pkg.nxrt domain/opset import.
  • Add the relocated DeepSeek-V4-Flash export design doc under docs/design/ and include it in docs/design/index.md.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/mobius/integrations/gguf/_repacker.py Updates docstring to reference pkg.nxrt.BlockQuantizedMatMul.
src/mobius/integrations/gguf/_builder_test.py Updates assertions for BlockQuantizedMatMul node domain/opset import to pkg.nxrt.
src/mobius/components/_quantized_linear.py Renames the nxrt custom-op domain constant and switches emission/opset imports to pkg.nxrt with rationale.
src/mobius/components/_quantized_linear_test.py Updates contract test to assert pkg.nxrt domain/opset import.
docs/design/index.md Adds deepseek-v4-flash-export to the design toctree.
docs/design/deepseek-v4-flash-export.md Adds the relocated DeepSeek-V4-Flash export design document.

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 6ebe8eeb0dbf81

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

…nces

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 25, 2026 04:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

@justinchuby
justinchuby merged commit 58c7472 into main Jul 25, 2026
22 of 24 checks passed
@justinchuby
justinchuby deleted the cleanup/blockquant-standard-expr branch July 25, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants