Commit Graph

1553 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
bd5dd6f088 Enhances Quarto build for robustness and dynamic cross-referencing
Configures explicit `render` paths for both volumes to ensure complete and correct builds, particularly for selective rendering workflows.

Replaces the static cross-reference fix script with a dynamic version. This new script automatically discovers and resolves internal links from QMD sources, improving maintainability and ensuring links remain functional during partial book builds.

Adds a new script to check and auto-fix bibliography completeness, facilitating self-contained volumes.

Removes redundant empty Python code blocks from chapter QMDs and refines frontmatter content for consistency.
2026-03-03 16:04:25 -05:00
Vijay Janapa Reddi
0dfbba8f45 Removes generated book compilation files
Deletes temporary files generated during Quarto book compilation, including index files and the figure manifest. This keeps the repository clean by untracking build artifacts.
2026-03-03 15:03:11 -05:00
Vijay Janapa Reddi
d9c2906e40 Adds Windows book builds and refines Quarto content
Introduces Windows HTML, PDF, and EPUB build configurations for both Volume I and Volume II in the GitHub Actions workflow, expanding the available output formats for the book.

Updates Quarto callout and figure syntax from `::::` to `:::` across numerous content files for consistency and compatibility.

Removes unreferenced `war_stories.bib` and `data_engineering.bib` bibliography files and their corresponding entries in Quarto configuration.

Standardizes internal references to the 'Responsible AI' chapter by updating `@sec-responsible-engineering` to `@sec-responsible-ai` for improved linking accuracy throughout the text.
2026-03-03 14:50:20 -05:00
Vijay Janapa Reddi
91e5c320c5 Improves Quarto build and table rendering
Adds PYTHONPATH and MPLBACKEND environment variables to Quarto PDF configurations. This ensures Python code blocks execute reliably, particularly for plot generation.

Refactors table styling in appendix content to use direct Quarto block attributes for the `.column-page` class, simplifying markup and improving consistent layout.
2026-03-03 11:27:25 -05:00
Vijay Janapa Reddi
59b23a22c5 Activates appendices in PDF configurations
Uncomments the `appendices` section in Quarto PDF configuration files for both volumes. This ensures that the specified appendix content is included in the generated PDF output.
2026-03-03 11:19:13 -05:00
Vijay Janapa Reddi
10a2dc4303 fix(docker): add librsvg2-bin to Linux container for rsvg-convert
Quarto's Lua filter calls rsvg-convert to convert SVG figures to PDF
during PDF builds. librsvg2-dev was present (C headers/lib) but the
binary package librsvg2-bin was missing, causing a FATAL build error:
  'Could not convert a SVG to a PDF. Please ensure rsvg-convert is on path'

Also adds rsvg-convert to the Phase 2 verification checks so missing
tools are caught at image build time, not at render time.
2026-03-03 11:05:56 -05:00
Vijay Janapa Reddi
e6bad1fd45 refactor(docker): extract TeX Live install logic into standalone script
Move the ~100-line Phase 4 inline PowerShell block into
book/docker/windows/install_texlive.ps1. The Dockerfile now simply
COPYs and calls the script. Benefits:
- Script can be tested and updated independently of the Dockerfile
- Cleaner, readable PS syntax (no backtick line-continuation noise)
- Docker layer only invalidates when the script actually changes
2026-03-03 08:24:15 -05:00
Vijay Janapa Reddi
96f03a672b fix(build): fix three container build failures across epub, pdf, and html targets
- Remove invalid `output-file` from `project:` block in both EPUB configs
  (Quarto schema only allows `output-file` under `book:`, not `project:`)
- Move `language` to top-level `lang:` and remove HTML-only keys from
  EPUB format blocks (`fig-caption`, `footnotes-hover`, `citations-hover`,
  `code-copy`, `code-line-numbers`, `description`) per Quarto EPUB spec
- Add `matplotlib>=3.7.0` to requirements.txt — was missing from container
  image, causing ModuleNotFoundError during figure rendering
