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.

1,068 pages that take you from a single transistor to writing production GPU kernels — and to building an ML compiler of your own.

Browse the contents

₹5,999 Launch price — 42% off

1,068
pages
63
chapters
9
parts
lifetime updates
Cover of Machine Learning Compilers by Laxmen Murali
PDF · 96 MB Delivered in ~60s 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 the difference between a model that costs ₹4 crore a year to serve and one that costs ₹40 lakh — 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 1,068-page book is not padding; it is the honest size of the gap between "I can train a model" and "I can explain, in cycles, why this kernel is 12× slower than the roofline says it should be." 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
  • CS 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
Language
English
Size
96 MB

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 → 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, not hand-waved.

Real stacks, dissected

TVM, PyTorch Dynamo/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: design, IR, passes, backend, 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 excerpt is being prepared and will appear here shortly. In the meantime, the full table of contents above lists every one of the 63 chapters and the page each begins on.

  • 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 1,068-page 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.

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.

Isn't 1,068 pages excessive?

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.

Can I expense this?

Yes. Razorpay issues a payment receipt to your email, and we're happy to send a written invoice on request for reimbursement.

What's the refund policy?

Because the book is delivered instantly and in full, purchases are non-refundable once access has been granted. Read the free sample first — it exists so you can be sure before you buy. If delivery genuinely fails on our side and we can't fix it, you get a full refund.

Can I share my copy?

Please don't. Access is tied to your email address and this is an independently written book — one person, no publisher. Sharing it is the difference between there being a second edition and there not being one.

LM

About the author

Laxmen Murali

Compute engineer · AI-HPC and ML compilers

I'm a compute engineer working on AI-HPC and machine learning compilers. My work sits in the gap between a model and the silicon it runs on — which is where most of the performance in modern AI is quietly won or lost.

I wrote this book because I couldn't find it. There is excellent material on classical compilers, and excellent material on machine learning, and almost nothing that builds the bridge between them from first principles. Every route into this field seemed to assume you had already walked most of it — that you already knew SSA, or CUDA, or why a cache line matters — and just needed the ML-specific parts filled in. If you didn't, you were left assembling the picture yourself from papers, source code and conference talks.

So this is the book I wanted when I started: one that begins at a single switch and doesn't skip a rung on the way to writing an operator fusion pass. ML compilers are among the highest-leverage skills in the industry right now, and the barrier to entry is far more a documentation problem than a difficulty problem. This is my attempt at removing it.

Independently written and self-published. There is no publisher, no team and no marketing budget behind this — every rupee goes directly to the person who wrote it.

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

1,068 pages, 63 chapters, one download. Delivered to your inbox in about a minute.

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