cs249r_book

harvard-edge活跃维护 有专家点评

哈佛 CS249r 的机器学习系统教材,覆盖基础、扩展、智能体 AI 与具身 AI 四卷,系统讲解从云端到边缘的 ML 系统设计与工程实践。

Machine Learning Systems: Foundations, Scaling, Agentic AI, and Physical AI (Vols I–IV) • Harvard CS249r | https://mlsysbook.ai

vol2-v0.3.1发布于 2026-11-06 16:33 UTC30,132star +121 / 7 天3,739fork同步于 2026-11-10 23:23 UTC

专家点评

上手难度:进阶更新于 2026-11-11

一套从单机到集群再到 Agent 的机器学习系统教材,配可动手的 TinyTorch 和模拟器,不是框架

适用场景

  • 团队新人补 MLSys 基础:从约束推导架构取舍的讲法比零散博客成体系,换别的就得自己拼课程
  • 想理解训练/推理内部机制:TinyTorch 让你从零写一遍反向传播和调度,比读 PyTorch 源码门槛低
  • 教学或内训出课件:Labs、Slides、Kits 成套,自己从零做成本高得多
  • 讨论超实验室规模的系统行为:MLSys·im 能在没有集群的条件下演示调度和扩展性,真机验证不现实时是替代方案

踩坑

  • 想直接 pip install 跑起来会撞墙:README 没给安装命令,TinyTorch 的安装路径在 issue 里被报过 404,得按仓库内文档逐步配
  • 依赖 Vol III/IV 内容做方案会撞上变动:这两卷仍在开发,Vol II 也只是预览版,章节结构和示例可能随时改
  • 用中文等翻译版对照英文最新页会不一致:翻译对应旧版页面,读的时候要以英文原版为准
  • 把 Kits 当标准硬件清单会踩空:README 没列型号和显存门槛,采购前得自己确认

同类对比

想要现成框架而非教材,看 PyTorch/TensorFlow 官方教程或 MLSys 课程(如 CMU 15-884);只想学 Agent 编排,直接读 LangGraph、AutoGen 的文档更省时间

怎么上手

由 README 提炼,执行前请确认
README 未给出安装命令
硬件要求按 README 说明

README 未说明具体硬件要求;配套 Kits 涉及可上手的硬件设备,但未列出型号或显存门槛

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

哈佛 CS249r 开源教材系列,讲机器学习系统怎么建、为什么这么建,配可动手的工具

哈佛 CS249r 的机器学习系统教材,覆盖基础、扩展、智能体 AI 与具身 AI 四卷,系统讲解从云端到边缘的 ML 系统设计与工程实践。

核心能力

  • 四卷教材覆盖单机、集群、Agent 与具身智能
  • TinyTorch 让学生亲手搭出训练与推理机制
  • MLSys·im 模拟器演示超出单实验室规模的系统行为
  • 配套 Labs、Kits、Slides 与教师资源
  • 每章从约束出发,用可复算的数字讲架构取舍

容易踩的坑

