Repository navigation
Commit 79b48bc
Add GLM-ASR Nano speech-language support (#509)
## Summary
- Add complete `glmasr` support for `zai-org/GLM-ASR-Nano-2512` as
standardized `audio_encoder` → `embedding` → cached `decoder` ONNX
models.
- Implement the convolutional 32-layer bidirectional partial-RoPE audio
tower, config-driven audio/projector activations, four-frame projector,
audio-token embedding replacement, and 28-layer Llama-like decoder with
dynamic KV cache.
- Add exact checkpoint weight alignment, registry/config/task exports,
ONNX GenAI metadata, immutable CLI `--revision` propagation, and
documentation metadata.
- Add a pinned real nonzero speech fixture plus exact L4 prefill and L5
transcript/token goldens.
## Immutable inputs
- Model:
`zai-org/GLM-ASR-Nano-2512@61ba4e0b3309b6656edea3e93e419f7bd5c61957`
- Audio: `eustlb/audio-samples@1045238c3afdc0254472ecdde5dae95370d621e4`
- All config, weight, tokenizer, processor, metadata, golden-generation,
and test Hub calls carry the immutable revision.
## Architecture checklist
- [x] Nested GLM-ASR text/audio config extraction
- [x] Registry and default speech-language task wiring
- [x] Standardized `audio_encoder`, `embedding`, and `decoder` package
keys
- [x] Whisper feature-extractor contract: float32 `[B,128,3000]`, 16
kHz, FFT 400, hop 160
- [x] 20-head bidirectional audio Attention with 32/64 partial RoPE,
asymmetric Q/V/O biases, and one output (no unused present KV)
- [x] Config-driven audio MLP and projector activations
- [x] Four-frame `5120 → 4096 → 2048` projector
- [x] Exact audio-placeholder replacement and valid projected-feature
stripping inside ONNX
- [x] Llama decoder with 16 query heads, 4 KV heads, full RoPE, and
cached decode
- [x] All 745 checkpoint parameter names aligned after preprocessing
- [x] ONNX GenAI speech-language metadata includes the pinned audio
processor
## Validation evidence
### L1–L3 and regression gates
- GLM-ASR graph/config/parity and rebase regression suite: **46 passed**
- ORT GenAI compatibility guard tests: **2 passed**
- Complete CLI suite: **37 passed**
- Synthetic FP32 HF/ONNX parity executes the complete audio → embedding
→ decoder pipeline and compares every stage, including short-audio
zero-token behavior.
- Standard non-integration gate: **4051 passed, 58 skipped, 10
deselected**. Five unrelated environment-sensitive failures remain in
GGUF Q4 dequantization, Qwen Image CUDA tolerance, and softcap
Attention-decomposition parity; none overlap this change set or the
required CI failures previously reported.
### L4 CUDA prefill (rebased head)
```powershell
$env:MOBIUS_TEST_DEVICE='cuda'
python -m pytest tests/e2e_golden_test.py -m golden --models glmasr -v --timeout=300 --tb=short
```
- **1 passed, 240 skipped, 161 deselected in 166.73s**
- Real pinned speech, 138 projected audio tokens, 153-token prompt.
- FP16 full-logit reference comparison: shape `[1,153,59264]`,
correlation `0.9991001`, mean absolute difference `0.02795`, maximum
absolute difference `7.456`; greedy token matches.
### L5 CUDA cached generation (rebased head)
```powershell
$env:MOBIUS_TEST_DEVICE='cuda'
python -m pytest tests/e2e_golden_test.py -m generation --models glmasr -v --timeout=300 --tb=short
```
- **1 passed, 156 skipped, 245 deselected in 238.19s**
- Exact 23-token sequence and exact decoded transcript asserted:
- `Yesterday it was thirty five degrees in Barcelona, but today the
temperature will go down to minus twenty degrees.`
### CLI export and CUDA execution
```powershell
python -m mobius build --model zai-org/GLM-ASR-Nano-2512 <output> \
--revision 61ba4e0b3309b6656edea3e93e419f7bd5c61957 \
--ep cuda --dtype f16
```
- Direct three-model ONNX export and saved-file CUDA execution pass:
- audio `(138, 2048)`
- embeddings `(1, 153, 2048)`
- logits `(1, 153, 59264)`
- prefill top-1 token `89`
- The staged test harness now destroys each ORT session before loading
the next component. This fixes the old CI `BFCArena` initialization OOM
(`242745344`-byte decoder allocation) and returns CUDA memory to
baseline between stages.
### Formatting and review
- `lintrunner -a`: **passed**
- Final specialist re-review: **no high-confidence findings**
- All inline review threads are addressed and resolved.
## Waivers and runtime constraints
- **FP32:** complete synthetic stage-by-stage semantic parity passes at
`rtol=2e-4`, `atol=2e-4` for decoder logits and tighter tolerances for
earlier stages. A full real FP32 CUDA checkpoint run is not practical on
the available 8 GB RTX A1000.
- **FP16:** full real-checkpoint CUDA L4/L5 and saved CLI artifact
execution pass as documented above.
- **BF16:** the weighted package builds and loads on CUDA. ORT 1.26
Python's NumPy API cannot materialize BF16 outputs (`No corresponding
Numpy type for Tensor Type. bfloat16`), so executable L4/L5 uses FP16;
BF16 output validation requires I/O binding or a runtime with BF16 host
materialization.
- **GQA fusion:** CUDA FP16 `GroupQueryAttention` changed greedy
termination from the exact 23-token HF sequence to an earlier valid EOS
at 21 tokens. GLM-ASR intentionally preserves standard opset-24
`Attention` for exact transcript parity; graph coverage locks this
dispatch decision.
- **ORT GenAI:** onnxruntime-genai 0.15.2 registers multimodal model
types only for `gemma4` and `phi4mm`; loading `type: glmasr` fails as
unsupported. Mobius now rejects `--runtime ort-genai` before saving
rather than emitting unloadable metadata. Direct ONNX and ONNX GenAI
metadata remain supported; native ORT GenAI packaging is deferred until
the runtime registers a compatible GLM-ASR pipeline.
- **Memcpy:** ORT reports small control-tensor Memcpy nodes from dynamic
shape/index operations (`NonZero`, integer `CumSum`, and placeholder
indexing). Eliminating them would require changing the
feature-stripping/embedding contract.
---------
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent <[email protected]>
Co-authored-by: justinchuby <[email protected]>1 parent b2b8213 commit 79b48bc
33 files changed
Lines changed: 1856 additions & 93 deletions
File tree
- docs
- scripts
- src/mobius
- _configs
- per_model
- _testing
- integrations
- diffusers
- onnx_genai
- ort_genai
- models
- tasks
- testdata
- cases
- speech
- golden/speech
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
707 | | - | |
| 707 | + | |
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| |||
800 | 800 | | |
801 | 801 | | |
802 | 802 | | |
803 | | - | |
| 803 | + | |
| 804 | + | |
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
| |||
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
859 | | - | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
860 | 863 | | |
861 | 864 | | |
862 | 865 | | |
| |||
867 | 870 | | |
868 | 871 | | |
869 | 872 | | |
870 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
871 | 877 | | |
872 | 878 | | |
873 | 879 | | |
874 | | - | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
875 | 883 | | |
876 | 884 | | |
877 | 885 | | |
878 | 886 | | |
879 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
880 | 890 | | |
881 | 891 | | |
882 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
883 | 917 | | |
884 | 918 | | |
885 | 919 | | |
| |||
913 | 947 | | |
914 | 948 | | |
915 | 949 | | |
| 950 | + | |
916 | 951 | | |
917 | | - | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
918 | 961 | | |
919 | 962 | | |
920 | 963 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
445 | 448 | | |
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
449 | 452 | | |
450 | 453 | | |
451 | 454 | | |
| 455 | + | |
452 | 456 | | |
453 | 457 | | |
454 | 458 | | |
455 | 459 | | |
456 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
457 | 467 | | |
458 | 468 | | |
459 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2787 | 2787 | | |
2788 | 2788 | | |
2789 | 2789 | | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
2790 | 2818 | | |
2791 | 2819 | | |
2792 | 2820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
229 | 234 | | |
230 | 235 | | |
231 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
754 | 755 | | |
755 | 756 | | |
756 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
757 | 814 | | |
758 | 815 | | |
759 | 816 | | |
| |||
0 commit comments