Repository navigation
Feature/tog notebook - #493
Merged
Merged
Conversation
…d a ReLU's tog.cpp to read
third_party/pytorchsim-triton-backend.json moves from 940c671 to PTB main e3a0576, whose image is published. PSAL-POSTECH/PyTorchSim-Triton-Backend@940c671...e3a0576
third_party/pytorchsim-triton-backend.json moves from e3a0576 to PTB main 8402097, whose image is published. PSAL-POSTECH/PyTorchSim-Triton-Backend@e3a0576...8402097
… addresses Spike records
…its weight once The grouped kernel ran one program per BM-row block of a group, and each program read the group's whole weight tile (BK covers K, so its K loop ran once). Every block read the expert's weight again: Qwen3-30B-A3B's gmm_down reads 383 x 3 MB at T4096 (255 x at T2048), and the TOG was bound on HBM (MXU 21% busy), where v6e's grouped matmul reads each expert's weight about once. A program is now one group with rows: it walks the group's rows BM at a time, and when the B tile holds all of K (BK == KP) reads it once before the walk. Otherwise each row block walks K as before. At most A's rows groups have rows, so the grid is min(groups, rows) programs: program i takes the i-th group with rows from a table: the group whose running count of groups with rows is i + 1, with its first row and row count, all three zero for a program left over, which then reads nothing. The table the TOG reads is that group, first row and row count per program. test_grouped_mm pins the grid: one program per group with rows (8 for 8 groups with rows, 4 for 4 rows over 16 groups). Measured locally on the validation bundle's kernels against PTB main 940c671c (TOGSim 1f05af9, tpuv6e), TOGSim / v6e, main's CI (940c671c) -> this commit: gmm_down T1 0.875 -> 0.884, gmm_gate_up T1 0.933 -> 0.940; layer decode S4096 1.058 -> 1.062. At T >= 128 A has at least as many rows as there are groups, so the grid is one program per group, as it was before the table; measured with that earlier table: gmm_down T2048 1.059 -> 0.943, T4096 1.629 -> 0.909; gmm_gate_up T2048 1.042 -> 0.979, T4096 (CI timeout) -> 0.870; layer prefill S1024 1.111 -> 1.074, S2048 1.129 -> 1.088, S4096 (CI timeout) -> 0.980.
[Frontend] grouped_mm runs one program per group with rows and reads its weight once
[Simulator] Compiler pin: PTB main 8402097
… launch's DRAM reads and bandwidth
…feature/tog-notebook
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.
Title: Tutorial session1 for the MICRO 2026 slides: TOG.ipynb replaces CompilerOptimization.ipynb; Mapping, ExecutionMode, TOGSimConfig and Training updated
Base:
micro2026←feature/tog-notebookSummary
This brings
tutorial/session1in line with the MICRO 2026 slides, so the nextmicro2026-<n>tag publishes an image whose notebooks match them. The tutorial changes are confined totutorial/session1/.Besides the tutorial commits, the branch merges
pytorchsim-triton-backendup to e6b1c90. That merge adds five upstream commits thatmicro2026does not have yet:grouped_mmruns one program per group and reads its weight once ([Frontend] grouped_mm runs one program per group with rows and reads its weight once #489).micro2026's own three commits, which move Coprocessor's tutorial branch up to f0c0ae0, touchdocker/tutorial/andthird_party/tutorial.jsononly. They do not conflict with this branch.Changes (
tutorial/session1/)TOG.ipynbreplacesCompilerOptimization.ipynbThe tutorial no longer covers compiler optimization (fusion on and off).
TOG.ipynbruns ontogsim_config.yml, with both functional and timing modes on, and covers two kernels.ReLU:
tog/relu/and prints itstog.cpp.Embedding (data-dependent): compiles 256 ids into an 8192 x 512 bf16 table, into
tog/embedding/, and shows:the runtime attribute that
kernel.jsondeclares, which comes fromin_ptr0(the ids);the addresses Spike recorded for the latest launch in
attr_<program>_0.bin, whose row starts are512 * id;the
Gather(ATTR0)on the table's load intog.cpp;the same TOG relaunched with three patterns of ids. For each launch, the notebook prints the cycles, and the DRAM reads and bandwidth from that launch's TOGSim log:
Mapping.ipynb: a 4096 x 4096 bf16 mm, instead of a 2 x 1024³ bmmtutorial_external_mapping.json, which is now keyed4096_4096_4096.ExecutionMode.ipynb: a 1024 x 1024 bf16 mm, instead of 512 x 512TOGSimConfig.ipynb: a compute-bound bmm (8 x 1024³ bf16), instead of a 4096 x 4096 mmTraining.ipynb: the MSE loss is compiled tooopt_loss = torch.compile(loss_fn).fused_mse_loss,fused_mse_loss_backwardand the bias gradient'sfused_sumare simulated, instead of running on the CPU through the npu fallback.Testing
On
ghcr.io/psal-postech/tutorial-micro2026:bea36e137609d59a94b158635ffa596878338b5c(micro2026-2, compiler pin 940c671, amd64), withtutorial/replaced by this branch's:TOG.ipynbtakes 15 to 38 s, andMapping.ipynb46 min.Training.ipynblogs no[Eager Mode]op. Its losses and trained parameters match the fp32 CPU reference.Not tested yet:
micro2026-5).Once this is merged and a new
micro2026-<n>tag has built its image, I will rerun the nine notebooks on that image and update any cycle counts that change.