Repository navigation
[TOGSim] Trace-bridge dependency + SRAM version redesign - #270
Merged
Merged
Conversation
YWHyuk
force-pushed
the
feature/togsim-cpp-trace
branch
from
June 24, 2026 08:23
6ff30ce to
e8697c7
Compare
YWHyuk
force-pushed
the
feature/bridge-dep-redesign
branch
3 times, most recently
from
June 24, 2026 11:38
d85b3f4 to
d4ded78
Compare
YWHyuk
force-pushed
the
feature/togsim-cpp-trace
branch
from
June 24, 2026 11:39
36da343 to
0f4deaa
Compare
YWHyuk
force-pushed
the
feature/bridge-dep-redesign
branch
from
June 24, 2026 13:02
d4ded78 to
03ccbcd
Compare
YWHyuk
force-pushed
the
feature/togsim-cpp-trace
branch
from
June 24, 2026 13:16
9b913d4 to
4767e8a
Compare
… runtime model Replace the trace bridge's accumulated special cases with one dataflow rule and clean up the runtime that consumes it. Dependency rule: per SRAM buffer keep a writers SET; a reader depends on all current writers (occupancy=ISSUE when both are systolic-array ops, else latency=DONE); a writer REPLACEs the set. The only exception is is_mm_accum (a matmul that reads and writes the same buffer = a commutative accumulator): skip its read edge and UNION its write, waiting only the non-matmul init seed and not ordering co-matmuls. This drops the matmul-accumulator chain that deadlocked the SA weight-slot pipeline while keeping the init->matmul edge, and lets a vector epilogue or the store wait every K matmul (fixes the pure-vector store that an empty COMPUTE_BAR let slip). Remove COMPUTE_BAR entirely: a matmul is its own DONE-handle (finish == SA drain), so the store JOINs the matmul writers directly. The whole emit/loader chain is gone -- build_skeleton, lower_to_emitc, togsim.compute_barrier, the runtime symbol, the Opcode/case/_fence_finish, and TraceRec::COMPUTE_BAR -- so a stale producer fails loudly instead of emitting records the bridge would drop. Only MEMORY_BAR remains (an async load's DONE is its data arrival, not issue). Model compute-output spad footprint in the SRAM version/capacity machinery so buffer reuse (WAR) is capacity-modeled, not a hard edge. The output size comes from the DMA records that touch the same buffer (a buf_bytes pre-pass); an in-place buffer (accumulator, relu) is version-transparent so footprint is not double-counted. The occupy gate and version release sit in the MOVIN/MOVOUT/COMP issue points (release before the COMP skip path so a skipped matmul still frees). Runtime: collapse child_inst / _pipeline_children into one event-indexed _deps[ISSUE|DONE] with add_dep(c, on) and fire(e); collapse the weight-slot release queue and the async-load wakeup into one _due_events timed-effect table drained by process_due_events. Both are behavior-preserving (byte-identical). Require the weight-slot model: sa_weight_buffer_depth must be > 0 (errors at init), and the round-robin disable mode is removed. Degenerate traces (a consumer-less preload, an unpinned matmul) hit explicit error+exit guards rather than asserts that vanish under NDEBUG. Mark the legacy ONNX TOG path deprecated: it is superseded by the trace path, so TileGraphParser logs a deprecation warning and the TORCHSIM_LEGACY_TOG=1 opt-in warns at command build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAmdM9BrsTvfi8sZnnfNno
YWHyuk
force-pushed
the
feature/bridge-dep-redesign
branch
from
June 24, 2026 13:18
03ccbcd to
8a77c88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesigns the C++ trace bridge's dependency model, removes the COMPUTE_BAR
fence, models compute-output spad footprint, and tidies the runtime event
machinery -- replacing a pile of special cases with one dataflow rule plus two
clean runtime mechanisms. Branches off feature/togsim-cpp-trace; disjoint file
set from the latest commit there (no conflicts).
Dependency rule (one rule)
Per SRAM buffer, keep a
writersSET. A reader depends on ALL current writers(JOIN) -- occupancy (released at ISSUE) when both are systolic-array ops, else
latency (released at finish). A writer REPLACEs the set. The only exception is
is_mm_accum(a matmul that reads AND writes the same buffer = a commutativeaccumulator): skip its read edge and UNION its write, waiting only the
non-matmul init seed and not ordering co-matmuls.
pipeline (Implement unique kernel name allocation #1) without losing the init->matmul edge.
pure-vector store that an empty COMPUTE_BAR let slip, Scalar #2).
Remove COMPUTE_BAR
A matmul is its own DONE-handle (its finish is the SA drain), so the store
JOINs the matmul writers directly. Drops the
compute_barrieremission inbuild_skeleton and the Opcode/case/_fence_finish in Core and Instruction. Only
MEMORY_BAR remains (an async load's DONE is its data arrival, not its issue).
SRAM version model for compute outputs (capacity-aware WAR)
Buffer reuse ordering (WAR) is modeled by the SRAM version/capacity machinery,
not a hard edge (a hard WAR edge over-serializes weight-slot and double-buffered
reuse). Compute outputs (the accumulator, vector epilogue results) are tracked
too; the output size comes from the DMA records that touch the same buffer (a
buf_bytes pre-pass). A read-and-written buffer (accumulator, in-place relu) is
version-transparent so footprint is not double-counted. The COMPUTE issue path
gets the same capacity gate as a load.
Runtime mechanism cleanup (behavior-preserving, byte-identical)
_deps[ISSUE|DONE]withadd_dep/fire; the old methods are thin aliases.into one
_due_eventstable drained byprocess_due_eventsthrough a singleapply_duesink.Instruction::start_cyclefield.--log_level trace) on matmul / matmul+relu / multi-tile gemm / reduction.Verification (no Spike)
the init edge and the all-matmuls JOIN); the pure-vector pooling kernel +16%
is the Scalar #2 store fix.
See docs/bridge_dependency_redesign.md for the full rule, the version/capacity
WAR model, and the runtime mechanism.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HAmdM9BrsTvfi8sZnnfNno