- Add `_matplotlib_available` guard in `viz.setup_plot()` to raise a clear
  ImportError instead of a cryptic AttributeError when matplotlib is absent
2026-03-03 08:14:59 -05:00
Vijay Janapa Reddi
2349e63094 fix(ci): consolidate black version — drop workflow pin, floor to >=24.0.0
The CI workflow hard-pinned black==24.10.0 separately from requirements.txt
(which said >=23.0.0), causing version skew that reformatted 11 QMD files
on every CI run. Remove the override and let requirements.txt be the single
source of truth, bumped to >=24.0.0 to align with current latest.
2026-03-03 07:39:31 -05:00
Vijay Janapa Reddi
6cb39f40ab fix(build): set PYTHONPATH for mlsysim, move output-file to book:, add volume to job name 2026-03-03 07:32:40 -05:00
Vijay Janapa Reddi
79a1015a5c fix(docker): avoid backtick escaping in cmd /c call for install-tl-windows.bat 2026-03-02 22:58:27 -05:00
Vijay Janapa Reddi
83cb23d178 fix(docker): use cmd /c for .bat invocation and fix exit in pwsh inline mode 2026-03-02 22:44:52 -05:00
Vijay Janapa Reddi
b316005230 fix(ci): reformat Python blocks with Black 24.10.0 and fix PS string interpolation
CI pins black==24.10.0 but requirements.txt had black>=23.0.0, causing
pre-commit to reformat 11 QMD files on the CI run and fail. Format all
affected files locally with 24.10.0 to match CI expectations.

Also fix PowerShell PATH string interpolation in Windows Dockerfile:
use explicit concatenation instead of nested method call inside a
double-quoted string, which can be unreliable in some PS contexts.
2026-03-02 22:21:41 -05:00
Vijay Janapa Reddi
bb0cecbe3d chore: add git hooks to run pre-commit on all files (matches CI)
- book/tools/git-hooks/pre-commit: runs pre-commit run --all-files
- setup.sh: one-time config (git config core.hooksPath)
- Ensures local commits pass same checks as CI
2026-03-02 20:45:01 -05:00
Vijay Janapa Reddi
159f4588c8 fix(docker): replace Chocolatey texlive with direct install-tl and mirror fallback
Chocolatey's texlive wrapper sets ErrorActionPreference=Stop and relies on
install-tl picking a random CTAN mirror at runtime. When that mirror is
flaky (as mirrors.rit.edu was), the entire build fails with no fallback.

Switch to calling install-tl-windows.bat directly:
- Set ErrorActionPreference=Continue so we own error handling
- Write a profile with instopt_adjustrepo=0 to prevent auto-mirror switching
- Pass -repository explicitly, trying Illinois → MIT → mirror.ctan.org in order
- Pin tlmgr repository post-install to the same stable mirror
- Remove Chocolatey texlive dependency entirely
2026-03-02 20:38:22 -05:00
Vijay Janapa Reddi
0cc0361f60 fix: remove --params mirror arg from choco texlive install
The InstallerParameters flag passed to install-tl via --params was
corrupting the installer profile, causing abs_path($::installerdir)
to return undef and triggering the 'uninitialized value $tmp' Perl
error at install-tl line 651. Install without params and set the
tlmgr repository mirror post-install instead.
2026-03-02 20:16:37 -05:00
Vijay Janapa Reddi
954b7942c2 chore: harden Windows TeX Live install and default to latest
Improve Windows container reliability by pinning TeX Live installer mirrors with fallback and setting safer Chocolatey CI defaults. Make TeX Live version configurable via build arg and default to latest while retaining override support.
2026-03-02 19:32:40 -05:00
Vijay Janapa Reddi
f64ba2962c chore: resolve pre-commit warning backlog and stabilize checks
Normalize book prose/style issues across touched chapters and remove remaining structural warnings so validation output is clean and reproducible in CI. Also tighten inline/times-spacing validation behavior to reduce noisy false positives while preserving strict checks.
2026-03-02 19:04:35 -05:00
Vijay Janapa Reddi
8129e4b31f Improves artifact verification and output naming
Updates the book publishing workflow to conditionally verify downloaded artifacts based on the `deploy_target` input, preventing failures during partial deployments.

