Files
cs249r_book/quarto/config/_quarto-pdf.yml
Vijay Janapa Reddi fd5fb20255 feat(scripts): add cross-platform Python SVG cleaner
- Add clean_svgs.py as cross-platform replacement for clean-svgs.sh
- Resolves Windows container compatibility issue (os error 193)
- Update all Quarto configs to use Python script
- Maintain all original functionality with improved error handling
- Add comprehensive logging and debug mode
- Use pathlib for cross-platform path operations
- Mark original bash script as deprecated

Fixes Windows build error: '%1 is not a valid Win32 application'
2025-08-19 08:10:29 -04:00

510 lines
19 KiB
YAML

# =============================================================================
# ACADEMIC PDF CONFIGURATION
# =============================================================================
# This configuration is optimized for professional academic PDF book output.
#
# Key Features:
# - Traditional book project type with linear chapter flow
# - Full LaTeX rendering with LuaLaTeX engine for advanced typography
# - Complete citation support and academic formatting
# - Professional part pages with custom TikZ designs
# - All Lua filters enabled (sidenotes, part summaries, cross-refs, etc.)
# - Traditional chapter numbering and book structure
# - Custom LaTeX includes for enhanced visual design
#
# Usage:
# make build-pdf # Uses this config automatically
# make preview-pdf # Uses this config for PDF development
#
# Part of the dual-configuration system:
# _quarto-html.yml # Website optimized
# _quarto-pdf.yml # This file (academic PDF optimized)
# =============================================================================
project:
type: book
output-dir: _build/pdf
post-render:
- scripts/clean_svgs.py
preview:
browser: true
navigate: true
book:
favicon: assets/images/icons/favicon.png
cover-image: assets/images/covers/cover-hardcover-book.png
cover-image-alt: "Cover image."
title: "Machine Learning Systems"
subtitle: "Principles and Practices of Engineering Artificially Intelligent Systems"
date: today
date-format: long
author:
name: Vijay Janapa Reddi
email: vj@eecs.harvard.edu
url: https://www.google.com/search?q=Vijay+Janapa+Reddi
affiliations: Harvard University
corresponding: true
roles: "Author, editor and curator."
abstract: |
Machine Learning Systems presents a comprehensive approach to understanding and engineering machine learning (ML). While many resources focus on ML algorithms and model architectures, this book serves as a bridge between theoretical foundations and practical engineering. It emphasizes the systems context that engineers need to master when building AI solutions in the real world. The text progresses from foundational concepts to advanced system design, integrating topics such as data engineering, model optimization, hardware-aware training approaches, and inference acceleration strategies. Throughout the book, readers develop a principled understanding of ML systems engineering, learning to reason about system architectures and address critical challenges in areas including security, privacy, and reliability. While ML applications and tools evolve rapidly, the engineering principles for building ML systems remain largely consistent. This book distills these enduring concepts, making it a resource for anyone seeking to build flexible, efficient, and robust ML systems.
----
🎙 Listen to the **AI Podcast**,
created using Google's Notebook LM and inspired by insights drawn from our
[IEEE education viewpoint paper](https://web.eng.fiu.edu/gaquan/Papers/ESWEEK24Papers/CPS-Proceedings/pdfs/CODES-ISSS/563900a043/563900a043.pdf).
This podcast provides an accessible overview of what this book is all about.
 
<audio controls>
<source src="assets/media/notebooklm_podcast_mlsysbookai.mp3" type="audio/mpeg">
</audio>
----
repo-url: https://github.com/harvard-edge/cs249r_book
page-footer:
left: |
Written, edited and curated by Prof. Vijay Janapa Reddi (Harvard University)
right: |
This book was built with <a href="https://quarto.org/">Quarto</a>.
chapters:
- index.qmd
# ==================================================
# Frontmatter
# ==================================================
- contents/frontmatter/foreword.qmd
- contents/frontmatter/about/about.qmd
- contents/frontmatter/changelog/changelog.qmd
- contents/frontmatter/acknowledgements/acknowledgements.qmd
- contents/frontmatter/socratiq/socratiq.qmd
# ==================================================
# Division: Mainmatter — Part I: Systems Foundations
# ==================================================
- contents/core/introduction/introduction.qmd
- contents/core/ml_systems/ml_systems.qmd
- contents/core/dl_primer/dl_primer.qmd
- contents/core/dnn_architectures/dnn_architectures.qmd
# ==================================================
# Division: Mainmatter — Part II: Design Principles
# ==================================================
- contents/core/workflow/workflow.qmd
- contents/core/data_engineering/data_engineering.qmd
- contents/core/frameworks/frameworks.qmd
- contents/core/training/training.qmd
# ==================================================
# Division: Mainmatter — Part III: Performance Engineering
# ==================================================
- contents/core/efficient_ai/efficient_ai.qmd
- contents/core/optimizations/optimizations.qmd
- contents/core/hw_acceleration/hw_acceleration.qmd
- contents/core/benchmarking/benchmarking.qmd
# ==================================================
# Division: Mainmatter — Part IV: Robust Deployment
# ==================================================
- contents/core/ops/ops.qmd
- contents/core/ondevice_learning/ondevice_learning.qmd
- contents/core/robust_ai/robust_ai.qmd
- contents/core/privacy_security/privacy_security.qmd
# ==================================================
# Division: Mainmatter — Part V: Trustworthy Systems
# ==================================================
- contents/core/responsible_ai/responsible_ai.qmd
- contents/core/sustainable_ai/sustainable_ai.qmd
- contents/core/ai_for_good/ai_for_good.qmd
# ==================================================
# Division: Mainmatter — Part VI: Frontiers
# ==================================================
#- contents/core/frontiers/frontiers.qmd
- contents/core/conclusion/conclusion.qmd
# ==================================================
# Division: Mainmatter — Part VII: Laboratory Exercises
# ==================================================
- contents/labs/labs.qmd
- contents/labs/kits.qmd
- contents/labs/ide_setup.qmd
# ==================================================
# Division: Mainmatter — Part VIII: Arduino Labs
# ==================================================
- contents/labs/arduino/nicla_vision/nicla_vision.qmd
- contents/labs/arduino/nicla_vision/setup/setup.qmd
- contents/labs/arduino/nicla_vision/image_classification/image_classification.qmd
- contents/labs/arduino/nicla_vision/object_detection/object_detection.qmd
- contents/labs/arduino/nicla_vision/kws/kws.qmd
- contents/labs/arduino/nicla_vision/motion_classification/motion_classification.qmd
# ==================================================
# Division: Mainmatter — Part IX: Seeed XIAO ESP32S3 Labs
# ==================================================
- contents/labs/seeed/xiao_esp32s3/xiao_esp32s3.qmd
- contents/labs/seeed/xiao_esp32s3/setup/setup.qmd
- contents/labs/seeed/xiao_esp32s3/image_classification/image_classification.qmd
- contents/labs/seeed/xiao_esp32s3/object_detection/object_detection.qmd
- contents/labs/seeed/xiao_esp32s3/kws/kws.qmd
- contents/labs/seeed/xiao_esp32s3/motion_classification/motion_classification.qmd
# ==================================================
# Division: Mainmatter — Part X: Grove Vision Labs
# ==================================================
- contents/labs/seeed/grove_vision_ai_v2/grove_vision_ai_v2.qmd
- contents/labs/seeed/grove_vision_ai_v2/setup_and_no_code_apps/setup_and_no_code_apps.qmd
- contents/labs/seeed/grove_vision_ai_v2/image_classification/image_classification.qmd
- contents/labs/seeed/grove_vision_ai_v2/object_detection/object_detection.qmd
# ==================================================
# Division: Mainmatter — Part XI: Raspberry Pi Labs
# ==================================================
- contents/labs/raspi/raspi.qmd
- contents/labs/raspi/setup/setup.qmd
- contents/labs/raspi/image_classification/image_classification.qmd
- contents/labs/raspi/object_detection/object_detection.qmd
- contents/labs/raspi/llm/llm.qmd
- contents/labs/raspi/vlm/vlm.qmd
# ==================================================
# Division: Mainmatter — Part XII: Shared Labs
# ==================================================
- contents/labs/shared/shared.qmd
- contents/labs/shared/kws_feature_eng/kws_feature_eng.qmd
- contents/labs/shared/dsp_spectral_features_block/dsp_spectral_features_block.qmd
# ==================================================
# Backmatter
# ==================================================
- contents/backmatter/references.qmd
bibliography:
- contents/core/introduction/introduction.bib
- contents/core/ai_for_good/ai_for_good.bib
- contents/core/benchmarking/benchmarking.bib
- contents/core/data_engineering/data_engineering.bib
- contents/core/dl_primer/dl_primer.bib
- contents/core/dnn_architectures/dnn_architectures.bib
- contents/core/efficient_ai/efficient_ai.bib
- contents/core/ml_systems/ml_systems.bib
- contents/core/frameworks/frameworks.bib
- contents/core/hw_acceleration/hw_acceleration.bib
- contents/core/ondevice_learning/ondevice_learning.bib
- contents/core/ops/ops.bib
- contents/core/optimizations/optimizations.bib
- contents/core/privacy_security/privacy_security.bib
- contents/core/responsible_ai/responsible_ai.bib
- contents/core/robust_ai/robust_ai.bib
- contents/core/sustainable_ai/sustainable_ai.bib
- contents/core/training/training.bib
- contents/core/workflow/workflow.bib
- contents/core/conclusion/conclusion.bib
crossref:
appendix-title: "Appendix"
appendix-delim: ":"
custom:
- kind: float
key: vid
latex-env: vid
reference-prefix: Video
citation: true
license: CC-BY-NC-SA
filters:
- filters/sidenote.lua
- filters/inject_parts.lua
- filters/inject_quizzes.lua
- pandoc-ext/diagram
- filters/inject_crossrefs.lua # This must come before custom-numbered-blocks (relies on \ref{...})
- mlsysbook-ext/custom-numbered-blocks
- mlsysbook-ext/margin-video
- filters/margin-connections.lua # This filter must come after custom-numbered-blocks
# Filter configurations and metadata
filter-metadata:
# Quiz configuration for inject_quizzes.lua filter
quiz-config:
file-pattern: "*_quizzes.json" # Pattern for quiz file discovery in PDF builds
scan-directory: "contents/core" # Directory to scan for quiz files
auto-discover-pdf: true # Whether to enable auto-discovery in PDF builds
# Cross-reference injection configuration for inject_crossrefs.lua filter
cross-references:
file: "data/cross_refs_final.json" # Path to cross-references JSON file
enabled: true # Enable/disable cross-reference injection
# Part summaries injection configuration for inject_parts.lua filter
part-summaries:
file: "contents/parts/summaries.yml" # Path to part summaries YAML file
enabled: true # Enable/disable part summary injection
# Custom numbered blocks configuration for mlsysbook-ext/custom-numbered-blocks filter
mlsysbook-ext/custom-numbered-blocks:
icon-path: "assets/images/icons/callouts" # Path to callout icons
icon-format: "pdf" # Icon format for PDF builds
diagram:
engine:
dot: false
mermaid: false
asymptote: false
tikz:
execpath: lualatex
header-includes:
- '\usepackage{tikz}'
- '\usepackage{pgfplots}'
- '\usepackage{pgf-pie}'
- '\usepackage{amsmath}'
- '\usepackage{amssymb}'
- '\usepackage{xcolor}'
- '\pgfplotsset{compat=1.9}'
- '\usepgfplotslibrary{fillbetween}'
- '\usetikzlibrary{angles}'
- '\usetikzlibrary{arrows.meta}'
- '\usetikzlibrary{arrows}'
- '\usetikzlibrary{backgrounds}'
- '\usetikzlibrary{bending}'
- '\usetikzlibrary{calc}'
- '\usetikzlibrary{fit}'
- '\usetikzlibrary{intersections}'
- '\usetikzlibrary{positioning}'
- '\usetikzlibrary{shapes.geometric}'
- '\usetikzlibrary{shapes}'
- '\usetikzlibrary{quotes}'
- '\usetikzlibrary{decorations.pathmorphing}'
- '\usetikzlibrary{decorations.markings}'
- '\usetikzlibrary{matrix}'
- '\usepgfplotslibrary{dateplot}'
- '\usepgfplotslibrary{polar}'
- '\definecolor{Brown}{rgb}{0.65, 0.16, 0.16}'
- '\definecolor{BrownL}{rgb}{0.6, 0.4, 0.2}'
- '\definecolor{BrownLine}{rgb}{0.5, 0.3, 0.1}'
- '\definecolor{BackColor}{RGB}{255,255,229}'
- '\definecolor{BackLine}{RGB}{181,181,72}'
- '\definecolor{BlueD}{RGB}{62,100,125}'
- '\definecolor{BlueL}{RGB}{209,243,255}'
- '\definecolor{BlueLine}{RGB}{34,148,189}'
- '\definecolor{BrownL}{RGB}{233,222,220}'
- '\definecolor{BrownLine}{RGB}{143,120,116}'
- '\definecolor{Green}{rgb}{0.0, 0.5, 0.0}'
- '\definecolor{GreenD}{RGB}{40,117,40}'
- '\definecolor{GreenL}{RGB}{219,253,166}'
- '\definecolor{GreenLine}{RGB}{73,89,56}'
- '\definecolor{OliveL}{RGB}{230,227,191}'
- '\definecolor{OliveLine}{RGB}{173,166,10}'
- '\definecolor{OrangeL}{RGB}{250,212,175}'
- '\definecolor{OrangeLine}{RGB}{255,127,76}'
- '\definecolor{RedL}{RGB}{253,226,240}'
- '\definecolor{RedLine}{RGB}{201,20,110}'
- '\definecolor{Sepia}{rgb}{0.44, 0.26, 0.08}'
- '\definecolor{TextColor}{RGB}{224,224,224}'
- '\definecolor{VioletL}{RGB}{247,180,247}'
- '\definecolor{VioletL2}{RGB}{243,243,255}'
- '\definecolor{VioletLine}{RGB}{34,125,189}'
- '\definecolor{VioletLine2}{RGB}{169,136,229}'
editor:
render-on-save: true
format:
# ------------------------------------------------------------------------------
# PDF Format Specific Options
# ------------------------------------------------------------------------------
titlepage-pdf:
pdf-engine: lualatex
use-rsvg-convert: true
documentclass: scrbook
classoption: [abstract,titlepage]
header-includes: |
\usepackage{needspace}
\let\Needspace\needspace
coverpage: true
coverpage-title: "Machine Learning Systems"
coverpage-bg-image: "assets/images/covers/cover-image-transparent.png"
coverpage-author: ["Vijay", "Janapa Reddi"]
coverpage-footer: "Introduction to"
coverpage-theme:
page-text-align: "center"
bg-image-left: "0.225\\paperwidth"
bg-image-bottom: 7
bg-image-rotate: 0
bg-image-opacity: 1.0
author-style: "plain"
author-sep: "newline"
author-fontsize: 20
author-align: "right"
author-bottom: "0.132\\paperwidth" #0.15
author-left: 7in
author-width: 6in
header-style: "none"
date-style: "none"
title-fontsize: 57
title-left: "0.075\\paperwidth"
title-bottom: "0.31\\paperwidth" #0.35
title-width: "0.9\\paperwidth"
footer-fontsize: 25
footer-left: "0.075\\paperwidth"
footer-bottom: "0.38\\paperwidth" #0.42
footer-width: "0.9\\paperwidth"
footer-align: "left"
titlepage: true
titlepage-theme:
elements: [ "\\titleblock",
"Prof. Vijay Janapa Reddi",
"School of Engineering and Applied Sciences",
"Harvard University",
"\\vspace{80mm}",
"With heartfelt gratitude to the community for their invaluable contributions and steadfast support.",
"\\vfill",
"{{< meta date >}}",
"\\vfill"]
date: "today"
date-format: long
page-align: "left"
title-style: "plain"
title-fontstyle: ["huge", "bfseries"]
title-space-after: "4\\baselineskip"
title-subtitle-space-between: "0.05\\textheight"
subtitle-fontstyle: ["large", "textit"]
author-style: "superscript-with-and"
author-fontstyle: "large"
affiliation-style: "numbered-list-with-correspondence"
affiliation-fontstyle: "large"
affiliation-space-after: "0pt"
footer-style: "plain"
footer-fontstyle: "large"
logo-size: "0.15\\textheight"
logo-space-after: "1\\baselineskip"
vrule-width: "2pt"
vrule-align: "left"
vrule-color: "black"
toc: true
lof: false
lot: false
top-level-division: chapter
number-sections: true
toc-depth: 3
number-depth: 3
keep-tex: true
citation-package: natbib
link-citations: true
biblio-title: "References"
cite-method: citeproc
title-block-style: none
indent: 0px
fontsize: 9pt
colorlinks: true
reference-location: document
citation-location: block
fig-caption: true
#cap-location: margin
fig-cap-location: bottom
tbl-cap-location: top
tbl-colwidths: auto
hyperrefoptions:
- linktoc=all
- pdfwindowui
- pdfpagemode=FullScreen
- pdfpagelayout=TwoPageRight
include-in-header:
- file: "tex/header-includes.tex"
- text: |
\usepackage{needspace}
\let\Needspace\needspace
mlsysbook-ext/custom-numbered-blocks:
groups:
quiz-question:
colors: ["F0F0F8", "5B4B8A"] # Darker purple for quiz questions
collapse: false
quiz-answer:
colors: ["E8F2EA", "4a7c59"] # Forest green for quiz answers
collapse: true
resource-slides:
colors: ["E0F2F1", "20B2AA"] # Teal for resources
collapse: false
numbered: false
resource-videos:
colors: ["E0F2F1", "20B2AA"] # Teal for resources
collapse: false
numbered: false
resource-exercises:
colors: ["E0F2F1", "20B2AA"] # Teal for resources
collapse: false
numbered: false
chapter-connection:
colors: ["FDF2F7", "A51C30"] # Harvard crimson for chapter connections
boxstyle: foldbox.simple
collapse: true
numbered: false
chapter-forward:
colors: ["FDF2F7", "A51C30"] # Harvard crimson for chapter connections
boxstyle: foldbox.simple
collapse: true
numbered: false
chapter-recall:
colors: ["FFF4E6", "C06014"] # Warm orange for chapter recall
collapse: false
numbered: false
classes:
callout-quiz-question:
label: "Self-Check: Question"
group: quiz-question
callout-quiz-answer:
label: "Self-Check: Answer"
group: quiz-answer
callout-resource-slides:
label: "Slides"
group: resource-slides
callout-resource-videos:
label: "Videos"
group: resource-videos
callout-resource-exercises:
label: "Exercises"
group: resource-exercises
callout-chapter-connection:
label: "Chapter connections"
group: chapter-connection
resources:
- CNAME
- assets