Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0886c2d
[Docs] C++ trace pipeline design (runtime-tag pairing, ABI)
YWHyuk Jun 24, 2026
2ac089c
[TOGSim] C++ trace pipeline: front end, runtime, loader, bridge, Core…
YWHyuk Jun 24, 2026
05d83a3
[TOGSim] Per-iteration tag pairing for multi-tile-K and conv
YWHyuk Jun 24, 2026
bc45e71
[TOGSim] Work-item outlining and ABI v12 dispatch
YWHyuk Jun 24, 2026
950d777
[TOGSim] SRAM-capacity and SA weight-buffer throttle for the trace path
YWHyuk Jun 24, 2026
545cb09
[Tooling] TOGSim trace timeline (Perfetto) and the trace emits it needs
YWHyuk Jun 24, 2026
cf1bd54
[TOGSim] Make the C++ trace path the default and stabilize it
YWHyuk Jun 24, 2026
91c5f71
[TOGSim] Make the trace runtime test self-contained
YWHyuk Jun 24, 2026
b53cefa
[Frontend] Trace cache-safe replay and compile-race fixes
YWHyuk Jun 24, 2026
2cde58e
[TOGSim] Redesign trace-bridge dependency, barrier, SRAM-version, and…
YWHyuk Jun 24, 2026
01241db
[Frontend] Run the spad-overflow check in timing-only mode, budget at…
YWHyuk Jun 25, 2026
2c6a548
[Frontend] Generate the trace.cpp ABI/API banner from togsim_runtime.h
YWHyuk Jun 25, 2026
db543a3
[TOGSim] Pick 1- vs 2-dispatch concurrency by per-dispatch spad footp…
YWHyuk Jun 25, 2026
343ccef
[Frontend] Budget fused-epilogue spad buffers honestly in GEMM tile s…
YWHyuk Jun 25, 2026
0a2581d
[Frontend] Stop charging the kernel stack frame against the spad budget
YWHyuk Jun 25, 2026
beb6686
[CI] Bump spike pin to v1.0.3
YWHyuk Jun 25, 2026
0a73a95
[Frontend] Add per-kernel CPU functional verify sub-option
YWHyuk Jun 25, 2026
2dd0e92
[Frontend] Budget fused-prologue spad buffers in BMM tile selection
YWHyuk Jun 25, 2026
f7de46e
[Docs] Document per-kernel functional verify
YWHyuk Jun 25, 2026
08e390e
[Frontend] Condense BMM prologue spad-budget comments to one line
YWHyuk Jun 25, 2026
4714c49
[TOGSim] Drop the ABI version changelog comment
YWHyuk Jun 25, 2026
7a47e73
Merge pull request #278 from PSAL-POSTECH/fix/bmm-prologue-spad-budget
YWHyuk Jun 25, 2026
7dd9545
[TOGSim] Skip per-instruction trace string build when trace logging i…
YWHyuk Jun 26, 2026
fcf4150
[TOGSim] Skip the per-cycle issue scan when nothing can newly issue
YWHyuk Jun 26, 2026
9e6c6fc
[TOGSim] Fix use-after-erase in the zero-cycle COMP skip path
YWHyuk Jun 26, 2026
32173a0
[Frontend] Make the C++ trace the sole main TOG path; drop legacy ONN…
YWHyuk Jun 25, 2026
268320a
[Frontend] Represent kernel body as ordered steps; multi-step indirect
YWHyuk Jun 26, 2026
2e8c742
[Frontend] Carry gather/scatter offset as an explicit transfer descri…
YWHyuk Jun 26, 2026
ac62aa4
[Frontend] Clean up indirect access: symbol-set detection, CONFIG4 st…
YWHyuk Jun 26, 2026
a2b0a5f
[Frontend] Drop memref.dma_start: lower togsim.transfer directly to G…
YWHyuk Jul 6, 2026
03489c6
[Frontend] Port the trace path (build_tog) to togsim.transfer/togsim.…
YWHyuk Jul 6, 2026
65abcfc
[Frontend] Detect the indirect offset operand by the `indirect` attr,…
YWHyuk Jul 6, 2026
ae036e4
[Frontend] Fix stale build_skeleton docstrings (memref.dma_wait -> to…
YWHyuk Jul 6, 2026
e77c262
[Frontend] Lower togsim.transfer to a DMA descriptor + CONFIG_DESC (n…
YWHyuk Jul 6, 2026
fbd585b
[Build] Bump spike to v1.0.4 (DMA descriptor / CONFIG_DESC)
YWHyuk Jul 6, 2026
b06d7a7
[Build] Bump spike to v1.0.5 (masked-DMA clamp + MVOUT accumulate)
YWHyuk Jul 7, 2026
97bf1d4
[Frontend] Masked-DMA dynamic clamp: drop tile divisibility, fill non…
YWHyuk Jul 7, 2026
22ecc80
[Frontend] Extend the masked-DMA clamp to conv (explicit extents + fi…
YWHyuk Jul 7, 2026
5972bda
[Frontend] Clamp the fused-epilogue output store on non-dividing shapes
YWHyuk Jul 7, 2026
cf8e6fb
[Test] Golden unit test for the lower_transfer_to_gemmini pass
YWHyuk Jul 7, 2026
7da95c0
[Frontend] Masked-DMA review fixes: exp target-match, explicit local_…
YWHyuk Jul 7, 2026
cfcb7a9
[Test] Non-dividing masked-DMA regression suite + CI
YWHyuk Jul 7, 2026
d6faca3
[Frontend] Drop the dead self.masks splice in the reduction-fusion ep…
YWHyuk Jul 7, 2026
1e2a3a9
[Frontend] Reduce >4D togsim.transfer to <=4D before build_tog (fix p…
YWHyuk Jul 7, 2026
6a38466
[Frontend] Per-kernel verify: run the CPU golden fully on CPU (device…
YWHyuk Jul 7, 2026
9003028
[Frontend] Fix cat concat-dim tile over-read on non-dividing splits
YWHyuk Jul 8, 2026
3a11fe9
[Frontend] Fix vlane index_expr row stride for multi-row splits
YWHyuk Jul 8, 2026
c78a391
[Frontend] Cap 1-D reduction tile to extent to stop MVIN over-read
YWHyuk Jul 8, 2026
1c7b93d
[Frontend] Keep argsort's sort kernel alive so indices are written
YWHyuk Jul 8, 2026
a1c3f3c
[Frontend] Zero bare indirect index in the gather DMA base offset
YWHyuk Jul 8, 2026
933b0bd
[Frontend] Drop ill-posed padded-load OOB clamp from masked-DMA bounds
YWHyuk Jul 8, 2026
79b1aec
[Frontend] Store the template buffer when it outlives the fused epilogue
YWHyuk Jul 9, 2026
efd6c8c
[Frontend] Add pointwise op lowerings
Jagggged Jul 9, 2026
00e6e40
[Frontend] Lower math.log/atan to VCIX in the Python pass
Jagggged Jul 9, 2026
8c7fd7e
[CI] Add test_pointwise.py
Jagggged Jul 9, 2026
ae19451
[Build] Pin spike v1.0.6 and gem5 v1.0.2
psalwonhyuk Jul 9, 2026
f8940f8
[Frontend] Make int max/min reductions dtype-aware (identity + combine)
YWHyuk Jul 8, 2026
2f12caf
[Frontend] Lower torch.roll to narrow+cat and realize to avoid a modu…
YWHyuk Jul 8, 2026
06bc74d
[Frontend] axis-split: flatten nested single-variable floor/mod
YWHyuk Jul 8, 2026
4406ae3
[Frontend] Define empty_strided_cpu in the generated wrapper header
YWHyuk Jul 9, 2026
e7126d4
[Frontend] Place the reduction axis outermost in the per-lane tile la…
YWHyuk Jul 9, 2026
43b8380
[Model] Enable SwinV2 shifted-window attention (issue #251)
YWHyuk Jul 9, 2026
713feed
[Frontend] Fix conv mapping rejecting batched large-kernel convs
YWHyuk Jul 9, 2026
2463f82
[Model] Enable CLIP vision backbone (issue #252)
YWHyuk Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 79 additions & 2 deletions .github/workflows/pytorchsim_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ on:

# Runner policy: the CPU-only CI image is small enough to pull on GitHub-hosted
# runners, so op and model tests run on ubuntu-latest. The memory/time-intensive
# jobs stay on self-hosted: test_deepseek (largest model), test_diffusion (UNet2D
# simulation OOMs the hosted runner), and test_accuracy (accuracy + speedup).
# jobs stay on self-hosted: test_deepseek (largest model), test_swinv2 (SwinV2
# shifted-window backbone), test_clip (CLIP vision backbone), test_diffusion
# (UNet2D simulation OOMs the hosted runner), and test_accuracy (accuracy + speedup).
jobs:
test_add:
name: Run test_add.py
Expand Down Expand Up @@ -57,6 +58,24 @@ jobs:
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/ops/elementwise/test_transcendental.py

test_pointwise:
name: Run test_pointwise.py
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test_pointwise.py
run: |
echo "Running test_pointwise.py"
docker run --rm \
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/ops/elementwise/test_pointwise.py

test_activation:
name: Run test_activation.py
runs-on: ubuntu-latest
Expand Down Expand Up @@ -633,6 +652,24 @@ jobs:
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/ops/misc/test_indirect_access.py

test_masked_nondividing:
name: Run test_masked_nondividing
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test_masked_nondividing.py
run: |
echo "Running test_masked_nondividing.py"
docker run --rm \
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/ops/misc/test_masked_nondividing.py

test_scheduler:
name: Run test_scheduler
runs-on: ubuntu-latest
Expand Down Expand Up @@ -707,6 +744,46 @@ jobs:
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/models/DeepSeek/test_deepseek_v3_base.py

test_swinv2:
name: Run test_swinv2.py
# SwinV2 backbone (shifted-window attention) is heavy; keep it on a
# self-hosted runner like the other model tests.
runs-on: self-hosted
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test_swinv2.py
run: |
echo "Running test_swinv2.py"
docker run --rm \
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/models/test_swinv2.py

test_clip:
name: Run test_clip.py
# CLIP vision backbone; keep it on a self-hosted runner like the other
# model tests (the 32x32 patch conv expands to many tiles at small arrays).
runs-on: self-hosted
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run test_clip.py
run: |
echo "Running test_clip.py"
docker run --rm \
-e TOGSIM_CONFIG="${{ inputs.togsim_config }}" \
${{ inputs.image_name }} python3 PyTorchSim/tests/models/test_clip.py

test_eager:
name: Run test_eager.py
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions AsmParser/tog_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# DEPRECATED (timing path): legacy ONNX Tile-Operation-Graph producer. Builds
# the TOG and serializes it to ONNX for the C++ TileGraphParser. Superseded by
# the C++ trace pipeline (PyTorchSimFrontend/mlir/passes/build_skeleton.py +
# lower_to_emitc.py + cycle_table.py -> a compiled trace .so). Kept live so the
# current pipeline does not break; to be retired once the trace pipeline (P3+)
# stabilizes. See docs/design/togsim_cpp_trace.md.
import os
import sys
import importlib.util
Expand Down
12 changes: 10 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The pipeline runs in that order on every `torch.compile` invocation; you'll see
| `Simulator/simulator.py` | Python drivers: `FunctionalSimulator` (Spike), `CycleSimulator` (Gem5), `TOGSimulator` (the cycle-accurate one + multi-tenant context manager) |
| `Scheduler/scheduler.py` | Poisson arrival generator + scheduling utilities for multi-tenant runs |
| `TOGSim/` | C++ TOGSim source. `src/Simulator.cc`, `Core.cc`, `Dram.cc`, `Interconnect.cc`, `L2Cache.cc`, `Tile.cc`, `TileGraph.cc` are the core models. Externals: ramulator2, booksim, stonneCore, onnx, protobuf, spdlog, yaml-cpp |
| `AsmParser/` | `tog_generator.py`, `onnx_utility.py` — TOG generation from ONNX/ASM |
| `AsmParser/` | `tog_generator.py`, `onnx_utility.py` — legacy ONNX TOG generation; now used only by the STONNE sparse path (the main path emits a C++ `trace.so` instead) |
| `configs/` | TOGSim hardware configs (YAML). The default is `systolic_ws_128x128_c1_simple_noc_tpuv3.yml`. Naming pattern: `systolic_ws_<size>_c<cores>_<noc>_<target>.yml` |
| `tests/` | Op- and model-level tests organized under `ops/<family>/` (elementwise, reduce, gemm, conv, attention, view, sort, sparsity, misc, fusion), `models/<name>/` (Llama, Mixtral8x7B, DeepSeek, Diffusion, MoE, MLP, MobileNet, Yolov5) plus single-file model tests (test_resnet, test_transformer, test_vit, test_mlp, test_single_perceptron), and `system/` (scheduler, eager, hetro, stonne, vectorops). Shared helper: `tests/_utils.py` |
| `experiments/artifact/` | Paper reproduction scripts (`cycle_validation/run_cycle.sh`, `speedup/run_speedup.sh`) |
Expand Down Expand Up @@ -58,6 +58,12 @@ export TORCHSIM_DUMP_MLIR_IR=1
export TORCHSIM_DUMP_LLVM_IR=1
```

**To find which op a wrong result first diverges at** (per-kernel CPU cross-check;
sub-option of functional mode). Set `pytorchsim_functional_verify_per_kernel: 1`
in the config YAML, clear the codegen cache, and re-run: each compiled kernel's
output is compared to a CPU golden and the run stops at the first divergent
kernel, naming the op and offending indices. See `docs/per-kernel-functional-verify.md`.

## Key environment variables

Read in `PyTorchSimFrontend/extension_config.py`:
Expand Down Expand Up @@ -85,11 +91,13 @@ Note: `TOGSIM_CONFIG` is **overwritten** while inside a `with TOGSimulator(confi
Located under `configs/*.yml`:

- `num_cores`, `core_freq_mhz`, `num_systolic_array_per_core`
- `sa_weight_buffer_depth` (per-SA resident weight slots; **must be > 0** — the simulator errors on 0. Raise it to effectively disable the preload run-ahead throttle. Defaults to 2 if the key is absent.)
- `vpu_num_lanes`, `vpu_spad_size_kb_per_lane`, `vpu_vector_length_bits`
- `dram_type` (`ramulator2` | `simple`), `dram_channels`, `dram_freq_mhz`, `ramulator_config_path`
- `icnt_type` (`simple` | `booksim`), `icnt_latency_cycles`, `icnt_freq_mhz`, `icnt_config_path`
- `l2d_type` (e.g., `datacache`), `l2d_config` (AccelSim-format cache config string)
- `pytorchsim_functional_mode` (Spike on/off), `pytorchsim_timing_mode`
- `pytorchsim_functional_verify_per_kernel` (debug: per-kernel CPU cross-check; see `docs/per-kernel-functional-verify.md`)
- `codegen_mapping_strategy`: `heuristic` | `autotune` | `external-then-heuristic` | `external-then-autotune`
- `codegen_external_mapping_file` (key `"M_N_K"` → `{TILE_M, TILE_K, TILE_N}` JSON)
- `codegen_compiler_optimization`: `"all"` | `"none"` | a list from `{fusion, reduction_epilogue, reduction_reduction, prologue, single_batch_conv, multi_tile_conv, subtile}`
Expand Down Expand Up @@ -122,7 +130,7 @@ Conan deps for TOGSim: `boost/1.79.0`, `robin-hood-hashing/3.11.5`, `spdlog/1.11
- **Adding a new op (Inductor lowering):** `PyTorchSimFrontend/mlir/mlir_ops.py`, `mlir_lowering.py`, plus a new `mlir_<op>_template.py` if it needs its own MLIR template. Decomposition rules: `mlir_decomposition.py`. Scheduling: `mlir_scheduling.py`. Autotune: `mlir_autotune.py`.
- **Adding a PyTorch device op:** `PyTorchSimDevice/csrc/aten/native/*` (Minimal/Extra split mirrors `torch_openreg`).
- **TOGSim hardware model changes:** `TOGSim/src/{Core,Dram,Interconnect,L2Cache,Tile,TileGraph}.cc` + matching `include/*.h`.
- **TOG generation:** `AsmParser/tog_generator.py` builds the raw graph and serializes it via `AsmParser/onnx_utility.py` to **ONNX, which is the on-disk TOG format** consumed by TOGSim.
- **TOG generation:** the main path compiles each kernel to a C++ **`trace.so`** (`mlir/passes/build_skeleton.py` + `lower_to_emitc.py`) plus a `trace_cycles.tsv` cycle table, which TOGSim turns into a TileGraph via `trace_to_tilegraph`. `AsmParser/tog_generator.py` + `onnx_utility.py` (the legacy ONNX TOG) remain only for the **STONNE sparse path** (`extension_op.py`).
- **Eager fallback registration:** `torch.npu.register_eager_to_compile([...])` — see `tests/system/test_eager.py`.
- **Per-run results:** `togsim_results/<YYYYMMDD_HHMMSS_<hash>>.log` (stats) and `.trace` (instruction trace). The path is also printed at the end of every run.
- **Wrapper codegen path:** printed as `Wrapper Codegen Path = /tmp/torchinductor_<user>/<hash>/...py` — useful for inspecting generated kernel code and tensor names for `SRAM_BUFFER_PLAN_PATH`.
Expand Down
Loading
Loading