Repository navigation
A row times a matrix runs as vector work, not on the array - #342
Merged
Merged
Conversation
…ngs its own unit table systolic_array_split now defaults to round_robin; none turns it off. A --trace_so run without --unit_table is refused unless the config says none. Under --models_list a kernel's trace_units.tsv, beside its trace.so, joins one table the simulator keeps: UnitTable::append shifts its tile_ids behind the rows already held and the kernel's computes carry the same shift. A unit the first table does not name is an error. With the split on, a launched kernel without the file is refused. core_serial: the serial cases set none; the split cases run on the default; a default run without a table is refused.
emit_trace writes each sampled tile's unit rows (the vcix units, the CPU's own, and Issue) from gem5's stats.txt beside trace_cycles.tsv. A standalone run passes it as --unit_table; a launched kernel is found by TOGSim beside its trace.so. The autotune launch links it like the cycle table, and a workdir that has cycles but no unit rows is emitted again.
get_result_from_file looked for 'Systolic Array Utilization(%)', 'MatMul
active cycle', 'DRAM CH[n]' and 'DRAM: AVG BW Util', none of which TOGSim
prints any more, so its core and DRAM results were always empty. It now
reads the per-unit rows ('Core [i] : <unit> utilization(%): ...', and the
Total rows of a several-core run), the per-array rows of a run without the
unit table, and the '[DRAM] channel n | ...' lines. core_metrics['units']
holds every row; the old flat keys are filled from the machine's array unit
and its vector unit. A log that never finished now returns five values like
any other, so the caller that takes the last one still gets the cycles.
tests/system/test_togsim_result.py pins both forms on logs cut from real
runs.
…pute at its full length util_viewer matched only the per-array and Vector unit lines, which a run with the unit table does not print, and that is now every frontend run: its systolic and vector series came out empty. It reads the Systolic (or Msa) and Vpu rows as well, in the periodic blocks and the final one. Checked on a 2048x2048x2048 log of each form: 50.66 / 26.39 with the table, 36.33 per array without it. trace_timeline drew a compute as compute_cycle - overlapping_cycle. TOGSim runs it for compute_cycle since the one-compute-at-a-time change, so a nonzero overlap column drew the slice shorter than it ran. The test joins scripts/ci/triton_route_passing.txt, and the comments this branch added to the Python sources come out, per the repository rule.
… not an mm An mm (or a plain addmm) whose left operand is 1 x K went to the mm template and ran on the systolic array, one row at a time. The TPU runs that shape on its vector unit. rewrite_row_mm replaces it in the post-grad graph with the row viewed as K x 1, multiplied by the matrix and summed over K, so Inductor emits one elementwise-and-reduce kernel and the layout is chosen for that kernel from the start; no tl.dot is generated. tpuv6e, no cache, fp16, cycles and sim/TPU against torch_xla: 1x384x1152 13517 -> 10628 1.33 -> 1.05 1x768x768 10223 -> 9002 0.93 -> 0.82 1x768x3072 39095 -> 32575 1.56 -> 1.30 1x3072x768 40244 -> 31259 1.85 -> 1.44 1x2048x2048 50514 -> 21599 1.80 -> 0.77 512x768x768 is unchanged at 12534. tests/ops/gemm/test_row_matmul.py (mm at two shapes, addmm) passes with the functional check on; each graph is one npu kernel with no host call. tests/ops/gemm/test_matmul.py still passes, 11 of 11.
student-Jungmin
force-pushed
the
vector-mm-m1
branch
from
October 12, 2026 09:48
ed6e01a to
b5db20a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #341 (its four commits show here until it merges; the change of this PR is the last commit).
What
An
mm(or a plainaddmm) whose left operand is 1 x K went to the mm template and ran on the systolic array. The TPU runs that shape on its vector unit (vpu_reducein the torch_xla table).rewrite_row_mm(post-grad, npu graphs only) replaces it with the row viewed as K x 1, multiplied by the matrix and summed over K. Inductor then emits one elementwise-and-reduce kernel, so the layout is chosen for that kernel from the start and notl.dotis generated.Measured
tpuv6e, no cache, fp16; cycles and sim/TPU against torch_xla:
512 x 768 x 768 is unchanged (12534).
Tests
tests/ops/gemm/test_row_matmul.py(new, in the allowlist and the workflow): mm at two shapes and addmm, functional check on, all pass. Each graph is one npu kernel, no host call, notl.dot.tests/ops/gemm/test_matmul.py: 11 of 11 still pass.Limits
aten.mm/aten.addmmwith a static first dimension of 1. A K x 1 right operand,bmm, and a hand-written Triton kernel with a one-rowtl.dotstill take the array.