Skip to content
First edition, 2026 · Out now

Machine Learning Compilers

A first-principles course: computers, compilers, GPUs, and the systems that make AI fast.

A first-principles path that takes you from a single transistor to writing production GPU kernels, and then to building an ML compiler of your own.

Read the free sample

₹5,999 Launch price, 42% off

63
chapters
9
parts
PDF
format
Free
updates
Cover of Machine Learning Compilers by Laxmen Murali
PDF download Delivered in about a minute Free updates

The book

Why a book this long exists

Every time a model runs fast, a compiler made a decision. It fused two operators so a tensor never touched DRAM. It picked a tile size that kept the L2 warm. It chose bf16 over fp32 and proved the numerics still held. Those decisions are where most of the performance in modern AI comes from, and almost nobody outside a handful of teams understands how they are made.

This book is the missing curriculum. It starts at the switch, a physical thing that is either on or off, and does not stop until you have designed an intermediate representation, written the optimisation passes that walk it, generated code for a GPU, and benchmarked the result against PyTorch. There is no chapter where you are asked to accept something on faith.

It is deliberately long. A book this size is not padding; it is the honest measure of the gap between "I can train a model" and "I can explain, in cycles, why this kernel falls short of what the roofline says it should achieve." Every chapter carries the same nine sections: a story, the theory, the mathematics, the engineering reality, a performance analysis, a build-it exercise in real code, a debugging guide, interview questions, and the misconceptions that trip people up.

Who it's for

  • ML engineers who are tired of `torch.compile` being a black box
  • Compiler engineers moving from classical backends into the AI stack
  • Systems and performance engineers targeting GPUs and accelerators
  • Students who want the whole ladder, not one rung of it
  • Anyone preparing for ML-compiler, CUDA, or performance-engineering interviews

What you need to know first

You should be able to write a program in any language. That's it. Python and C++ are taught from scratch where the book needs them, and no prior compilers, CUDA, or machine-learning background is assumed.

Format
PDF
Pages
1,068
Chapters
63
Language
English

What makes it different

Six things most compiler books skip

Every chapter follows the same nine-part structure, so you always know where the theory ends and the measured reality begins.

Genuinely first principles

Chapter 1 begins with a switch and ends with you having built a working CPU simulator, TOY-100, in Python. Every abstraction above it is constructed, not assumed.

The whole stack, one narrative

Logic gates, caches, C++, SSA, LLVM, MLIR, tensors, transformers, CUDA, fusion, Triton and FlashAttention. One continuous thread, not nine disconnected books.

You build things, constantly

A cache simulator in 25 lines. malloc-lite. A bytecode interpreter running real CPython opcodes. A register allocator. And finally, a complete ML compiler.

Performance treated as a science

Roofline, Amdahl, Gustafson, Little's Law, tail percentiles, and the seven ways benchmarks lie, applied to measured numbers rather than hand-waved ones.

Real stacks, dissected

TVM, PyTorch Dynamo and Inductor, XLA, IREE, Triton, TensorRT and ONNX Runtime. What each one actually does differently, and why.

Written for the interview and the job

Every chapter ends with the questions that get asked at compiler teams, the mistakes that get made in review, and the debugging playbook for when it breaks in production.

Table of contents

63 chapters, nine parts, one continuous argument

Each part assumes only what came before it. Expand any part to see every chapter and the page it starts on.

I Foundations of Computing How machines actually compute: switches, binary, memory, CPUs, caches, and the discipline of performance.
  1. 1 What Is a Computer? From Switches to Thinking Machines p.1
  2. 2 Binary: The Language of Machines p.34
  3. 3 Memory: The Computer’s Notebook p.65
  4. 4 The CPU: The Engine of Computation p.89
  5. 5 Caches and the Memory Hierarchy p.109
  6. 6 Processes, Threads, and Virtual Memory p.127
  7. 7 Performance: Thinking Like a Speed Engineer p.145
