Commit 39bb8f1
fix(redmule): lower bias-less Gemm to MatMul so CCT_train tiling stops crashing
The Siracusa+RedMulE CCT_train CI job (added in b682739) crashed during
tiling with KeyError 'C' inside RedmuleGEMMTileConstraint -- the constraint
unconditionally reads parseDict['C'] but GEMMRedmuleParser.parseNodeCtxt
only populates it when len(node.inputs) == 3 and noBiasHoisting is True
(the default). Backward-pass codegen for CCT (GradFusedMatMul rewrites)
emits a flurry of 2-input ONNX Gemm nodes (alpha=1, no bias), which match
the binding but never get a 'C' field -- hence the lookup blows up.
A bias-less Gemm with alpha=1 is mathematically just MatMul, and the
Redmule platform already routes ONNX MatMul through
MatMulRedmuleMapper / RedmuleMatMulTilingReadyBindings (no C operand
needed). So instead of papering over the parser, lower the op:
- Add RedMuleBiaslessGemmToMatMulPass in
Targets/Redmule/TopologyOptimizationPasses/Passes.py. It matches Gemm
nodes (the 2-input pattern reused from RedMuleGEMMTransposePass),
guards on len(inputs) == 2 and alpha == 1, materializes any
transA/transB (constants get folded, variables get a Transpose
appended via the same _appendTranspose helper the transpose pass
already uses), then rewrites op="MatMul" and clears attrs.
- Wire it into RedmuleDeployer.loweringOptimizer.passes BEFORE
RedMuleGEMMTransposePass so the latter only ever sees real (3-input)
Gemms; otherwise it would write transA/transB=0 onto what we just
rewrote into a MatMul, and the stale Gemm op would still hit the
bias-required tile constraint.
3-input Gemms (forward CCT FCs, the existing testFloatGEMM/testFloatGEMMtransB
kernel fixtures) are untouched: the new pass returns the graph
unchanged when len(inputs) != 2, and RedMuleGEMMTransposePass continues
to see them as before.
Local validation: pytest --collect-only -m "siracusa_redmule_tiled"
still yields the same 4 cases (3 kernel + 1 training); module import
of Deployer + the new pass class both succeed. Real run deferred to CI.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b682739 commit 39bb8f1
2 files changed
Lines changed: 86 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
0 commit comments