Repository navigation
Commit bd666bc
fix(models): stack per-expert GPTQ/AWQ MoE experts into fused QMoE (#513)
Per-expert GPTQ/AWQ MoE checkpoints (e.g. Qwen1.5-MoE-A2.7B-GPTQ-Int4)
store every routed expert as a separate module, so the generic MoE models
(MoECausalLMModel, Qwen2MoECausalLMModel, Ernie45MoECausalLMModel,
Glm4MoECausalLMModel) emitted an unfused graph: per-expert MatMulNBits +
Equal masking with empty fc1/fc2 QMoE initializers. The runtime then
computes every expert each token.
The native QMoE packer (pack_qmoe_expert_weights) expects the fused
expert-major tensors that Olive emits, which per-expert checkpoints do not
provide. Add stack_per_expert_moe_weights to bridge the two: after the
MatMulNBits reshape, concatenate each expert's gate/up projections in
HF-concatenated [gate; up] order and stack all experts into a new leading
dim, producing the fused gate_up_proj / down_proj tensors the packer
consumes. Wire the generic MoE models through preprocess_quantized_weights
with qmoe_target_path=".mlp" so the stacking + packing runs.
Result on Qwen1.5-MoE-A2.7B-GPTQ-Int4 (measured, RTX 4060): the graph now
emits 24 fused com.microsoft::QMoE nodes (one per layer), 0 Equal ops, and
populated fc1/fc2 expert weights (fc1 [60, 2816, 1024]). Numerically
equivalent to the dense per-expert reference: identical argmax and top-5,
max abs first-step logit diff 0.072 over 151,936 logits (fp32 A/B on CUDA,
same weights) — consistent with fused-SwiGLU FP accumulation order, not a
wrong expert mapping.
Symmetric GPTQ (sym=True) drops zero-points on both the dense and QMoE
paths (implicit zp=8), so no zero-point transport is added; asymmetric
transport remains out of scope.
Co-authored-by: Copilot <[email protected]>1 parent 4dbab45 commit bd666bc
3 files changed
Lines changed: 258 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
624 | 706 | | |
625 | 707 | | |
626 | 708 | | |
| |||
1096 | 1178 | | |
1097 | 1179 | | |
1098 | 1180 | | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1099 | 1184 | | |
1100 | 1185 | | |
1101 | 1186 | | |
| |||
1109 | 1194 | | |
1110 | 1195 | | |
1111 | 1196 | | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1112 | 1200 | | |
1113 | 1201 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
979 | 980 | | |
980 | 981 | | |
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 | + | |
982 | 1025 | | |
983 | 1026 | | |
984 | 1027 | | |
| |||
1251 | 1294 | | |
1252 | 1295 | | |
1253 | 1296 | | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
55 | 78 | | |
56 | 79 | | |
57 | 80 | | |
| |||
287 | 310 | | |
288 | 311 | | |
289 | 312 | | |
290 | | - | |
| 313 | + | |
291 | 314 | | |
292 | 315 | | |
293 | 316 | | |
| |||
392 | 415 | | |
393 | 416 | | |
394 | 417 | | |
395 | | - | |
| 418 | + | |
396 | 419 | | |
397 | 420 | | |
398 | 421 | | |
| |||
417 | 440 | | |
418 | 441 | | |
419 | 442 | | |
420 | | - | |
421 | | - | |
422 | | - | |
| 443 | + | |
423 | 444 | | |
424 | 445 | | |
425 | 446 | | |
| |||
487 | 508 | | |
488 | 509 | | |
489 | 510 | | |
490 | | - | |
| 511 | + | |
491 | 512 | | |
492 | 513 | | |
493 | 514 | | |
| |||
522 | 543 | | |
523 | 544 | | |
524 | 545 | | |
525 | | - | |
| 546 | + | |
526 | 547 | | |
527 | 548 | | |
528 | 549 | | |
| |||
0 commit comments