II Programming and Systems The languages compilers consume and are written in: semantics, pointers, data structures, Python internals, and modern C++.
  1. 8 What Is Programming? Variables, Types, and Functions p.164
  2. 9 Pointers, References, and the Shape of Memory p.184
  3. 10 Recursion and the Call Stack p.201
  4. 11 Data Structures: Organizing Information p.217
  5. 12 Algorithms and Complexity p.234
  6. 13 Python: How the Interpreter Really Works p.251
  7. 14 C++ for Systems and Compiler Engineers p.267
III Compiler Fundamentals The classical pipeline end to end: lexing, parsing, ASTs, SSA, dataflow, optimization, codegen, LLVM and MLIR.
  1. 15 What Is a Compiler? The Grand Tour p.283
  2. 16 Lexing: Turning Characters into Words p.299
  3. 17 Parsing: Turning Words into Structure p.314
  4. 18 ASTs and Semantic Analysis p.330
  5. 19 Intermediate Representations and SSA p.344
  6. 20 Control Flow Graphs and Data Flow Analysis p.359
  7. 21 Classical Optimizations p.374
  8. 22 The Backend: Instruction Selection, Scheduling, Register Allocation, Codegen p.388
  9. 23 LLVM: The Industry Workhorse p.403
  10. 24 MLIR: The Compiler Construction Kit p.417
IV Mathematics and Machine Learning Tensors, numerical precision, and the models themselves, from linear algebra to transformers and LLMs.
  1. 25 Vectors and Matrices from First Principles p.431
  2. 26 Tensors, Broadcasting, and Memory Layout p.445
  3. 27 Numerical Precision: FP32, FP16, BF16, FP8, INT8 p.459
  4. 28 What Is Machine Learning? p.476
  5. 29 Neural Networks and Backpropagation p.492
  6. 30 Convolutional Neural Networks p.509
  7. 31 Transformers and Attention p.526
  8. 32 Training, Inference, and Large Language Models p.543
V GPUs and Parallel Hardware Why accelerators won, the SIMT model, the GPU memory hierarchy, and tensor-core scheduling.
  1. 33 Why GPUs? The Parallel Revolution p.560
  2. 34 CUDA and the SIMT Programming Model p.576
  3. 35 The GPU Memory Hierarchy p.592
  4. 36 Tensor Cores, Occupancy, and Kernel Scheduling p.608
VI Inside an ML Compiler Graph IR, shape inference, fusion, scheduling, memory planning, cost models, and kernel generation.
  1. 37 Anatomy of an ML Compiler: Graph IR and Tensor IR p.625
  2. 38 Shape Inference and Graph Optimization p.642
  3. 39 Operator and Kernel Fusion p.659
  4. 40 Scheduling: Separating What from How p.677
  5. 41 Memory Planning p.694
  6. 42 Cost Models and Auto-Tuning p.710
  7. 43 Kernel Generation p.726
VII Production Compiler Stacks TVM, PyTorch 2 (Dynamo/Inductor), XLA, IREE, Triton, TensorRT and ONNX Runtime, dissected.
  1. 44 TVM: The Full-Stack Pioneer p.741
  2. 45 PyTorch Compilation: FX, Dynamo, and Inductor p.756
  3. 46 XLA and OpenXLA p.771
  4. 47 IREE and the MLIR-Based Stacks p.785
  5. 48 Triton: Python-to-GPU Kernels p.799
  6. 49 TensorRT and ONNX Runtime p.813
VIII High-Performance Kernels GEMM to near-peak, convolutions, FlashAttention, reductions, loop craft, serving, parallelism and quantization.
  1. 50 GEMM: From Naive to Near-Peak p.827
  2. 51 Convolution Kernels p.840
  3. 52 Attention Kernels and FlashAttention p.854
  4. 53 Normalization, Activations, and Reductions p.869
  5. 54 Advanced Loop Craft p.884
  6. 55 Inference Serving: KV Cache, Continuous Batching, and Speculative Decoding p.899
  7. 56 Parallelism: Tensor, Pipeline, and Expert p.915
  8. 57 Quantization p.931
