26 Commits
Author SHA1 Message Date
Vijay Janapa Reddi 82b7679c3d Add end-of-chapter research questions 2026-07-01 12:23:48 -04:00
Vijay Janapa Reddi 5d74c7a4c7 Polish custom callout palette and icons 2026-06-13 08:30:02 -04:00
Vijay Janapa Reddi b445aa4e3b Fix algorithm reference prefix casing 2026-06-04 16:06:12 -04:00
Vijay Janapa Reddi f9db5c18d7 Consolidate cross-reference label config 2026-06-04 16:00:42 -04:00
Vijay Janapa Reddi 05215e74b8 Enforce algorithm reference rendering 2026-06-04 15:44:10 -04:00
Vijay Janapa Reddi 2c2d4f4e78 Fix Linux book render Python path 2026-06-03 02:55:20 -04:00
Vijay Janapa Reddi 626942c1fe chore: set crossref prefixes to lowercase per MIT Press convention
MIT Press requires inline cross-references to use lowercase prefixes
("figure 1", "table 2", "section 3") with capitalization only at
sentence starts. Quarto supports this via *-prefix config options
paired with the @Fig- / @Tbl- / @Sec- syntax for sentence starts.

Config: add fig-prefix, tbl-prefix, sec-prefix, eq-prefix, lst-prefix
to the shared crossref base config (crossref-video.yml).

Resolver: update fallback labels in resolve_cross_references.py to
match the new lowercase convention.

Next step: sweep ~1,173 sentence-start refs across vol1+vol2 QMD files
to use the @Fig- / @Tbl- / @Sec- / @Eq- / @Lst- capitalized syntax.
2026-05-26 19:52:36 -04:00
Vijay Janapa Reddi 7556902220 Normalize example callout reference prefix 2026-05-21 13:20:28 -07:00
Vijay Janapa Reddi 37875cda71 Format bibliography for MIT Press output 2026-05-20 08:33:45 -07:00
Vijay Janapa Reddi 1cf520f167 callouts: rename IDs to non-conflicting prefixes (def→dfn, exm→exmp, thm→thrm)
The original prefix choices for callout-definition (def-), callout-example
(exm-), and callout-theorem (thm-) collided with Quarto's built-in
crossref types. Quarto auto-wraps any div with one of those IDs in a
\begin{definition} / \begin{example} / \begin{theorem} theorem env that
prints its own "Definition X.Y." / "Example X.Y." header into body
prose — which then visually duplicates with our custom callout's title
bar (which the Lua filter renders WITHOUT the number, because it
detects the outer wrapping).

Visible symptom: a stray "Definition 1.2." line above the callout
box, plus a callout title bar showing only "Definition: <name>"
without the number.

Fix: rename to prefixes Quarto does not recognize as built-ins, so no
outer wrapping happens. The custom Lua filter then puts the number
directly in the callout's title bar — matching how Principle, Napkin
Math, Checkpoint, etc. already work.

Renames applied book-wide:
  def-  → dfn-     (definition)
  exm-  → exmp-    (example)
  thm-  → thrm-    (theorem)

YAML prefix: declarations updated to match. 202 ID and \ref{} changes
across 30 QMD files.

Verified by rebuilding the Introduction chapter: title bars now read
"Definition 1.1: …", "Example 1.1: …", "Theorem 1.1: …" exactly as
the Notebook / Principle / Checkpoint title bars already do.
2026-05-19 19:08:15 -07:00
Vijay Janapa Reddi f773fc6e17 callouts: declare prefix per numbered class + add IDs to 662 callouts book-wide
Adds the `prefix:` field to each numbered callout class in
custom-numbered-blocks.yml so the convention is declared once and
discoverable by tooling. Prefixes are short (3-letter) and match the
group's role:

  callout-example       → exm
  callout-notebook      → nbk
  callout-theorem       → thm
  callout-war-story     → ws
  callout-lighthouse    → lhs
  callout-definition    → def
  callout-perspective   → psp
  callout-checkpoint    → chk
  callout-principle     → pri  (book-wide global)

