Skip to content

[TOGSim] Systolic queue size in every config, packed trace tensors, an optional (8,128) tiled DRAM layout - #322

Merged
YWHyuk merged 3 commits into
pytorchsim-triton-backendfrom
tt-opt/systolic-util
Oct 8, 2026
Merged

YWHyuk merged 3 commits into
pytorchsim-triton-backendfrom
tt-opt/systolic-util

Conversation

@YWHyuk

@YWHyuk YWHyuk commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Three commits on 6ba6e62 (#321):

  • 2d40902 [Frontend] all 24 systolic_ws_* configs state tpu_systolic_queue_entries: 256 (the vcix tpu model's own default) and CONFIG_MACHINE passes it as systolic_queue_entries, a field pytorchsim-triton-backend's target now requires (p08 streams a dot's subtiles against it). A config without the key fails at CONFIG_MACHINE.
  • d91215e trace tensors are packed back to back in argument order, each start aligned to 16 KiB (XLA's program HBM alignment), from trace_tensors.txt beside trace.so; the run stops when it is absent. The 1 MiB stubs let a 4 MiB operand run into the next tensor and gave no address past 16 tensors. Both producers write the file: PTB's TOGSim device already did, and the frontend now writes it per launch from kernel.json.
  • ceacbb5 trace_tensor_tile: [8, 128] (absent by default) times trace tensors as stored in (8,128) tiles (bf16 (16,128), int8 (32,128)), from trace_tensor_shapes.txt (written by both producers). Timing only; Spike stays row-major. A tiled tensor takes its padded footprint in the packed layout. TOGSim/tests/tensor_tiling_check.sh pins the map.

Measured with PTB #24 (main e417ef0 + 4), 1 core tpuv6e, segment grouping:

  • packed vs stub bases: 512^3 b512 11643 → 11649, 2048^3 b1024 351964 → 351964.
  • tiled vs row-major (HBM3 1 KB rows): 512^3 b512 11649 → 11627, 2048^3 b512 522840 → 682083, so the layout stays off.

Follow-ups, not here: the vcix model's queue size still comes from its own machine config (default 256), not from the target; TOGSim does not stall a node on a unit's admission rate, so overlapping compute can exceed Systolic capacity and --unit_table exits (typed grouping).

YWHyuk added 3 commits October 8, 2026 18:47
…the target carries it

tpu_systolic_queue_entries: 256 is the vcix tpu model's own default, now
written in each of the 24 systolic_ws configs, and CONFIG_MACHINE passes it
on as systolic_queue_entries, a field pytorchsim-triton-backend's target
requires: p08 streams a dot's subtiles against it. A config without the key
now fails at CONFIG_MACHINE instead of compiling against a guessed queue.

Checked: CONFIG_MACHINE gives 256 under the tpuv6e and tpuv3
functional-only configs.
The stub bases put argument i at (i+1) MiB whatever its size, so a
1024x1024 fp32 operand (4 MiB) ran into the next tensor and A, B and C of a
1024 or 2048 matmul shared DRAM rows they would not share on the machine,
and a kernel with more than 16 tensors had no address for the rest.

TOGSim now lays the tensors out in argument order, each start aligned to
16 KiB (XLA's program HBM alignment), from the byte sizes trace_tensors.txt
lists beside trace.so, and stops when the file is absent. Both producers
write it: pytorchsim-triton-backend's TOGSim device already does, and the
frontend now writes it per launch from kernel.json, next to trace_shape.txt.

Measured on PTB main's ABI 14 traces, 1 core tpuv6e, segment grouping:
gemm 512^3 b512 11643 -> 11649, gemm 2048^3 b1024 351964 -> 351964.
Without trace_tensors.txt the run exits 1 naming the file.
…only

`trace_tensor_tile: [rows, cols]` (absent by default) has every DMA's
requests address the tensor as stored in tiles of that many 4-byte elements,
tiles row-major and row-major inside each; a tile keeps its bytes, so rows
scale by 4/elem (bf16 (16,128), int8 (32,128)). The 2-D view is the last
axis as columns and every leading axis folded into the rows, read from
trace_tensor_shapes.txt beside trace.so, which both producers write: the
PTB TOGSim device, and now the frontend per launch from kernel.json. An
indirect DMA's addresses take the same map. Spike and the functional run
keep every tensor row-major; only the requests a DMA sends DRAM move.

A tiled tensor takes its padded footprint in the packed layout. The run
stops when the key is set and the shapes file is absent, lists a different
number of tensors than trace_tensors.txt, or names a zero dimension.

Measured, 1 core tpuv6e (HBM3 1 KB rows), segment grouping, row-major ->
tiled: gemm 512^3 b512 11649 -> 11627, gemm 2048^3 b512 522840 -> 682083.
With 1 KB rows a row-major tile already fills its DRAM rows, so the layout
stays off; it is a knob for asking what a tiled HBM would change.

TOGSim/tests/tensor_tiling_check.sh pins the map: one 8x128 MOVIN of a
512x512 fp32 tensor is eight 512 B runs at a 2 KiB pitch row-major and one
contiguous 4 KiB run tiled, and the footprint pads to whole tiles.
@YWHyuk
YWHyuk force-pushed the tt-opt/systolic-util branch from e18413e to ceacbb5 Compare October 8, 2026 10:03
@YWHyuk YWHyuk changed the title [TOGSim] Systolic queue size in the tpuv6e configs, 256 MiB tensor bases, an optional (8,128) tiled DRAM layout [TOGSim] Systolic queue size in every config, packed trace tensors, an optional (8,128) tiled DRAM layout Oct 8, 2026
@YWHyuk
YWHyuk merged commit 05c2d47 into pytorchsim-triton-backend Oct 8, 2026
YWHyuk added a commit to PSAL-POSTECH/PyTorchSim-Triton-Backend that referenced this pull request Oct 8, 2026
…e, trace tensors packed

PSAL-POSTECH/PyTorchSim#322 on top of 6ba6e62: the 24 systolic configs
state tpu_systolic_queue_entries (which the target now requires),
CONFIG_MACHINE carries it, TOGSim lays trace tensors back to back from
trace_tensors.txt (which the TOGSim device already writes) and stops
without it, and an optional (8,128) tiled DRAM layout reads
trace_tensor_shapes.txt (which the previous commit writes).

Checked: 05c2d47's tree is the ceacbb5 tree these commits were measured
on; 9 matmul kernels PASS and the gemm --timing runs in 980ec96 come from
a TOGSim built from it.
@YWHyuk
YWHyuk deleted the tt-opt/systolic-util branch October 12, 2026 05:36
student-Jungmin pushed a commit to PSAL-POSTECH/PyTorchSim-Triton-Backend that referenced this pull request Nov 10, 2026
…e, trace tensors packed

PSAL-POSTECH/PyTorchSim#322 on top of 6ba6e62: the 24 systolic configs
state tpu_systolic_queue_entries (which the target now requires),
CONFIG_MACHINE carries it, TOGSim lays trace tensors back to back from
trace_tensors.txt (which the TOGSim device already writes) and stops
without it, and an optional (8,128) tiled DRAM layout reads
trace_tensor_shapes.txt (which the previous commit writes).

Checked: 05c2d47's tree is the ceacbb5 tree these commits were measured
on; 9 matmul kernels PASS and the gemm --timing runs in 980ec96 come from
a TOGSim built from it.
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