1 of 42

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

2 of 42

AI Model & Hardware Trends

  • Deep Neural Network (DNN) are growing exponentially in size
  • Hardware performance improves relatively slowly

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

3 of 42

Evolution of Neural Processing Units

Neural Processing Units (NPUs) are designed to address this challenge

  • Efficient dataflow units (e.g., systolic arrays, adder-tree)

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

4 of 42

NPU Simulator Requirements – AI Model

  • Both inference and training are important
  • (Vector) operations are becoming increasingly diverse
  • Sparsity is now widely exploited for efficiency
    • Latency varies with input data (i.e., data-dependent timing behavior)

4

Source: Tandem Processor

[Ghodrati, Soroush, et al,. ASPLOS 2024]

FFN 2

FFN 1

FFN 3

Router

Mixture-of-Expert

Trainium2

(Training)

Inferentia2

(Inference)

5 of 42

NPU Simulator Requirements – NPU Hardware

  • Need to accurately model key components of modern NPUs
  • NPU core: matrix, vector, and scalar units and scratchpad memory
  • Shared resources: interconnect and DRAM
    • Detailed simulation often necessary to model inter-core contention

5

NPU Core 0

Scalar

unit

Vector

unit

DMA engine

Scratchpad memory

Matrix multiply unit

NPU Core 1

Memory controller

Memory controller

Interconnect

6 of 42

NPU Simulator Requirements – Compiler

  • Necessary to bridge AI models and NPU hardware
  • Lowers DNN models into machine code
  • Apply various optimizations
  • Enables full-model simulation for both inference and training

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

7 of 42

NPU ISA

  • No de-facto standard ISA for NPUs (unlike CPUs and GPUs)

  • RISC-V can be a strong candidate for an NPU ISA
    • Generality:
      • Vector-length agnostic design
      • A generic interface (VCIX) for dataflow units
    • Extensibility: Reserved opcode space for custom instructions
    • Openness: Contributions from both academia and industry
    • SW Infrastructure: Rich software ecosystem (e.g., compilers, simulators)

7

8 of 42

Existing NPU Models

  • Various NPU simulators and analytical models have been proposed

8

    • Full AI model support
    • NPU core & shared resources
    • Fast & accurate simulation
    • AI compiler support

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

9 of 42

Contents

  • Background / Motivation
  • PyTorchSim
    • PyTorchSim overview
    • NPU core modeling
    • Compilation flow
  • Methodology & Evaluation
  • Case study
    • Impact of DNN Training Hyperparameter
    • Scheduling for Chiplet-based NPUs
  • Summary

10 of 42

PyTorchSim Framework: Overview

10

PyTorch AI model

  • Runs PyTorch models directly

NPU Simulator

  • General and extensible architecture
  • Fast & accurate simulation
  • Compiles the models to a RISC-V based NPU ISA

PyTorch 2.x

NPU Backend

11 of 42

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

  • Scalar unit
  • Vector unit
  • DMA engine
  • SFU.
  • Dataflow unit

RISC-V + �Vector extension

Custom

Instructions

VCIX

DMA engine

Scratchpad memory

12 of 42

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

13 of 42

PyTorchSim Compilation Flow

  • NPU backend generates a RISC-V binary
    • Applies target-dependent optimizations

13

PyTorch 2 compiler

TorchInductor

CPU backend

GPU backend

FX graphs

Loop-level IR

torch.compile()

NPU backend

(Ours)

  • Benefits of integration with PyTorch 2
    • Simulate existing PyTorch models without any need for manual conversion
    • Supports training simulation through� PyTorch’s auto-differentiation
    • Leverage existing target-independent optimizations

TorchDynamo/Autograd

PyTorch models

RISC-V

binary

MLIR

LLVM

14 of 42

Instruction-Level Simulation (ILS)

  • Simulate every single instruction one-by-one
  • Inherently slow

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

15 of 42

Key Insight behind NPU Execution

15

Compute units

Scratchpad memory

NPU Core

Compute units

Scratchpad memory

NPU Core

Interconnect

···

···

DRAM

Memory ctrl.

DRAM

Memoryctrl.

  • NoC & DRAM latencies remain�non-deterministic due to �inter-core contention and traffic
  • Intra-core compute latency is deterministic

16 of 42

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 )