Then sweeps all 31 chapters and inserts `{#prefix-chapter-slug-…}`
identifiers on every numbered callout that didn't already have one,
deriving the slug from the callout's title. 662 IDs added across
both volumes.

The cross-reference resolution itself was already wired up in the
custom-numbered-blocks Lua filter (it handles `\ref{}` matching against
any identifier on a numbered callout). Adding the IDs is purely
declarative — authors can now write `\ref{exm-inference-dynamic-
batching-resnet50}` and it resolves to "Example 10.1" automatically.

Verified by rebuilding vol2 — no regressions, no visual breakage,
flagged-page count slightly improved (57 → 54).
2026-05-19 17:59:47 -07:00
Vijay Janapa Reddi 0cb7b0e4bf feat(callouts): migrate Learning Objectives to custom foldbox callout
Previously every chapter's Learning Objectives used the native Quarto
.callout-tip with title='Learning Objectives'. Native callouts have
different DOM structure, CSS padding, and LaTeX rendering than the
book's custom foldbox callouts (Napkin Math, War Story, Example, etc.),
which produced two problems:

1. Visible spacing inconsistency in HTML/EPUB: the .callout-tip header
   was 17 px taller than foldbox <summary> headers because of
   padding-bottom: 1em on .callout-icon-container / .callout-title-
   container. Previous commits tried to patch this via CSS overrides,
   but the fix was fragile and only covered HTML.

2. No PDF styling parity: native .callout-tip in PDF uses Quarto's
   default tcolorbox rendering, which differs from foldbox.tex. Colors,
   borders, and header geometry all mismatched the rest of the book's
   callouts.

Fix: register a custom foldbox callout class called
'callout-learning-objectives' in custom-numbered-blocks.yml with:
- colors: ['E8F2EA', '4A7C59'] (green, matching native callout-tip)
- collapse: false
- numbered: false
- label: 'Learning Objectives'

Add icon assets (SVG, PNG at 128×128, PDF) — a lightbulb matching the
native callout-tip lightbulb metaphor, in the same green stroke color.

Sweep every chapter (vol1 + vol2 + appendices + frontmatter, 44 files)
to replace ':::{.callout-tip title="Learning Objectives"}' with
':::{.callout-learning-objectives}'.

Benefits:
- One source of truth: YAML config drives HTML/EPUB (foldbox.css) and
  PDF (foldbox.tex) consistently.
- Uniform spacing: summary_h=36.9 px, summary_pt/pb=8.5 px across all
  callouts now — verified via Playwright measurements.
- PDF rendering: foldbox.tex auto-generates \definecolor from YAML,
  so LO PDF callout inherits the same tcolorbox geometry as other
  foldbox callouts. Verified by rendering the Conclusion chapter PDF
  (page 11).
2026-04-24 12:52:24 -04:00
Vijay Janapa ReddiandGitHub 0940f58746 fix(quarto): restore mlsysim importability after PR #1397 outer-init removal (#1420)
* fix(tests): make mlsysim.core importable from CI without pip install

`book/tests/test_units.py` did `sys.path.insert(0, _repo_root)` and
then `from mlsysim.core.constants import *`. That only works if a
top-level `mlsysim/__init__.py` exists at the repo root — but the
actual package layout is two levels deep:

  <repo_root>/mlsysim/                    ← project dir, NOT a package
  <repo_root>/mlsysim/mlsysim/__init__.py ← actual Python package
  <repo_root>/mlsysim/mlsysim/core/       ← submodule

Locally, the import succeeded because `mlsysim` is `pip install -e`'d
in dev environments. CI has no editable install, so Python 3.3+
treated `<repo_root>/mlsysim/` as an implicit namespace package and
then `mlsysim.core` was unfindable, producing
`ModuleNotFoundError: No module named 'mlsysim.core'`.

Result: `book-mlsys-test-units` has been Failed on every dev
`book-validate-dev` run since 2026-04-18 (last green: 2026-04-17).
The hook is what blocks the publish guard for the upcoming book
release, so this also unblocks B1–B6 of the staged-rollout plan.