Vol II 为预览版、Vol III 与 Vol IV 仍在开发中,内容变动频繁;中文等翻译版本对应的是旧版页面,可能已过时;各组件许可证不同,使用前需逐项确认

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本vol2-v0.3.1
  1. slides-v0.1.1Slides v0.1.1: Publish updated Volume I and II lecture materials2026-11-06 · 2026-11-06 18:27 UTC
    查看更新说明

    Slides 0.1.1 updates the lecture materials and portal for Volumes I and II.

    • Rebuild and revise decks around the book's chapter sequence, with selected Volume I topics split into paired lectures.
    • Revise figures, typography, speaker notes, activities, and lecture-to-lecture connections; connect calculated examples to shared modeling inputs and retain source-specific assumptions.
    • Add mechanical checks for deck structure and visual fit, improve chapter-to-slide links, and carry speaker notes into PowerPoint exports.

    The live portal and MLSysBook slide archives include Volumes I and II only. Volume III and Volume IV decks remain outside this live release. PowerPoint slides are images of PDF pages, with speaker notes in the notes pane; slide text is not editable.

    Portal: https://mlsysbook.ai/slides/ PDF and PowerPoint downloads: https://github.com/harvard-edge/cs249r_book/releases/tag/slides-latest

  2. tinytorch-v0.2.2TinyTorch v0.2.2 - Publish TinyTorch updates and portable exercise timing2026-11-06 · 2026-11-06 18:05 UTC
    查看更新说明

    TinyTorch 0.2.2 updates teaching exercises and the Module 01 broadcasting explanation.

    • Use a high-resolution interval clock in activation and data-loader timing exercises, avoiding zero-duration wall-clock readings on short runs such as those reported on Windows.
    • Report nonpositive intervals as unmeasurable instead of dividing by zero when calculating timing comparisons.
    • Clarify vector broadcasting and organize the example headings.

    Site: https://mlsysbook.ai/tinytorch/

    These timing changes affect the exercises; they do not establish a framework speedup or benchmark result.

  3. staffml-v0.1.4StaffML v0.1.4 — Publish StaffML updates and service hardening2026-11-06 · 2026-11-06 16:33 UTC
    查看更新说明

    StaffML 0.1.4 updates the question vault, taxonomy navigation, and service source.

    • Correct hardware assumptions and worked reasoning in questions about mobile memory bandwidth, batch-one decoding weight reads, and edge-device rooflines.
    • Update taxonomy labels and relationships, preserve subject/concept filtering in practice links, and revise vault authoring/schema checks.
    • Replace provider response bodies and arbitrary exceptions in interviewer diagnostics with bounded error codes and HTTP statuses.
    • Harden analytics origin checks, submitted-event validation, aggregate key handling, and summary authorization; document service and storage boundaries.

    Site: https://mlsysbook.ai/staffml/

    This release includes service-source changes; a site release does not by itself establish deployment of every Worker. Analytics filtering does not guarantee that submitted data contains no personal information.

  4. vol2-v0.3.1vol2-v0.3.1: Publish SocratiQ and Volume II updates最新正式版2026-11-06 · 2026-11-06 16:33 UTC

    Volume II 0.3.1 restores SocratiQ in the online book and updates the text, figures, and printed layout.

    • Select a passage for an explanation, ask follow-up questions, and open quizzes or flashcards alongside the reading. A skippable first-use tour and optional learning preferences explain and adjust the workflow.
    • The updated SocratiQ guide explains keyboard and touch controls, browser-local study records, and the passage and preferences sent for AI help. Reader conversations remain in page memory.
    • Chapter revisions improve paragraph flow and connections between systems topics. The reference training job now uses a shared step definition; figure, equation, and appendix changes address presentation and printed-page fit.

    PDF and EPUB editions are attached. AI explanations and quiz feedback can be mistaken; they are study aids, not evidence of mastery.

  5. vol1-v0.8.1vol1-v0.8.1: Publish SocratiQ and Volume I updates2026-11-06 · 2026-11-06 16:33 UTC
    查看更新说明

    Volume I 0.8.1 restores SocratiQ in the online book and updates the text, figures, and printed layout.

    • Select a passage for an explanation, ask follow-up questions, and open quizzes or flashcards alongside the reading. A skippable first-use tour and optional learning preferences explain and adjust the workflow.
    • The updated SocratiQ guide explains keyboard and touch controls, browser-local study records, and the passage and preferences sent for AI help. Reader conversations remain in page memory.
    • Chapter revisions clarify scope and narrative connections, qualify overstated claims, and move derived values into rerunnable calculations. Figure and equation changes address presentation and printed-page fit.

    PDF and EPUB editions are attached. AI explanations and quiz feedback can be mistaken; they are study aids, not evidence of mastery.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Machine Learning Systems


    Why This Curriculum Exists

    AI engineering is the discipline of building efficient, reliable, and safe intelligent systems that operate in the real world, not models in isolation. It deserves a place alongside software engineering and computer engineering, and this curriculum teaches it the way computer architecture has long been taught, from first principles and with numbers a student can recompute.

    Those numbers come from constraints. A model that scores well on a benchmark still has to fit in memory, meet a latency budget, stay within a power limit, and fail safely in front of real people. These constraints decide the architecture, and they follow laws that outlast any framework or chip. Memory bandwidth, network latency, energy, and failure rates govern a microcontroller with 256 KB of memory and an accelerator in a datacenter alike, even though the two differ in scale by many orders of magnitude. I learned this while working on TinyML at Google, and it became the idea that runs through every volume: constraints drive architecture.

    Teaching AI engineering this way takes more than a book, which is why everything lives in one repository. Each part teaches something the others cannot. Students who only read do not internalize, and students who only code do not generalize. The textbook builds the mental model, TinyTorch makes it concrete by having students build the machinery themselves, and the hardware kits and the MLSys·im simulator show where the model breaks, on devices students can hold and at scales beyond any one lab.

    The work began in a classroom. The HarvardX TinyML course came first and reached more than 100,000 learners. In 2023, the students in CS249r at Harvard wrote the first class notes for this curriculum together, one topic per group, and we published them on GitHub. Since then, I have kept revising the material with help from a growing community of contributors, and instructors at universities around the world now teach from it. The goal is to reach one million learners by 2030, because the world is building AI factories faster than it is training AI engineers.


    What You Will Learn

    Each chapter connects an idea a reader may already know from machine learning to the systems that make it work in practice.


    The Four Volumes

    The textbook spans four volumes. Each one widens the boundary of the system and raises the cost of failure, so the volumes differ in scope, not in depth.

    Each volume answers a question the previous one leaves open.

    • Vol I → Vol II, when one machine is not enough. Volume I covers single-machine execution, memory walls, and kernel efficiency. Volume II carries those foundations across thousands of accelerators, collective communication, fault-tolerant networks, and datacenter orchestration.
    • Vol II → Vol III, when a stateless response is not enough. Volume II serves stateless requests at scale. Volume III adds stateful, multi-step loops that manage context memory, call tools, run in sandboxes, and recover from nondeterministic failures.
    • Vol III → Vol IV, when software acts on the physical world. Volume III governs software environments. Volume IV crosses into physical systems, where computational latency becomes distance traveled and a failure cannot be undone.

    I am writing Volumes III and IV because I plan to teach both subjects, and because they are where machine learning systems are heading. The progression is a natural one. Volumes I and II run in an open loop, where a request goes in and a response comes out. Volume III closes the loop in software, where an agent acts, observes the result, and acts again. Volume IV closes it through the physical world. Writing a book is how I learn a subject well enough to teach it.

    ⚠️ Volumes III and IV are open drafts. Chapters are added, reorganized, and rewritten as my understanding grows, so please do not cite or teach from them yet. Feedback is welcome through the book feedback issue forms.


    What's in the Repository

    Around the textbook sit the companion tools that let students build, measure, and practice what they read. The pieces are designed to work together, but none of them requires the others.

    Two earlier-stage experiments also live here. SocratiQ is an AI tutor that adds guided reading, quizzes, and spaced repetition to static learning sites. MLPerf EDU is a teaching benchmark suite aligned with MLCommons MLPerf.


    Start Here

    Where to begin depends on what you want from the curriculum.


    How the Material Is Made

    No chapter is written once. Each one goes through a cycle that repeats as the field changes.

    1. Watch the field. I follow the research and industry venues where new work appears: ISCA, MICRO, HPCA, ASPLOS, ISPASS, MLSys, NeurIPS, ICML, ICLR, Hot Chips, and industry summits.
    2. Distill. A chapter keeps the principles and leaves out the variations. Quantization, for example, has been implemented in dozens of ways, and a student needs the principles that explain all of them. To decide what belongs, I use a test that David Patterson, who wrote the foreword to Volume I, gave me. A technique earns a place only when several companies use it in practice. That test ties the material to systems in production, so what a student learns carries over to practice.
    3. Review with practitioners. I review chapters one-on-one with the engineers who build these systems inside large companies, from hyperscale infrastructure engineers to model developers. Practitioners at Arm, Google, Intel, Meta, Microsoft, Qualcomm, STMicroelectronics, and other organizations have reviewed the material, and academic reviewers in Europe, Asia, and the Americas have tested it against their own research and teaching.
    4. Teach it. Volume I has been taught at Harvard through CS249r since 2023 and adopted by instructors at UC Berkeley, Columbia, Georgia Tech, IIT Bombay, and universities across Europe, Latin America, Africa, and Asia. The classroom shows where students get stuck.
    5. Revise. Reader issues, reviewer notes, and classroom experience go back into the next draft.

    Reviewers do more than check facts, and sometimes they change what the book covers. Sustainable AI and responsible AI both entered the book this way. Engineers building AI datacenters told me that the footprint of these facilities keeps growing and that students need to learn to account for it. Their concern led to a chapter I had not planned, which I wrote in 2023, before sustainable AI was a common topic.

    Engineers in industry also urged me to teach responsible AI. It can look like a subject outside traditional engineering, but the systems in this book make decisions that affect people, and more and more of them act on their own. The engineers who build such systems are responsible for how they behave, so the book teaches that responsibility as part of the engineering.

    Readers are part of the review, too. Every chapter is open, and when something is wrong, unclear, or missing, the book feedback forms send it straight into the next revision.

    Numbers are computed, not typed. Every derived quantity in the books comes from Python code that ships with the text. I learned the need for this the hard way. In early drafts I typed numbers by hand, made mistakes, and watched the same quantity drift apart from one chapter and one volume to the next. No author can hold every number across the series in mind at once, so I wrote MLSys·im to hold them instead. It is the single source of truth for every chapter and every volume. Each hardware and model specification in it traces to a cited source, and when a value changes there, every chapter that uses it changes with it. A test suite runs on every commit and checks unit consistency, cross-references, notation, and citations.


    FAQ

    When I began teaching machine learning systems, there was no textbook for the course. Books covered the models, and papers covered individual systems, but nothing taught the infrastructure underneath them as one subject. The field was changing too quickly for anyone to have written one. So I started writing it myself, because I have always learned best by building from scratch and teaching others.

    When I want to understand an emerging or complex systems area, writing about it and writing code for it force me to slow down. They force me to find the principles that last, work through the math, and separate what is fundamentally true about physics and hardware from what is merely current.

    This repository is my open workshop and teaching lab. It is where I work out ideas for my students at Harvard, my research lab, and open benchmarking efforts like MLPerf. Volumes III and IV are that process happening in public.

    There is also a deeper reason. In the late 1990s, as an undergraduate, I wrote to a professor at Stanford because I was fascinated by genetic algorithms. I did not expect an answer. Then a brown package arrived at my house with a VHS tape on genetic algorithms inside, sent from the professor's office. I no longer remember the professor's name, so I never got to say thank you, but I have not forgotten what it felt like to have someone I had never met take the time to share what they knew with a curious student. That package sparked my curiosity, and the feeling has stayed with me.

    Students write to me now the way I once wrote to that professor, far more than I can answer one by one. This curriculum is my way of sending the package back out, to a much bigger classroom than any lecture hall can hold.

    It is for anyone who wants to understand how intelligent systems run, not only how models are trained: students, software engineers moving into ML infrastructure, hardware architects, and educators designing courses.

    The only assumptions are that the reader can program in Python and has met basic machine learning ideas, such as a neural network or a loss function. The systems concepts are built from the ground up. No prior background in computer architecture, networking, or distributed systems is needed.

    No. The two volumes differ in scope, not in depth or rigor.

    Volume I covers one machine with a handful of accelerators, from the memory hierarchy and kernel efficiency to quantization and on-device deployment. Volume II covers the fleet, with thousands of accelerators connected by high-speed networks, the parallelism that spans them, fault tolerance, and serving at datacenter scale.

    Volume II does not assume that a reader has finished Volume I, so a reader with strong single-machine foundations can start there. Reading Volume I first gives the cleanest mental model from the silicon up, in the same way that Hennessy and Patterson's Computer Organization and Design precedes Computer Architecture: A Quantitative Approach.

    Each volume stands on its own as a textbook. The companions are there for readers who want to go further. Reading builds the mental model, and building and measuring make it last. Start with the book and add the hands-on pieces when an idea needs to become practice.

    Books such as Goodfellow, Bengio, and Courville's Deep Learning, Bishop's texts, d2l.ai, and fast.ai teach the mathematics, architectures, and optimization of models, and they teach them well.

    This curriculum starts where those books stop. It treats the model as one component inside a system that must ingest data, run on real silicon under power and thermal limits, answer queries within milliseconds, and keep running across thousands of machines. A reader can finish an excellent deep learning course and still not know why a cluster idles at 30% utilization, why serving memory grows with the KV cache, or how gradients are synchronized without stalling the network. Those questions are the subject here.

    MLOps books, such as Chip Huyen's Designing Machine Learning Systems, focus on operational pipelines: feature stores, workflow orchestration, and deployment with current industry tools. They are valuable practical guides.

    This curriculum focuses on what lies underneath: the hardware limits, quantitative trade-offs, and first principles that explain why those tools are designed as they are, and the limits no tool escapes, such as memory bandwidth, network latency, energy, and failure rates.

    The two differ the way a recipe differs from an understanding of how heat, salt, fat, and time interact. A recipe works until the oven changes or the batch grows tenfold. Understanding the chemistry lets a cook work in any kitchen, fix a dish that went wrong, and invent new ones.

    Barroso, Hölzle, and Clidaras give a firsthand account of how one organization built hyperscale infrastructure, and I admire that work. This curriculum aims to complement it in three ways:

    1. A progressive curriculum, not a reference. It starts from a single machine and its memory hierarchy (Volume I) and builds up to multi-node clusters and warehouse-scale fleets (Volume II), with quantitative exercises along the way.
    2. Vendor-neutral foundations. It generalizes across accelerator architectures (GPUs, TPUs, custom ASICs) and deployment targets (cloud clusters to milliwatt microcontrollers), so the principles carry across hardware generations.
    3. Hands-on and living. The text is surrounded by code readers build themselves (TinyTorch), open hardware kits, cluster modeling (MLSys·im), and community contributions, and it changes as the field does.

    Yes, and I would rather say so plainly than leave readers to guess. I use generative AI tools to write code and the checks that test it, to survey the literature before I read the papers myself, to draft passages that I then rewrite, to help produce figures that I once drew by hand, and to audit the books for consistency. I use them on the companions as well, from TinyTorch and the labs to the slides and the StaffML question bank. They are also how I learn a new area quickly. The tools take on mechanical work, which leaves my time for the parts that need a teacher: what to include, how to explain it, and whether it is right.

    A tool can write text that sounds right and is wrong, so I do not take its output on trust. I check the work in ways that do not depend on the tool. Every number in the books is computed by code, and automated checks run whenever something changes. Practitioners review the chapters, and students test them in class. In StaffML, each question records whether it began as a machine draft and whether a person has reviewed it.

    I researched, wrote, and rewrote every chapter. The decisions about what goes in, what stays out, and how an idea is taught are mine, and so is every mistake. Because all of the work is open, anyone can check it and tell me what they find.

    Volumes III and IV have not yet been through the classroom or practitioner review, which is why they are marked as drafts. Each volume includes a full Note on AI Assistance.

    Language models are good at retrieval, code generation, and summarizing facts. A paragraph that only delivers a fact a reader could look up in seconds has not earned its place in a textbook.

    What a textbook provides is perspective and a coherent mental model: the order in which to learn ideas, how trade-offs constrain one another, and what not to worry about. Deciding what to leave out is one of the most important choices an author makes.

    Bruce Davie made this point in his essay “Textbooks in Tokenland” (Systems Approach). A language model generates text without communicative intent, he writes, while a textbook is a deliberate path from a teacher to a student toward a shared understanding of how the world works.

    The two are not in opposition. The book provides the structure and the quantitative argument, and interactive tools let a reader test that understanding. The Marimo labs ask a reader to predict an outcome and then check it, and the SocratiQ tutor answers questions about the page being read.

    Yes. Every volume is free to read online at mlsysbook.ai.

    The textbook is released under a Creative Commons license (CC BY-NC-ND 4.0), the same license as the MIT Press print edition. It may be read and shared for non-commercial use with attribution. Translations and other modified versions need permission. The companion software is open source under its own licenses, listed under License.


    Support This Work

    If this curriculum has helped you, there are two simple ways to help it grow.


    Contributing

    Branches. Development happens on dev, which this page shows. The main branch holds what is live on mlsysbook.ai, and the publish workflow promotes dev to main at each release.


    License

    This is a multi-component repository, and each component is released under its own license to match its purpose. The license file inside each directory, such as tinytorch/LICENSE or staffml/app/LICENSE, is authoritative.

    A shorter summary for readers is at mlsysbook.ai/about/license.

    If you are an institution considering adoption, or a company interested in commercial terms for a copyleft component, please write to [email protected].


    Acknowledgments

    I assembled this curriculum, but I did not invent most of what it teaches. The ideas come from the engineers and practitioners in industry who build these systems every day, and from researchers worldwide who study them and publish what they learn. The books cite their work throughout, and the curriculum would not exist without it. My own research lab has contributed as well.

    Many people also gave their time to the curriculum itself. My students in CS249r at Harvard have tested every revision. Reviewers in industry and academia read chapters and told me where I was wrong. Instructors who adopted the material reported what worked in their classrooms and what did not. Readers found errors, and contributors fixed them. The financial contributors on Open Collective helped carry the work to more students.

    Whatever is good here owes a great deal to all of them. The mistakes are mine.


    Contributors

    These people have improved the textbooks, the software, and the teaching materials.

    Legend: 🪲 Bug Hunter · 🧑‍💻 Code Contributor · ✍️ Doc Wizard · 🎨 Design Artist · 🧠 Idea Spark · 🔎 Code Reviewer · 🧪 Test Tinkerer · 🛠️ Tool Builder

    📖 Textbook Contributors