Skip to content

systolic_array_split on by default, with the unit table the frontend now passes - #341

Merged
student-Jungmin merged 4 commits into
pytorchsim-triton-backendfrom
systolic-split-default
Oct 12, 2026
Merged

student-Jungmin merged 4 commits into
pytorchsim-triton-backendfrom
systolic-split-default

Conversation

@student-Jungmin

@student-Jungmin student-Jungmin commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

What

systolic_array_split was opt-in and reachable only by hand: it needs --unit_table, the frontend never passed one, and --models_list (the path launch_model takes) refused the table and silently ran unsplit.

TOGSim

  • systolic_array_split defaults to round_robin; none turns it off.
  • --trace_so without --unit_table is refused unless the config says none (as before for an explicit round_robin).
  • --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 (trace_to_tilegraph(..., unit_tile_base)). A unit the first table does not name is an error. With the split on, a launched kernel without the file is refused.

Frontend

  • gem5.unit_rows reads each sampled tile's unit admissions (vcix units, the CPU's own, Issue) from the gem5 run that already gives the cycles. For the same m5out it gives the rows PTB's tests/runtime/device writes.
  • emit_trace writes them as trace_units.tsv; the standalone launch passes --unit_table; the autotune launch links the file like the cycle table. A workdir with cycles but no unit rows is emitted again.

Result parser

  • get_result_from_file looked for lines TOGSim no longer prints (Systolic Array Utilization(%), MatMul active cycle, DRAM CH[n], DRAM: AVG BW Util), so its core and DRAM results were always empty. It now reads the per-unit rows, the per-array rows of a run without the table, and the [DRAM] channel n | ... lines. core_metrics["units"] holds every row; the old flat keys are filled from the array unit and the vector unit. An unfinished log returns five values like any other.

Scripts

  • scripts/util_viewer.py matched only the per-array and Vector unit lines, which a run with the unit table does not print; it now reads the Systolic / Msa and Vpu rows too. On a 2048x2048x2048 log of each form: 50.66 / 26.39 with the table, 36.33 per array without it.
  • scripts/trace_timeline.py drew a compute as compute_cycle - overlapping_cycle; TOGSim runs it for compute_cycle, so it now draws that.

Tests

  • tests/system/test_togsim_result.py (new, listed in the workflow): both output forms, on logs cut from real runs.

  • TOGSim/tests/core_serial/run_core_serial.sh: PASS, 14 checks. The serial cases set none, the split cases run on the default, and a default run without a table is refused (new).

  • End to end (torch.matmul through launch_model, tpuv6e, no cache, PTB with PR 54): 20 shapes, all exit 0.

Measured

v6e GEMM, total cycles; sim/TPU against the torch_xla table. "before" is 3984351 with PTB 670ae21, "PTB 54" adds the masked-stream fix only, "this" adds the split.

M x K x N before PTB 54 this before sim/TPU this sim/TPU
512 x 384 x 1152 16840 13531 11021 1.01 0.66
512 x 768 x 768 16873 15809 12534 0.97 0.72
512 x 768 x 3072 58103 50287 40273 1.59 1.10
512 x 2048 x 2048 58257 58257 48779 1.07 0.90
512 x 3072 x 768 56970 48300 43771 1.53 1.17
2048 x 384 x 1152 52156 38978 30386 1.69 0.99
2048 x 768 x 768 51997 36384 34754 1.56 1.04
2048 x 768 x 3072 159886 129415 92579 2.03 1.17
2048 x 2048 x 2048 194485 194485 128976 1.57 1.04
2048 x 3072 x 768 181211 127348 112813 2.11 1.31
8192 x 384 x 1152 196510 143111 102545 2.35 1.23
8192 x 768 x 768 161908 135471 99517 1.78 1.09
8192 x 768 x 3072 671190 421421 320825 2.97 1.42
8192 x 2048 x 2048 718966 718966 608754 1.87 1.58
8192 x 3072 x 768 681512 444606 324971 2.33 1.11

M = 1 (384x1152, 768x768, 768x3072, 2048x2048, 3072x768): cycles unchanged (13517, 10223, 39095, 50514, 40244).
M >= 512 median sim/TPU 1.69 -> 1.10; within 25% of the TPU 3 -> 10 of 15.

To decide

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant