Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c3f7647
[Docs] C++ trace pipeline design (runtime-tag pairing, ABI)
YWHyuk Jun 24, 2026
1fe2cb7
[TOGSim] Add the C++ trace producer, runtime, loader and bridge
YWHyuk Jun 24, 2026
6bf8f61
[TOGSim] Work-item outlining and ABI v12 dispatch
YWHyuk Jun 24, 2026
8f9e389
[TOGSim] SRAM-capacity and SA weight-buffer throttle for the trace path
YWHyuk Jun 24, 2026
9a39ad9
[Tooling] TOGSim trace timeline (Perfetto) and the trace emits it needs
YWHyuk Jun 24, 2026
36b0b35
[TOGSim] Make the C++ trace path the default and stabilize it
YWHyuk Jun 24, 2026
5c4a798
[TOGSim] Redesign trace-bridge dependency, barrier, SRAM-version, and…
YWHyuk Jun 24, 2026
903dad2
[Frontend] Run the spad-overflow check in timing-only mode, budget at…
YWHyuk Jun 25, 2026
8164151
[Frontend] Generate the trace.cpp ABI/API banner from togsim_runtime.h
YWHyuk Jun 25, 2026
2c87270
[TOGSim] Pick 1- vs 2-dispatch concurrency by per-dispatch spad footp…
YWHyuk Jun 25, 2026
1cdeb51
[Frontend] Budget spad buffers honestly in GEMM tile selection
YWHyuk Jun 25, 2026
6ae56f2
[CI] Bump spike pin to v1.0.3
YWHyuk Jun 25, 2026
14302e1
[Frontend] Add a per-kernel CPU functional-verify sub-option
YWHyuk Jun 25, 2026
a8b67c8
[Frontend] Budget fused-prologue spad buffers in BMM tile selection
YWHyuk Jun 25, 2026
25491ad
[TOGSim] Trim per-cycle overhead in the Core issue loop
YWHyuk Jun 26, 2026
bf91b20
[Frontend] Make the C++ trace the sole main TOG path; drop legacy ONN…
YWHyuk Jun 25, 2026
88177e0
[Frontend] Carry gather/scatter offsets as an explicit transfer descr…
YWHyuk Jun 26, 2026
8a2d257
[Frontend] Drop memref.dma_start: lower togsim.transfer directly to G…
YWHyuk Jul 6, 2026
bfef916
[Frontend] Lower togsim.transfer to a DMA descriptor + CONFIG_DESC (n…
YWHyuk Jul 6, 2026
8de755c
[Build] Bump spike to v1.0.5 (DMA descriptor, masked clamp, MVOUT acc…
YWHyuk Jul 6, 2026
ddfc86e
[Frontend] Masked DMA: drop tile divisibility for non-dividing shapes
YWHyuk Jul 7, 2026
c1ae7b5
[Frontend] Reduce >4D togsim.transfer to <=4D before build_tog (fix p…
YWHyuk Jul 7, 2026
bd52184
[Frontend] Fix non-dividing tile over-reads found by the small-array CI
YWHyuk Jul 8, 2026
47c64e1
[Frontend] Keep argsort's sort kernel alive so indices are written
YWHyuk Jul 8, 2026
1d7da69
[Frontend] Fix the gather base offset and drop the ill-posed padded-l…
YWHyuk Jul 8, 2026
67c2636
[Frontend] Store the template buffer when it outlives the fused epilogue
YWHyuk Jul 9, 2026
22b32ce
[Frontend] Add pointwise op lowerings and their CI
Jagggged Jul 9, 2026
0cc908b
[Build] Pin spike v1.0.6 and gem5 v1.0.2
psalwonhyuk Jul 9, 2026
b769845
[Frontend] Op fixes behind SwinV2's shifted-window attention
YWHyuk Jul 8, 2026
77c7338
[Model] Enable SwinV2 shifted-window attention (issue #251)
YWHyuk Jul 9, 2026
bab3d03
[Frontend] Fix conv mapping rejecting batched large-kernel convs
YWHyuk Jul 9, 2026
1ff2ebb
[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
3 changes: 3 additions & 0 deletions AsmParser/tog_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# DEPRECATED (timing path): the legacy ONNX Tile-Operation-Graph producer, superseded
# by the C++ trace pipeline (build_skeleton + lower_to_emitc + cycle_table -> trace.so).
# Retired once the trace path is stable. 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.

## 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)
- `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