17 of 42

Tile-Level Simulation (TLS) Execution Flow

Tile-Level Simulation works in a two-step flow

Offline (compile time)

  • Obtain the deterministic compute latency in the TOG

Online (simulation time)

  • Reuse the obtained compute latency
  • Model DMAs with detailed NoC & DRAM�simulators (bookism, ramulator2)

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

18 of 42

PyTorchSim TLS Compilation Flow

  • Gem5 (timing simulator) models the compute latency for TLS

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

19 of 42

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

20 of 42

PyTorchSim TLS Compilation Flow

  • Spike (functional simulator) executes the binary with PyTorch input:
    • To obtain data-dependent attributes
    • To validate correctness of compiled binary

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

21 of 42

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

22 of 42

Evaluation Methodology

Accuracy validation

  • Target: Real Google TPU v3
  • Baselines: SCALE-Sim v3, mNPUSim, Timeloop, MAESTRO

Simulation speed

  • Baselines: Accel-Sim, mNPUsim
    • We selected Accel-Sim for its rich features and GPUs’ dominance in deep learning

Workloads

  • Kernels: GEMM, convolution, layer normalization, softmax, attention
  • Full models: ResNet18/50, Bert-base/large

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)

23 of 42

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%

24 of 42

Evaluation: Speedup

24

Better

100

10

1

0.1

Speedup

140

109

9x

48

7.4x

PyTorchSim achieves significant simulation speedup

25 of 42

Contents

  • Background / Motivation
  • PyTorchSim
    • Overview
    • NPU core modeling
    • Compiler workflow
  • Methodology & Evaluation
  • Case Studies (CS)
    • Impact of DNN training hyperparameter
    • Impact of data placement for chiplet-based NPUs
  • Summary

25

26 of 42

CS1: Impact of DNN Training Hyperparameter�

26

MLP

Training loss

Norm.

NPU cycles

4.6x

PyTorchSim enables studying training time behaviors of systems

27 of 42

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)

28 of 42

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%

29 of 42

CS2: Impact of Data Placement for Chiplet-based NPUs

29

  • High remote traffic becomes the severe bottleneck

Norm. Runtime

Better

3.4x

3.0x

PyTorchSim enables the study of diverse NPU architectures

30 of 42

More Results and Discussions in the Paper

Case studies

  • Heterogeneous dense-sparse NPU
  • DNN inference with multi-model tenancy
  • Compiler optimization impact

Discussions

  • Extension for other deep learning frameworks
  • Extension for modeling GPUs and large-scale systems

30

31 of 42

Summary

  • AI workloads require a comprehensive, fast, and accurate simulator

  • To address this, we propose PyTorchSim
    • High-speed, high-accuracy through our Tile-Level Simulation (TLS)
    • Integration with PyTorch 2 compilation flow
    • General and extensible architecture through a RISC-V-based NPU ISA

  • Compared to prior NPU simulators, PyTorchSim:
    • Enables various case studies not supported by prior simulators
    • Significantly improves accuracy and simulation speed

31

32 of 42

PyTorchSim is Open Source

  • Contributions are welcome!

32

GitHub Link

33 of 42

Backup

33

34 of 42

Comparison of the features of different NPU sim.

34

35 of 42

Compilation flow with simplified example IR

  • PyTorchSim backend generates MLIR code
    • MLIR’s affine, arith, linalg, memref, vector, llvm, etc., which are widely used in AI compilers, are adopted to represent the LLIR.

35

36 of 42

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 )

37 of 42

Custom Instructions

37

38 of 42

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.

39 of 42

CS3: Heterogeneous Dense-Sparse NPU

37

Norm. Performance

Dense core

(Dense GEMM)

Sparse core

(Sparse GEMM, 95% sparsity)

Good

  • Dense access patterns are favored

  • Takeaway: Memory scheduling must be carefully designed to ensure fairness

Norm. Performance

Dense core

(Dense GEMM)

Sparse core

(Sparse GEMM, 95% sparsity)

Good

-40%

+23%

40 of 42

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

41 of 42

Why AI compiler support matters

  • Modern deep learning frameworks now integrate AI compilers
  • Compiler optimizations have a huge impact on hardware performance

41

torch.compile speedup over w/o compile on A100

+38%

+76%

+52%

42 of 42

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