Skip to content

[TOGSim] A load of what a buffer already holds is not read again - #346

Merged
student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
shared-load-tag
Oct 12, 2026
Merged

student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
shared-load-tag

Conversation

@student-Jungmin

Copy link
Copy Markdown
Collaborator

What

Every dma record got a fresh tag key, scoped to its work-item, so the Core's existing skip of a second load under the same key never fired. The weights of 8192x768x3072 were read once per M tile (four times), and the array sat idle 54,000 of 320,825 cycles while the third tile's copy queued behind the second tile's store.

The bridge now tracks what each spad buffer holds as its last async load brought it (tensor, address, shape). A later load of the same thing into the same buffer:

  • shares the first load's key, in a tag scope the kernel's work-items share, so the Core skips it and its barrier is released when the first load has landed;
  • opens no buffer version, so the bytes stay occupied until the last reader over all work-items, not the first.

A store to the tensor, a compute writing the buffer, or any other load into it ends that. Sync, indirect and multi-buffer loads are untouched.

This assumes the kernel's data stays in the scratchpad between work-items.

Measured

tpuv6e, no cache, with PyTorchSim-Triton-Backend #57:

shape before after
8192x768x3072 309622 269075 DRAM reads 983040 -> 540672; 3 of 8 loads skipped
2048x3072x768 101234 85548
128x3072x768 24622 15245 A was read once per N tile

62 representative GEMM shapes all ran. Against torch_xla (prefetch on) the shapes at M >= 2048 improve (MAPE 12.2% -> 8.3%, 19 of 19 within 25%); small M moves further below the TPU, which is the unmodelled fixed cost showing, not this change.

Tests

  • TOGSim/tests/core_serial: PASS.
  • PyTorchSim-Triton-Backend smoke, tile_gemm, mixed_gemm, conv2d, yolo_dfl with --timing against this TOGSim: 20 of 20, cycles unchanged.

No test in this repository pins the skip itself yet.

Every dma record got a fresh tag key, scoped to its work-item, so the
Core's skip of a second load under the same key never fired: the weights
of 8192x768x3072 were read once per M tile, four times, and the array sat
idle 54,000 cycles of 320,825 while the third tile's copy queued behind the
second tile's store.

The bridge now tracks what each spad buffer holds as its last async load
brought it (tensor, address, shape). A later load of the same thing into
the same buffer shares the first one's key, in a scope the kernel's
work-items share, and opens no buffer version: the Core skips it, its
barrier is released when the first load has landed, and the bytes stay
occupied until the last reader over all work-items. A store to the tensor,
a compute writing the buffer, or any other load into it ends that.

tpuv6e, no cache, with PyTorchSim-Triton-Backend PR 57:
  8192x768x3072  309622 -> 269075 cycles, DRAM reads 983040 -> 540672,
                 3 of 8 loads skipped
  2048x3072x768  101234 ->  85548
  128x3072x768    24622 ->  15245   (A was read once per N tile)
tests/core_serial: PASS. PyTorchSim-Triton-Backend smoke, tile_gemm,
mixed_gemm, conv2d, yolo_dfl with --timing against this TOGSim: 20 of 20,
cycles unchanged.
@student-Jungmin
student-Jungmin merged commit aaa3ee8 into pytorchsim-triton-backend Oct 12, 2026
YWHyuk added a commit that referenced this pull request Oct 13, 2026
PSAL-POSTECH/TOGSim holds both, with one exception named below. Its history
carries TOGSim/ as it stood here at 7b61c1d (tree ee50e4a at its commit
42e39ee), then 1354021 as its commit b190fc1 (tree 5e4ad4c); that
repository's src/ and include/ differ from it only by what it changed
afterwards. It imported configs/ as one snapshot (tree 76a8bbe at its commit
cb457fb, the tree deleted here). The compiler pins that repository as
third_party/TOGSim and this repository reaches it through the compiler:
PyTorchSim -> PyTorchSim-Triton-Backend -> TOGSim, one line, where the two
repositories used to pin each other.

The exception: the TOGSim/ tree this commit deletes is 4c5d50d, which is
5e4ad4c plus ee5f8a4 (#346, a load of what a buffer already holds is not
read again; Instruction.h, Core.cc, togsim_trace_bridge.cc). TOGSim does not
hold that change at 83f43c8 (v1.3.0). It has to be carried there, and the
compiler pin moved to a commit that carries it, or this commit deletes its
only copy on this branch line.

Removed: TOGSim/ (80 files), configs/ (56 files), .gitmodules (its two
entries were TOGSim/extern/booksim and TOGSim/extern/ramulator2, so this
repository has no submodule left), and the TOGSim/build/ line of .gitignore
and of the two dockerignore files.

The compiler pin must be one that carries third_party/TOGSim before this
lands; third_party/pytorchsim-triton-backend.json is not moved here.
YWHyuk added a commit that referenced this pull request Oct 13, 2026
…t v1.3.0 with the TPU v6e HBM3 address mapper

third_party/pytorchsim-triton-backend.json, ref 65fb0585 -> 11ef9b00, the head
of the compiler's main. Its image is published.

- third_party/TOGSim at a1c4209: TOG ABI 16, v1.3.0 (the three refusals), and
  PSAL-POSTECH/TOGSim #20, the TPU v6e HBM3 mapping addresses with MOP4CLXOR
  instead of RoBaRaCoCh. Every tpuv6e cycle count moves with the mapper.
- The compiler's sync-by-default transfers (PTB #62), the pop rule of the
  accelerator model (PTB #63), and a dot's elementwise consumer running at its
  last-K pops.

TOGSim does not carry PyTorchSim #346 (a load of what a buffer already holds
is not read again) yet: PSAL-POSTECH/TOGSim #22, #23. That behaviour is absent
from here on until TOGSim carries it and this pin moves.

PyTorchSim #348, #350.
YWHyuk added a commit that referenced this pull request Oct 13, 2026
The in-tree simulator and its machine configs are removed. Both come from the
TOGSim checkout the compiler carries (TOGSIM_DIR).

- A config named by a test, an experiment or the sweep is found in
  config.CONFIG_TOGSIM_CONFIG_DIR; run_mobilenet and run_yolo no longer take a
  config they never read; tpu_validation reads its DRAM config from the TOGSim
  checkout.
- A new worktree links no TOGSim binary and reads its v6e config from the
  TOGSim checkout.
- The app image builds no TOGSim: the compiler image it stands on carries one.
  The base image installs neither libboost-all-dev nor conan, which only the
  TOGSim build used. The checkouts ask for no submodules: this repository has
  none.
- The README, the worktree notes and the repo guide say where TOGSim and its
  configs are.

This removes the in-tree copy of PyTorchSim #346 as well; see the pin commit.

PyTorchSim #349.
@student-Jungmin
student-Jungmin deleted the shared-load-tag branch October 21, 2026 12:30
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