Explicitly sets the output filenames for EPUB and PDF builds in Quarto configurations, ensuring consistent naming for generated book artifacts.
2026-03-02 17:51:04 -05:00
Vijay Janapa Reddi
354cb2000f chore: extract shared HTML footer and update announcement banner
- Add config/shared/html/footer-common.yml with common page-footer elements
  (copyright/license left, GitHub/star right, background, border)
- Reduce _quarto-html-vol1.yml and _quarto-html-vol2.yml page-footer to
  volume-specific center link only; shared elements imported via metadata-files
- Update announcement bar: lead with two-volume launch, keep four-line format
2026-03-02 17:38:30 -05:00
Vijay Janapa Reddi
96fa7ac5e5 chore: bump Quarto to 1.9.27 and R to 4.5.2
- Quarto 1.9.27: Linux (.deb), Windows (direct download; Scoop Extras has 1.8.27)
- R 4.5.2: Linux (CRAN jammy-cran40), Windows (Scoop main/r)
- Baremetal: quarto-actions/setup for both Linux and Windows
- Remove ggrepel version pin (R 4.5.x supports ggrepel 0.9.7)
- Update docs: BUILD.md, CONTAINER_BUILDS.md, docker READMEs
2026-03-02 17:36:35 -05:00
Vijay Janapa Reddi
38ec2d66fb Fix image reference and pre-commit auto-fixes
- Rename _regression_testing.png to regression_testing.png for fault_tolerance.qmd
- Collapse extra blank lines (security_privacy, fault_tolerance)
- Prettify pipe tables (appendix_machine)
2026-03-02 17:21:56 -05:00
Vijay Janapa Reddi
5ec92f5e6a Merge branch 'feature/book-volumes' into dev 2026-03-02 17:16:19 -05:00
Vijay Janapa Reddi
bd151e75ca Expands TikZ libraries and color palette
Incorporates additional TikZ libraries to provide more versatile tools for diagram creation. Also introduces a new `GreenL0` color definition to extend the available color palette for visual elements.
2026-03-02 17:15:57 -05:00
Vijay Janapa Reddi
12ed6525bf Remove root clutter, archive dirs, and build artifacts
- git rm 96 files: one-off scripts (test_simulator.py, list_figs_vol1.py,
  refactor_math_prompt.md), stale archive directories
  (book/tools/scripts/_archive/, book/quarto/scripts/_archive/)
- Move SEMINAL_PAPERS_CORPUS.md and SEMINAL_PAPERS_V2.md to
  .claude/docs/shared/ for proper organization
- Delete local build artifacts: all __pycache__ dirs, .pytest_cache,
  mlsysbook.egg-info, .tito/logs
2026-03-02 17:14:50 -05:00
Vijay Janapa Reddi
0d6b8fee7a feat: add unified memory hierarchy reference and data locality invariant 2026-03-02 17:14:11 -05: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
a88b25a69c Activates full book content for PDF builds
Uncomments all chapters, parts, frontmatter, and appendices in both Volume 1 and Volume 2 Quarto PDF configuration files. This ensures that the complete book content is included when generating PDF outputs.
2026-03-02 12:23:58 -05:00
Vijay Janapa Reddi
1669a5a63e Refactors diagrams to external SVG files
Replaces embedded TikZ code with external SVG image references across various chapters. This change enhances rendering performance, reduces document file size, and improves compatibility.

Includes minor text formatting adjustments for numerical values and symbols.
2026-03-02 12:01:41 -05:00
Vijay Janapa Reddi
e42c8bc4ea Refactor figures to SVG; enhance validation logic
Converts numerous inline TikZ diagrams to external SVG files across the book's content. This improves rendering performance, streamlines figure management, and ensures consistent visual presentation.

