Commit d71964c
cpu: x64: matmul: restrict K-collapse to int8 and bound load concurrency
The K-collapse in set_blocking_parameters (32909e9) keeps C resident in
the AMX tiles across the whole K reduction, saving the per-chunk C read-
modify-write. Cold-weight A/B on GNR (int8, M=64) shows this saving is a net
win for most shapes but can regress at large reduction depth: collapsing
serializes the cold B-tile loads into one call, so the out-of-order engine
can no longer overlap that DRAM latency the way the chunked baseline does
with its separate brgemm calls.
The exposed cost scales with the aggregate concurrent memory demand, which
is the reduction depth times the number of threads streaming B at once
(nthr_ * k_tiles_full). A cold sweep over K and thread count shows the
win/regress boundary tracks this product: at 32 threads the crossover is
k_tiles_full == 96, and it moves proportionally with fewer threads (deep
reductions that regress at 32 threads win at 8-24). VTune confirms the
mechanism on the regressing case -- collapse eliminates the C read-modify-
write (Store-Bound 2.0%->0.2%) but raises Memory-Bound via lost memory-level
parallelism (DRAM 27%->36%, CPI 6.8->10.3); Front-End Bound stays <1%, so
the deeper unroll itself is not the cost.
Replace the fixed reduction-depth cap with a load-concurrency cap
(nthr_ * k_tiles_full <= 32 * 96) alongside the existing tmul-count cap,
which alone does not catch the regressors at M=64 (c_tiles == 8 keeps
tmuls == 896 < 1024 even at deep K; M>=128 has c_tiles >= 16 and is already
excluded). Also restrict the collapse to int8, where it was calibrated. The
new cap reduces exactly to the prior k_tiles_full <= 96 at 32 threads, so
behavior in that regime is unchanged, while recovering the deep-K wins at
lower thread counts. Validated cold across N and thread counts (wins hold at
all tested N for nthr <= 24, behavior identical to the prior guard at 32
threads); all affected shapes pass benchdnn mode=C.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent c7e59b8 commit d71964c
1 file changed
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
1194 | | - | |
1195 | | - | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1196 | 1199 | | |
1197 | 1200 | | |
1198 | 1201 | | |
1199 | 1202 | | |
1200 | 1203 | | |
1201 | 1204 | | |
1202 | | - | |
1203 | | - | |
| 1205 | + | |
1204 | 1206 | | |
| 1207 | + | |
| 1208 | + | |
1205 | 1209 | | |
1206 | 1210 | | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1213 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1214 | 1224 | | |
| 1225 | + | |
1215 | 1226 | | |
1216 | 1227 | | |
1217 | 1228 | | |
| |||
0 commit comments