PyTorchSim: A Comprehensive, Fast, and Accurate NPU Simulation Framework
Wonhyuk Yang∗, Yunseon Shin∗, Okkyun Woo∗, Geonwoo Park§, Hyunkyu Ham,
Jeehoon Kang†¶, Jongse Park¶, Gwangsun Kim
MICRO 2025 Session 7B: Tools and Simulators
* Equal contribution
§ Currently with Samsung Electronics
∥ † FuriosaAI
POSTECH
Parallel System Architecture Lab.
¶ KAIST
AI Model & Hardware Trends
2
1029
1026
1023
1020
1017
1014
1011
1017
1015
1014
1013
1016
1.4x / year
4.4x / year
We need high-performance & efficient hardware
Evolution of Neural Processing Units
Neural Processing Units (NPUs) are designed to address this challenge
3
Intel Gaudi3
Trainium2
Inferentia2
?
Future NPUs
NPU simulators play a crucial role in designing NPUs
TPU v2
TPU v4
TPU v6
TPU v3
TPU v5
TPU v7
NPU Simulator Requirements – AI Model
4
Source: Tandem Processor
[Ghodrati, Soroush, et al,. ASPLOS 2024]
FFN 2
FFN 1
FFN 3
Router
Mixture-of-Expert
Trainium2
(Training)
Inferentia2
(Inference)
NPU Simulator Requirements – NPU Hardware
5
NPU Core 0
Scalar
unit
Vector
unit
DMA engine
Scratchpad memory
Matrix multiply unit
NPU Core 1
Memory controller
Memory controller
Interconnect
NPU Simulator Requirements – Compiler
6
GEMM
Vector
Operation fusion
TorchInductor
GPU backend
CPU backend
TorchDynamo/
Autograd
PyTorch models
Target machine code
PyTorch
compiler
For compiler support, an NPU ISA must first be defined
NPU ISA
7
Existing NPU Models
8
None of them meets all the key requirements
❌
❌
2019
2020
2021
2022
2023
2024
2025
Timeline
SMAUG, MAESTRO
Timeloop
Stonne
mNPUSim, Sparseloop
GeneSys
Scale-Sim v3
We propose PyTorchSim, which can better satisfy the key requirements for NPU simulation
Contents
PyTorchSim Framework: Overview
10
PyTorch AI model
NPU Simulator
PyTorch 2.x
NPU Backend
Modeling Common Building Blocks in NPU Cores
11
Extensible NPU core
Dataflow unit (e.g., systolic array)
Special function unit
Scalar
unit
Vector
unit
Extensible NPU ISA
RISC-V + �Vector extension
Custom
Instructions
VCIX
DMA engine
Scratchpad memory
VCIX: A Generic Interface for Dataflow Units
12
Vector unit
Serializer
(input)
Deserializer
(output)
Dataflow unit
(e.g., Systolic array)
VCIX
Serializer
(weight)
We adopt VCIX, a generic interface for diverse dataflow units
SiFive
PyTorchSim Compilation Flow
13
PyTorch 2 compiler
TorchInductor
CPU backend
GPU backend
FX graphs
Loop-level IR
torch.compile()
NPU backend
(Ours)
TorchDynamo/Autograd
PyTorch models
RISC-V
binary
MLIR
LLVM
Instruction-Level Simulation (ILS)
14
.insn r 43, 3, 0, zero, t2, t4
.insn r 43, 3, 4, zero, a2, ra
.insn r 43, 3, 5, zero, a2, s8
.insn r 43, 3, 2, zero, a3, s0
add a0, s1, a6
.insn r 43, 3, 0, zero, a7, t4
.insn r 43, 3, 4, zero, a2, ra
.insn r 43, 3, 5, zero, a2, s8
.insn r 43, 3, 2, zero, a0, a5
addi a4, a4, 1
addi s1, s1, 512
addi a5, a5, 1024
bge s3, a4, .LBB0_16
j .LBB0_13
...
add a0, a0, s7
vmv1r.v v11, v6
vle32.v v11, (a0), v0.t
sf.vc.iv 1, 0, v8, 0
sf.vc.iv 1, 0, v9, 0
...
sf.vc.iv 1, 0, v8, 0
sf.vc.iv 1, 0, v9, 0
li s11, 136
bltz s3, .LBB0_21
RISC-V binary (GEMM)
DMA load
Tile A
DMA load
Tile B
Matrix multiply
(~100 instructions)
B MATRIX
A MATRIX
Tile C
C MATRIX
Tile B
GEMM
Tile A
RISC-V
binary
NPU Simulator
Key Insight behind NPU Execution
15
Compute units
Scratchpad memory
NPU Core
Compute units
Scratchpad memory
NPU Core
Interconnect
···
···
DRAM
Memory ctrl.
DRAM
Memoryctrl.
Tile Operation Graph (TOG)
16
Tile Operation Graph (TOG)
DMA
Load Tile A
DMA
Load Tile B
Matrix Multiply
Condition
Loop Start
DMA
Store Tile C
.insn r 43, 3, 0, zero, t2, t4
.insn r 43, 3, 4, zero, a2, ra
.insn r 43, 3, 5, zero, a2, s8
.insn r 43, 3, 2, zero, a3, s0
add a0, s1, a6
.insn r 43, 3, 0, zero, a7, t4
.insn r 43, 3, 4, zero, a2, ra
.insn r 43, 3, 5, zero, a2, s8
.insn r 43, 3, 2, zero, a0, a5
addi a4, a4, 1
addi s1, s1, 512
addi a5, a5, 1024
bge s3, a4, .LBB0_16
j .LBB0_13
...
add a0, a0, s7
vmv1r.v v11, v6
vle32.v v11, (a0), v0.t
sf.vc.iv 1, 0, v8, 0
sf.vc.iv 1, 0, v9, 0
...
sf.vc.iv 1, 0, v8, 0
sf.vc.iv 1, 0, v9, 0
bltz s3, .LBB0_21
RISC-V binary (GEMM)
Matrix multiply
(~100 instructions)
DMA load
DMA load
( X cycles )
Tile-Level Simulation (TLS) Execution Flow
Tile-Level Simulation works in a two-step flow
Offline (compile time)
Online (simulation time)
17
Offline
Tile Operation Graph (TOG)
DMA
Load Tile A
DMA
Load Tile B
Matrix Multiply
(x cycles)
Condition
Loop Start
DMA
Store Tile C
Online
TLS can achieve both high simulation speed and accuracy
PyTorchSim TLS Compilation Flow
18
NPU backend
(Ours)
PyTorch
Runtime
Loop-level IR
Challenge: Tile operation latency can depend on input data!
MLIR
LLVM
Lowering pass
TOG Simulator
(TLS)
Compute�latency
TOG
RISC-V
binary
Data-Dependent Timing Behavior Example
19
SpMspM TOG
DMA
Load Tile A
DMA
Load Tile B
Matrix Multiply
Condition
Loop Start
DMA
Store Tile C
For each specific pair of input tiles,
the compute latency is still deterministic
Sparse matrix multiply unit
Tile
Bk-1
Tile
Ak-1
Tile
Ck-1
Tile
B1
Tile
A1
Tile
C1
Tile
B0
Tile
A0
Tile
C0
…
Latency X0
Latency X1
Latency Xk-1
Data-dependent attributes
PyTorchSim TLS Compilation Flow
20
Compute�latency
TOG Simulator
Data-dependent attributes
PyTorch
Runtime
Input tensors
Output tensors
Spike
Loop-level IR
TOG
MLIR
LLVM
Lowering pass
RISC-V
binary
Putting It All Together
21
PyTorchSim Framework
Interconnect
···
NPU
core
NPU
core
···
DRAM
Mem. ctrl.
···
DRAM
Mem. ctrl.
TOG Simulator
Data-�dependent �attributes
TOG
Compute�latencies
RISC-V
binary
Input tensor
Output tensor
NPU Backend
Spike
PyTorch Runtime
MLIR
LLVM
Lowering pass
PyTorch
models
Data-dep.
attributes
Evaluation Methodology
Accuracy validation
Simulation speed
Workloads
22
| Cores & clock | Systolic arrays | Vector lanes (# of ALUs) | Scratchpad | DRAM |
TPU v3 | 1 core @ 940 MHz | (128x128) x 2 | 128 (16 ALUs each) | 32 MB | 4 HBM2 (960 GB/s) |
Evaluation: Validation against Real TPU v3
23
Relative Error
Better
150%
100%
50%
0%
-50%
-100%
860%
GEMM
(NxNxN)
PyTorchSim can accurately simulate full models end-to-end
55%
124%
60%
47%
12%
Evaluation: Speedup
24
Better
100
10
1
0.1
Speedup
140
109
9x
48
7.4x
PyTorchSim achieves significant simulation speedup
Contents
25
CS1: Impact of DNN Training Hyperparameter�
26
MLP
Training loss
Norm.
NPU cycles
4.6x
PyTorchSim enables studying training time behaviors of systems
CS2: Impact of Data Placement for Chiplet-based NPUs
27
NPU
core 0
D2D
NPU
core 1
D2D
DRAM 1
(480 GB/s)
DRAM 0
(480 GB/s)
Local traffic
(High bandwidth)
Remote traffic
(Low bandwidth)
Chiplet interconnect
(64 GB/s, 20 ns)
CS2: Impact of Data Placement for Chiplet-based NPUs
28
Output matrix
(0,0)
(1,0)
(0,1)
(1,1)
NPU
core 1
NPU
core 1
NPU
core 0
NPU
core 0
NPU
core 0
NPU
core 0
NPU
core 1
NPU
core 1
Weight matrix
DRAM 0
DRAM 1
Input matrix
DRAM 0
DRAM 1
Remote
Local
Worst mapping
Local
25%
Remote
75%
Best mapping
Local
75%
Remote
25%
CS2: Impact of Data Placement for Chiplet-based NPUs
29
Norm. Runtime
Better
3.4x
3.0x
PyTorchSim enables the study of diverse NPU architectures
More Results and Discussions in the Paper
Case studies
Discussions
30
Summary
31
PyTorchSim is Open Source
32
GitHub Link
Backup
33
Comparison of the features of different NPU sim.
34
Compilation flow with simplified example IR
35
Tile Operation Graph
36
Tile Operation Graph (TOG)
DMA
Load Tile A
DMA
Load Tile B
Matrix Multiply
Condition
Loop Start
DMA
Store Tile C
( X cycles )
Custom Instructions
37
CS3: Heterogeneous Dense-Sparse NPU
37
Third-party core integration
Providing core abstraction interfaces
NPU with third-party core
Interconnect
Sparse Core
(Ex. Flexagon)
···
DRAM
Mem. ctrl.
···
DRAM
Mem. ctrl.
CS3: Heterogeneous Dense-Sparse NPU
37
Norm. Performance
Dense core
(Dense GEMM)
Sparse core
(Sparse GEMM, 95% sparsity)
Good
Norm. Performance
Dense core
(Dense GEMM)
Sparse core
(Sparse GEMM, 95% sparsity)
Good
-40%
+23%
System-driven Requirements
Requirements for modern NPU architecture design
40
Source: Source Hot Chips 2025, “Ironwood,” Aug 26, 2025, PDF (slide 15)
Interconnect
DRAM
Vector Unit
Dataflow Unit
Why AI compiler support matters
41
torch.compile speedup over w/o compile on A100
+38%
+76%
+52%
Understanding Tile Operation Graph
42
Tile Operation Graph (TOG)
DMA
Load Tile A
DMA
Load Tile B
Matrix Multiply
Condition
Loop Start
DMA
Store Tile D
Vector compute
B MATRIX
A MATRIX
Tile C
C MATRIX
Tile D
D MATRIX
Apply ReLU
Tile B
Tile A
GEMM + ReLU