IX Build Your Own ML Compiler A capstone covering design, IR, passes, backend and testing, plus how real teams and careers work.
  1. 58 Design and Architecture p.949
  2. 59 Building the IR and Optimization Passes p.965
  3. 60 The Backend and Code Generation p.979
  4. 61 Testing, Benchmarking, and Debugging p.992
  5. 62 How Real Teams Build ML Compilers p.1006
  6. 63 The Road Ahead: Careers, Interviews, and the Future p.1020

Sample pages

Read a chapter before you decide

A free 67-page excerpt: the full table of contents plus complete chapters, exactly as they appear in the book. No email required, no signup.

  • Every chapter opens with a story and closes with interview questions
  • Build-it sections contain runnable Python and C++, not pseudocode
  • Performance claims are measured, with the numbers shown

Readers

Be one of the first readers

This is a first edition, published independently and released recently, so there are no reader reviews here yet, and we'd rather show you nothing than show you something invented.

The table of contents and the free sample are the honest evidence available. Read them, and judge the book on those.

FAQ

Questions people actually ask

Something not covered here? Email laxmenmuralii@gmail.com . Replies usually come the same day.

What exactly do I get after paying?

Within a minute of payment, you receive an email at the address you entered at checkout with access to the full PDF in Google Drive. Access is granted to that specific email address.

Do I need a Google account?

Yes. The book is delivered through Google Drive, so you'll need to be signed in to a Google account using the same email address you gave at checkout. If you use a non-Google address, write to us right after purchase and we'll sort out access for you.

Are purchases refundable?

All purchases are final. Because the book is delivered in full immediately after payment, orders cannot be cancelled or refunded once access has been granted. The sole exception is a delivery failure that cannot be resolved, in which case a full refund is issued.

Can I share or resell it?

No. The book is copyrighted, and sharing, reselling, uploading or redistributing it in any form is prohibited. Your access is tied to your email address and is licensed to you alone.

I didn't receive the email. What now?

Check spam and promotions first. If it still isn't there after 10 minutes, email us with your Razorpay payment ID and we'll re-issue access immediately. Every payment is recorded on our side, so nothing is ever lost.

Do I need to know compilers or CUDA already?

No. The book is built for exactly the opposite case. It starts at logic gates and teaches Python, C++, compiler theory, linear algebra, machine learning and GPU programming as it needs them. If you can write a program in any language, you can read this.

Can I see some of it before buying?

Yes. A free 67-page excerpt is available on this page, with the complete table of contents and full chapters exactly as they appear in the book. No email or signup required.

Isn't the book excessively long?

It's the honest length. The distance between using a model and understanding why it runs at the speed it does spans hardware, systems, languages, compilers, numerics and ML. Any book that covers that in 300 pages is skipping something you'll later have to learn anyway.

Is there a print edition?

Not currently. The book is digital-only, which is also why it can be revised as the field moves.

Do I get future updates?

Yes. Revisions to this edition are free and permanent. The same Drive file is updated in place, so you always see the current version without doing anything.

What can I do with the code in the book?

Use it freely, including in commercial work. The code examples exist to be run and built upon. It is the text, diagrams and the book itself that are copyrighted.

Photograph of Laxmen Murali

About me

Laxmen Murali

Compute engineer, GPU performance and AI computing

I am a compute engineer working on GPU performance and AI computing. My work sits in the gap between a model and the hardware it runs on, which is where most of the performance in modern AI is quietly won or lost.

When I was trying to learn machine learning compilers, I could not find a single place to learn it from. There is good material on classical compilers and good material on machine learning, but nothing that went from the fundamentals all the way to production systems in one piece. Everything I picked up assumed I already knew half of it, so I ended up building the picture myself out of papers, source code and conference talks.

So I decided to curate the book I had been looking for. It is written for engineers and students who want to get into this field and would rather not spend a year piecing it together the way I did. One path, from a transistor to a working compiler, with nothing quietly skipped.

Contact

Get in touch

There is one person behind this store, and he reads every email.

If you've paid and something went wrong, include your Razorpay payment ID (it starts with pay_). That lets us find and fix your order in seconds.

Stop treating the compiler as a black box

63 chapters across 9 parts, one download. Delivered to your inbox in about a minute.

Read the FAQ
  • Razorpay-secured payment
  • Instant email delivery
  • Free lifetime updates