Fix: point `sys.path` at `<repo_root>/mlsysim/` (the directory that
*contains* the package), not `<repo_root>/`. Validated:
  - hook passes locally via `pre-commit run book-mlsys-test-units`.
  - emulating CI (no editable install, plain sys.path), the import
    chain now resolves `mlsysim.core` correctly; runtime deps
    (pint, pydantic, numpy, pyyaml, rich) are already in
    `book/tools/dependencies/requirements.txt` which CI installs.

* fix(quarto): restore mlsysim importability after PR #1397 outer-init removal

Quarto's execute env sets PYTHONPATH="../.." (= repo root) so that
.qmd Python chunks can do `from mlsysim.core.constants import *`. That
worked because there used to be an outer `mlsysim/__init__.py` that
made `<repo_root>/mlsysim/` itself a Python package — even though the
real package is one level deeper at `<repo_root>/mlsysim/mlsysim/`.

PR #1397 ("MLSys·im 0.1.0 release-prep audit") cleaned up that
nested-with-same-name layout by removing the outer init (correct
packaging hygiene). After that, `<repo_root>/mlsysim/` became an
implicit namespace package without `core/`, and every .qmd that
imports `mlsysim.core` started failing in the build container with
`ModuleNotFoundError: No module named 'mlsysim.core'`.

