Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PyTorch-AI-Compiler.pdf

Avatar for Tommy Han Tommy Han
August 07, 2026
51

 PyTorch-AI-Compiler.pdf

Avatar for Tommy Han

Tommy Han

August 07, 2026

Transcript

  1. About me • Not working with ML/LLM Compiler on daily

    basis. • One of the Compiler Meetup Host in Hong Kong • Software Engineer
  2. Before we begin… A few things to mention This is

    not a “how to tune/train your model better” talk -> Leave to Mathematicians! Expect you to know some ML Basics (Matrix Multiplication), Tensor Basics Expect you to know how a pipeline-based compiler works. Feel free to ask questions, and point out the mistakes I made!
  3. Agenda What are we going to talk about… Level 0:

    Background Build Up! Level 1: What actually is ML/LLM Compiler Level 2: Why ML/LLM Compiler is important
  4. Level 0 Mostly starts with PyTorch… • Start with PyTorch(or

    sth else), build up datasets and training • Export the training data to graph (Done by ATenGraph/StableHLO) • Graph will getting to the compiler for optimization -> Output • Inferencing • Runtime (e.g. vLLM, ONNX, llama.cpp, etc)
  5. Level 0 When the Model is Compiled and ready… •

    Runtime running on Hardwares • LLM Applications (The stu we ff fl mostly using.) e.g. generation, RAG, Inferencing API, chatbots, agents, AI work ows.
  6. Level 0 What are the hardwares? • GPU (Most Common)

    • SoC Chips (e.g. Apple M-Chips) • TPUs • Custom Made NPUs
  7. Level 0 Why there are new types of hardware? •

    Accelerate Graph Computation • Build Speci c Instruction Sets to handle the maths calculations easier. fi (will talk about that later)
  8. Level 0 Where is the compiler? Between runtime and Hardware.

    It is similar to normal compilers. ff But the details are di erent.
  9. Level 1 Then, what Actually is a ML/LLM Compiler? ffi

    An ML/LLM Compiler transforms high-level tensor computations into e cient programs for the target hardware.
  10. Level 1 What is a tensor operation? A tensor operation

    describes what to compute. fi The compiler gures out how to compute it.
  11. Level 2 The Math is Simple, execution is expensive Model

    says: Y = GELU(X @ W + b) But execution involves: • Huge tensor operations • Large memory movement • Many GPU kernels ff • Di erent hardware architectures
  12. Level 2 Hardware is highly specialized CPU → vectorization →

    cache locality GPU → thousands of threads → shared memory → Tensor Cores NPU → specialized matrix units fi → speci c data layouts
  13. Last words And the beginning… • Knowing what’s under the

    hood is great! ff • Try out di erent frameworks for helping you building LLMs!