Repository navigation
Commit 087e15f
Fix DeepSeek MoE routed experts losing linear_class quantization
_DeepSeekMoEFFN.__init__ threaded linear_class into _SharedExpertMLP
but not into the MoELayer that builds the routed-expert dense-loop
fallback. A quantized config therefore quantized attention, dense FFN,
and the shared expert, but silently left every routed MoE expert's
gate/up/down projections as plain float MatMul -- losing quantization
and breaking the fuse_dense_moe_to_qmoe post-hoc rewrite, which only
pattern-matches a quantized MatMulNBits dense-fallback shape.
Fix: pass linear_class through to MoELayer's routed-expert
construction (one line). DeepSeek-V4's MoE FFN is unaffected -- it
recomputes its own quantized class per-expert independently of
MoELayer's linear_class and was already correct.
Added test_deepseek_moe_ffn_linear_class_reaches_routed_experts,
which isolates and asserts on module.moe.experts vs
module.shared_experts separately (not just an aggregate creation
count) so the regression is caught precisely. Verified: fails on
pre-fix code, passes post-fix. Full suite (3249 passed, 9 skipped)
and ruff check/format clean.
Co-authored-by: Copilot <[email protected]>1 parent bed2983 commit 087e15f
2 files changed
Lines changed: 59 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
100 | 151 | | |
101 | 152 | | |
102 | 153 | | |
| |||
0 commit comments