This was masked behind another failure for 3 days: `book-validate-dev`
was already red on the `book-mlsys-test-units` pre-commit hook (fixed
in PR #1419), so the container build matrix was being SKIPPED, not
RUN. As soon as PR #1419 unblocked the matrix, every Linux container
build started failing with the same import error, plus the symmetric
Windows ones.

Concrete blast radius: 15+ vol1 chapters and a similar count in vol2
import `mlsysim.core` directly in their Python chunks (benchmarking,
nn_architectures, hw_acceleration, model_serving, training, ml_ops,
etc.), so this affects every HTML/PDF/EPUB build.

Fix: prepend `<repo_root>/mlsysim/` (where the real package lives) to
PYTHONPATH so `import mlsysim` resolves to the correct file without
requiring `pip install`. Keep the original `<repo_root>` entry so any
existing imports that rely on repo-root scope continue to work.

Verified locally by emulating the Quarto execution context:
  cd book/quarto && PYTHONPATH="../..:../../mlsysim" python3 -c \
    'from mlsysim.core.constants import *; ...'
resolves cleanly. The fix touches all five Quarto config files that
duplicate the PYTHONPATH line (the shared base + 4 PDF variants), so
HTML, PDF, and PDF-copyedit builds all benefit.

Companion to PR #1419 (test_units.py path fix); same root cause,
different surface area.
2026-04-20 13:48:55 -04:00
Vijay Janapa Reddi 2bd6ed1cf0 Prefix unused images with _ and restore TikZ figures from main
- Rename 409 unused image files with _ prefix across vol1 (272) and
  vol2 (137) so they are visually identifiable without being deleted
- Restore polished TikZ figures from main branch into vol2 chapters:
  fault_tolerance, edge_intelligence, security_privacy, distributed_training,
  responsible_ai, sustainable_ai, robust_ai
- Remove all tikz-source backup blocks (0 remaining across vol2)
- Prefix 33 SVG files superseded by restored TikZ with _
- Add GreenL0, chains, shapes.arrows, decorations.pathreplacing to diagram.yml
2026-03-02 15:19:16 -05:00
Vijay Janapa Reddi c30f2a3bfd refactor: move mlsysim to repo root, extract fmt module from viz
Moves the mlsysim package from book/quarto/mlsysim/ to the repo root
so it is importable as a proper top-level package across the codebase.

Key changes:
- mlsysim/fmt.py: new top-level module for all formatting helpers (fmt,
  sci, check, md_math, fmt_full, fmt_split, etc.), moved out of viz/
- mlsysim/viz/__init__.py: now exports only plot utilities; dashboard.py
  (marimo-only) is no longer wildcard-exported and must be imported
  explicitly by marimo labs
- mlsysim/__init__.py: added `from . import fmt` and `from .core import
  constants`; removed broken `from .viz import plots as viz` alias
- execute-env.yml: fixed PYTHONPATH from "../../.." to "../.." so
  chapters resolve to repo root, not parent of repo
- 51 QMD files: updated `from mlsysim.viz import <fmt-fns>` to
  `from mlsysim.fmt import <fmt-fns>`
- book/quarto/mlsys/: legacy shadow package contents cleaned up;
  stub __init__.py remains for backward compat
- All Vol1 and Vol2 chapters verified to build with `binder build pdf`
2026-03-01 17:24:11 -05:00
Vijay Janapa Reddi 9cba37c92d Refactor TikZ figures and standardize code constants
Introduces reusable `pic` definitions for common elements across numerous TikZ diagrams, enhancing modularity and visual consistency. Improves diagram readability through explicit node positioning and refined styling.

Standardizes hardware and model constants in Python code by using specific `mlsys.constants` and dedicated setup classes, improving maintainability and clarity.

Addresses minor LaTeX formatting in math blocks and refines unit-aware calculations.
2026-02-27 07:15:37 -05:00
Vijay Janapa Reddi f6f98266a0 vol2: comprehensive transformation pass (P.I.C.O. refactor, archetypes, hardware trajectories) 2026-02-23 17:38:37 -05:00
Vijay Janapa Reddi 77d0081e38 Refactors build process and validation logic
Refactors the build process to leverage shared output file resolution logic, ensuring consistency across build and debug commands.

Improves validation by streamlining bibliography handling and adding stricter citation matching.

Updates diagram dependencies and adjusts content for clarity and accuracy.
2026-02-22 12:06:46 -05:00
Vijay Janapa Reddi 17117adc70 fix(vol2): use ETH Zurich Blue intensity gradient for Fleet Stack diagrams
Replace four distinct colors (Brown, Blue, Green, Red) with ETHZ Blue
intensity gradient (25%→50%→75%→100%) in fig-fleet-stack and
fig-vol2-roadmap, matching vol1 mlsysstack crimson gradient pattern.
2026-02-21 19:07:08 -05:00
Vijay Janapa Reddi 62b98edee1 Updates book content and configuration
Refines book abstracts, table of contents, and diagram configurations for improved clarity and structure.

This commit enhances the descriptions of both Volume I and Volume II, emphasizing their respective focuses. It also introduces a framework decision tree to guide the selection of parallel training strategies and inference frameworks, and diagrams for visualizing hardware constraints.
2026-02-21 08:19:01 -05:00
Zeljko HrcekandGitHub ae2ef83dd3 Merge branch 'feature/book-volumes' into fix/training 2026-02-21 09:54:24 +01:00
Zeljko Hrcek 403994ea2e Update training chapter and add missing color definition 2026-02-21 09:28:04 +01:00
Vijay Janapa Reddi 739b48622f Add war story callout with proper icon formats and supporting files
- Add war story callout definition in custom-numbered-blocks.yml
- Create war story icon in all three formats (SVG, PNG, PDF) matching
  the 64x64 stroke-only style used by all other callout icons
- Add war story bibliography and PDF config entry
- Add first war story ("The Quadratic Wall") in nn_architectures
- Include icon conversion utility script
2026-02-19 07:38:16 -05:00
Vijay Janapa Reddi 73a956a09b chore(volumes,vscode-ext): batch volume updates and tooling improvements
Checkpoint the branch-wide content/config revisions together with workbench enhancements so chapter rendering and developer workflows stay aligned. This captures the current validation-driven formatting and parallel build/debug improvements in one commit.
2026-02-15 14:03:27 -05:00
Vijay Janapa Reddi df8c3174e5 Refactor: centralize Quarto shared config and streamline PDF build fragments.
Moves common diagram and PDF title/build settings into shared metadata layers, simplifies per-volume configs to keep only volume-specific values, and carries related chapter figure text/asset updates needed in the current working set.
2026-02-12 20:14:31 -05:00
Vijay Janapa Reddi 2390c3ab31 Refactor: consolidate Quarto config layers and content reorganization.
Unifies Quarto metadata into shared base/format/volume fragments while carrying through chapter path, asset, and tooling updates to keep the repository consistent and easier to maintain.
2026-02-12 15:38:55 -05:00