Enhances CLI validation by:
- Ignoring cross-reference IDs when checking for multiplication to prevent false positives.
- Stripping inline math spans before currency checks to avoid misinterpreting mathematical expressions as currency.
- Applying hex literal exclusions to pre-processed lines for more accurate validation.

Adds optional Matplotlib import to the plotting module for improved flexibility in environments where the library may not be available.
2026-03-02 11:59:41 -05:00
Vijay Janapa Reddi
d21e34ab73 Refines numerical multiplier formatting
Standardizes the representation of numerical multipliers and ranges across Quarto documents. This change improves the typographic rendering of expressions like `$10\times$` and `1.3--$2\times$`, enhancing consistency and readability of the book's content.
2026-03-02 11:56:05 -05:00
Vijay Janapa Reddi
1f568f4283 Remove hallucinator from default dependency set.
Avoid blocking CI and local bootstrap on an optional reference-check package that is not required by the pre-commit validation path.
2026-03-02 10:44:53 -05:00
Vijay Janapa Reddi
e0117cebfa Merge feature/book-volumes: volumes + tinytorch + kits + colab 2026-03-02 09:45:48 -05:00
Vijay Janapa Reddi
1052b2be31 Update book workflows for volume-only builds
Switch container/baremetal/validate/preview/live flows to vol1+vol2 artifacts, keep baremetal in dev validation, and add stable single-book navbar link.
2026-03-02 09:45:40 -05:00
Vijay Janapa Reddi
a7f9367e42 Merge dev into feature/book-volumes: CI, contributors, workflows
# Conflicts:
#	README.md
2026-03-02 09:38:47 -05:00
Vijay Janapa Reddi
48b519c42e Merge feature/tinytorch-core into feature/book-volumes
# Conflicts:
#	README.md
#	tinytorch/src/01_tensor/01_tensor.py
#	tinytorch/src/15_quantization/ABOUT.md
2026-03-02 09:38:08 -05:00
Vijay Janapa Reddi
73db0e021a Streamlines chapter introduction
Removes a sentence that summarized the chapter's structure.
This change simplifies the immediate opening, aligning with broader content organization efforts.
2026-03-02 09:37:06 -05:00
github-actions[bot]
358879a300 docs: add @salmanmkc as book contributor for doc 2026-03-02 14:01:05 +00:00
Vijay Janapa Reddi
8a1b0b8cd5 Reorganizes Introduction chapter content and prose
Moves the 'Scaling the Machine: From Node to Fleet' section to a more logical position
within the chapter, following the discussion on defining ML systems.

Refines various sentences for improved clarity, conciseness, and a more formal,
impersonal tone. Adds an introductory sentence to better outline the chapter's
structure and movements.
2026-03-02 08:38:57 -05:00
Vijay Janapa Reddi
533cfa6e99 fix: pre-commit hooks — all 48 checks now pass
- book/quarto/mlsys/__init__.py: add repo-root sys.path injection so
  mlsysim is importable when scripts run from book/quarto/ context
- book/quarto/mlsys/{constants,formulas,formatting,hardware}.py: new
  compatibility shims that re-export from mlsysim.core.* and mlsysim.fmt
- mlsysim/viz/__init__.py: remove try/except for dashboard import; use
  explicit "import from mlsysim.viz.dashboard" pattern instead
- .codespell-ignore-words.txt: add "covert" (legitimate security term)
- book/tools/scripts/reference_check_log.txt: delete generated artifact
- Various QMD, bib, md files: auto-formatted by pre-commit hooks
  (trailing whitespace, bibtex-tidy, pipe table alignment)
