Commit ae7691b
fix(cpu-ops): lazy transpose for Q4_0 too; cover all packed matmul dtypes
Follow-up to #736 (Q8_0). The transpose lazy-rewrap `when` was still missing
Q4_0 — a packed type chooseQuantizedMatmulHeap dispatches — so a packed Q4_0
matmul weight through linearProject (matmul(x, transpose(W))) hit the generic
FP32 path and threw `Byte cannot be cast to Float`. Add the Q4_0 case so the
`when` now covers EVERY packed type that can be a matmul weight
(Q4_K/Q5_K/Q6_K/Q5_0/Q5_1/Q8_0/Q4_0).
Adds `transpose_preserves_every_packed_quant_type` to PackedMatmulDispatchTest:
transposes a 2-D tensor of each of the 7 packed types and asserts the shape
flips and the packed encoding is preserved (no FP32 fallback / no crash).
Content-agnostic, runs on every platform (jvm + linuxX64).
See SKaiNET-transformers#178.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent cd2bfd2 commit ae7691b
2 files changed
Lines changed: 49 additions & 4 deletions
File tree
- skainet-backends/skainet-backend-cpu/src
- commonMain/kotlin/sk/ainet/exec/tensor/ops
- commonTest/kotlin/sk/ainet/exec/tensor/ops
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
607 | 608 | | |
608 | 609 | | |
609 | 610 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
613 | 614 | | |
614 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
615 | 618 | | |
| 619 | + | |
616 | 620 | | |
617 | 621 | | |
618 | 622 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
| 14 | + | |
11 | 15 | | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
132 | 173 | | |
0 commit comments