Repository navigation
Commit 2481e3c
Fix Qwen3.5/3.6-MoE VL decoder QMoE quantization support (#511)
## Summary
`Qwen35MoEVL3ModelCausalLMModel.preprocess_weights` (the 3-model-split
vision-language wrapper for Qwen3.5/3.6-MoE) previously had **zero
quantization awareness**, unlike its text-only sibling
`Qwen35MoECausalLMModel`. An Olive-quantized VL checkpoint would be
silently mishandled: quantized MoE expert weights would be routed as if
float, producing a broken/incomplete ONNX export with no error raised.
This is one of the pieces needed to support end-to-end quantized export
of `Qwen/Qwen3.6-35B-A3B` (256-expert MoE VL model) via `MobiusBuilder`,
alongside microsoft/Olive#2628 and microsoft/Olive#2457.
## Changes
- `use_qmoe` detection (via `_supported_qmoe_quantization`), mirroring
the text-only sibling.
- A guard that raises a clear `ValueError` when packed-but-unsupported
quantized expert weights are found, instead of silently falling back to
the (incompatible) dense per-expert path.
- `preprocess_olive_weights` + `pack_qmoe_expert_weights` calls to
rename and pack Olive-quantized decoder MoE expert weights into the
native QMoE ONNX parameter layout (`target_moe_path=".mlp"`, matching
the text-only sibling's `Qwen35MoEBlock` placement).
- Explicit `NotImplementedError` guards for:
- `quant_method` in `{"gptq", "awq"}` — not yet supported by this VL
wrapper (only Olive-quantized checkpoints are handled today).
- `quantize_embeddings` / `quantize_lm_head` — no quantized
`Embedding`/`Linear` module variants are wired up anywhere in this
3-model split, so these flags previously produced orphaned initializers
with no error.
Both guards fail loudly instead of silently producing a broken export.
- Honors `quantization.tie_word_embeddings` (not just
`config.tie_word_embeddings`) when deciding whether to duplicate
`lm_head` from `embed_tokens`, for internal consistency with the
recovered "effective tie" value.
## Tests
New `TestQwen35MoEVL3ModelQMoEExport` class covering:
- QMoE packing/binding (Olive-quantized)
- Dense fallback (unquantized)
- Unsupported-ABI guard (packed-but-non-QMoE quantization)
- Vision/embedding/MTP-routing preservation (unaffected by decoder
quantization)
- GPTQ/AWQ rejection (clear error)
- Quantized-embeddings/lm_head rejection (clear error)
```
python -m pytest src/mobius/models/qwen35_test.py -v
10 passed
```
Full model suite: `python -m pytest src/mobius/models/ -q` → 401 passed,
3 pre-existing unrelated failures (confirmed present on clean `main`:
`deepseek_v4_flash_test.py::test_ort_genai_sidecar_metadata`,
`qwen_image_test.py::test_cuda_matches_cpu`,
`world_model_test.py::test_mlp_world_model_matches_pytorch`).
`ruff check` / `ruff format --check`: clean.
## Review
This change went through a full internal review pass (readability,
correctness, adversarial/critical, spec-adherence, and cross-module
integration review, plus independent test execution) before being
opened. Findings from that review (GPTQ/AWQ gap, quantized-embedding
binding gap) are addressed via the explicit guards above rather than
full implementations, since neither is needed by the current
Olive→Mobius pipeline for Qwen3.6-35B-A3B.
---------
Co-authored-by: Copilot <[email protected]>
Copilot-Session: e10674c1-6909-4b09-9f5a-d41b28c89d2d1 parent 5589243 commit 2481e3c
6 files changed
Lines changed: 727 additions & 132 deletions
File tree
- src/mobius
- components
- models
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
26 | 53 | | |
27 | 54 | | |
28 | 55 | | |
| |||
431 | 458 | | |
432 | 459 | | |
433 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
434 | 466 | | |
435 | 467 | | |
436 | 468 | | |
| |||
713 | 745 | | |
714 | 746 | | |
715 | 747 | | |
| 748 | + | |
| 749 | + | |
716 | 750 | | |
717 | 751 | | |
718 | 752 | | |
| |||
753 | 787 | | |
754 | 788 | | |
755 | 789 | | |
| 790 | + | |
| 791 | + | |
756 | 792 | | |
757 | 793 | | |
758 | 794 | | |
| |||
849 | 885 | | |
850 | 886 | | |
851 | 887 | | |
852 | | - | |
853 | | - | |
| 888 | + | |
| 889 | + | |
854 | 890 | | |
855 | | - | |
| 891 | + | |
856 | 892 | | |
857 | 893 | | |
858 | 894 | | |
| |||
917 | 953 | | |
918 | 954 | | |
919 | 955 | | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
760 | 762 | | |
761 | 763 | | |
762 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
763 | 778 | | |
764 | 779 | | |
765 | 780 | | |
| |||
924 | 939 | | |
925 | 940 | | |
926 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
927 | 1046 | | |
928 | 1047 | | |
929 | 1048 | | |
| |||
0 commit comments