2026-03-01 17:30:24 -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
6a763c2552 Fix Node 1 NVLink ring arrowhead tangents in hierarchical-allreduce.svg
Offset the 2nd bezier control point x from the endpoint x on all four
Node 1 ring arcs so orient="auto" computes a diagonal arrival angle
instead of a straight vertical arrowhead.
2026-03-01 16:02:21 -05:00
Vijay Janapa Reddi
b0d826df64 Add Vol 2 textbook-quality SVG figures across all 17 chapters
Generated and audited 122 SVG figures covering all Vol 2 chapters:
introduction, compute_infrastructure, network_fabrics, data_storage,
distributed_training, collective_communication, fault_tolerance,
performance_engineering, inference, fleet_orchestration, ops_scale,
edge_intelligence, responsible_ai, robust_ai, security_privacy,
sustainable_ai. All figures follow the shared SVG style guide
(680x460 viewBox, Helvetica Neue, no embedded titles). Layout audit
applied 11 fixes for text overflow, out-of-bounds elements, and
missing arrowheads.
2026-03-01 15:51:20 -05:00
Vijay Janapa Reddi
bf9c402827 Adds callout-definition blocks to all Vol.2 chapters and fixes pre-commit hook errors
- Adds standardized callout-definition blocks with bold term + clear definition
  to all Vol.2 chapters (distributed training, inference, network fabrics, etc.)
- Fixes caption_inline_python errors: replaces Python inline refs in table
  captions with static text in responsible_engr, appendix_fleet, appendix_reliability,
  compute_infrastructure
- Fixes undefined_inline_ref errors: adds missing code fence for PlatformEconomics
  class in ops_scale.qmd; converts display math blocks with Python refs to prose
- Fixes render-pattern errors: moves inline Python outside $...$ math delimiters
  in conclusion, fleet_orchestration, inference, introduction, network_fabrics,
  responsible_ai, security_privacy, sustainable_ai, distributed_training
- Fixes dropcap errors: restructures drop-cap sentences in hw_acceleration and
  nn_architectures to not start with cross-references
- Fixes unreferenced-label errors: removes @ prefix from @sec-/@tbl- refs inside
  Python comment strings in training, model_compression, ml_systems
- Adds clientA to codespell ignore words (TikZ node label in edge_intelligence)
- Updates mlsys constants, hardware, models, and test_units for Vol.2 calculations
- Updates _quarto.yml and references.bib for two-volume structure
2026-03-01 10:44:33 -05:00
Vijay Janapa Reddi
69736d3bdb updates 2026-02-28 18:20:47 -05:00
Vijay Janapa Reddi
3266bc7dfa Standardize chapter discovery via Quarto config
Refactors chapter discovery across CLI commands to use a single, canonical source of truth: the volume's Quarto PDF configuration file.

Introduces a new `get_chapters_from_config` function in `core/discovery.py` that parses the `_quarto-pdf-{volume}.yml` to derive the ordered list of testable chapter stems. This ensures consistent chapter order for `build` and `debug` operations, reducing duplication and improving maintainability.

Updates `build.py` and `debug.py` to delegate all chapter list retrieval to this new centralized method within `ChapterDiscovery`. Also enhances chapter QMD file location to support shared content paths.
2026-02-28 17:08:17 -05:00
Vijay Janapa Reddi
ae6f5d9f11 Refines book structure; modularizes embedded code and updates content
Updates Quarto configurations to reorder, add, and rename appendices across all output formats for both volumes, and includes previously commented chapters in PDF builds.

Encapsulates Python calculation logic and exported variables within dedicated classes across numerous Quarto documents, improving modularity, maintainability, and clarity of in-text references.

Refines MLOps definitions, corrects TCO calculation with distinct inference GPU rates, adjusts distributed training scaling scenarios (e.g., commodity network bandwidth), and clarifies network fabric details (e.g., FEC latency).
2026-02-28 17:00:09 -05:00
Vijay Janapa Reddi
d299e49d10 update 2026-02-28 16:25:00 -05:00
Vijay Janapa Reddi
72d64a5499 cell updates 2026-02-28 13:03:38 -05:00
Vijay Janapa Reddi
2ce322def1 LEGO updates , call out updates 2026-02-28 11:47:42 -05:00