Commit Graph

10620 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
ab697a84f2 refactor(milestones): use stdlib tar filter='data' for safe CIFAR-10 extraction 2026-02-22 13:40:09 -05:00
Vijay Janapa Reddi
3a149a06a6 Merge pull request #1182 from RinZ27/fix/safe-data-extraction
Improve dataset extraction robustness
2026-02-22 13:34:06 -05:00
Vijay Janapa Reddi
ddbc0a45e3 Merge branch 'dev' of https://github.com/harvard-edge/cs249r_book into dev 2026-02-22 13:22:49 -05:00
Vijay Janapa Reddi
85c0cd4c83 Merge branch 'feature/tinytorch-core' into dev 2026-02-22 13:22:37 -05:00
Vijay Janapa Reddi
1733596996 style(module 19): fix table alignment in MLPerf benchmark docs 2026-02-22 13:22:31 -05:00
Vijay Janapa Reddi
55007e1f6e docs(module 19): add educational purposes disclaimer for MLPerf 2026-02-22 13:20:12 -05:00
Vijay Janapa Reddi
68d446edcf docs(module 19): add MLPerf trademark attribution and pedagogical framing
- MLPerf® is a trademark of MLCommons
- This module teaches the principles of MLPerf-style benchmarking
2026-02-22 13:19:43 -05:00
Vijay Janapa Reddi
335bad8cd0 fix(module 19): address benchmarking feedback from issue #1196
- Fix Pareto diagram: swap A/C so line has positive slope (latency vs accuracy)
- Add missing Image Classification writeup to Standard Benchmark Tasks
- Treat anomaly_detection as binary classification (np.rand(2))
- Convert MLPerf inputs to Tensors + transpose HWC→CHW for TinyTorch models

Fixes harvard-edge/cs249r_book#1196
2026-02-22 13:18:08 -05:00
Vijay Janapa Reddi
bee7db3a22 Merge pull request #1197 from harvard-edge/fix/ch10
Updated figures in chapter 10: model_compression
2026-02-22 13:09:20 -05:00
Vijay Janapa Reddi
9ab80d7cc0 fix: replace broken research paper link with arXiv PDF
The GitHub link (github.com/harvard-edge/TinyTorch/blob/main/paper/paper.pdf)
returns 404. Use arxiv.org/pdf/2601.19107 instead.

Fixes harvard-edge/cs249r_book#1198
2026-02-22 12:52:11 -05:00
Vijay Janapa Reddi
95956dee3c Scales cover images to 100% width
Ensures cover images in Vol. 2 chapters fill the available width, improving visual presentation across different screen sizes.

Removes duplicate cover image from the introduction chapter.

Corrects a typographical error in Appendix Machine regarding energy ratios.
2026-02-22 12:48: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
Zeljko Hrcek
4884d40b76 Updated figures in chapter 10: model_compression 2026-02-22 18:00:03 +01:00
Vijay Janapa Reddi
e9171b1379 fix: remove duplicate figure captions in vol2
Figures should have caption only in fig-cap attribute, not duplicated
as trailing text. Removed redundant captions from:
- introduction.qmd: fig-loss-vs-n-d, fig-data-scaling-regimes, fig-scaling-regimes
- sustainable_ai.qmd: fig-datacenter-energy-usage
2026-02-22 11:18:32 -05:00
Vijay Janapa Reddi
1a22405288 fix(vol2): correct fenced div closers (:::: → :::) in security_privacy 2026-02-22 10:31:21 -05:00
Vijay Janapa Reddi
e1a667e06f refactor(vol2): convert bold pseudo-headers in collective_communication and robust_ai
- collective_communication: Torus Topology (TPU Pods), Rail-Optimized Routing (NVIDIA DGX) → ####
- robust_ai: Conceptual Foundation, Fast Gradient Sign Method (FGSM) → ######
2026-02-22 10:09:35 -05:00
Vijay Janapa Reddi
1d087503a0 refactor(vol2): convert bold pseudo-headers to proper headers per book-prose rules
- inference: Pattern 1/2/3, Example 8-way tensor parallelism
- sustainable_ai: Hardware/Mobile/Edge measurement, Cascade/Wake-word/Federated
  patterns, TinyML stack, MLPerf benchmarks, Energy Delay Product
- edge_intelligence: Peak Memory Usage, Convergence/Non-IID/Heterogeneity,
  Communication-Computation Trade-off, When Does FL Work?
- ops_scale, fault_tolerance, security_privacy: prior bold-to-header conversions
2026-02-22 10:05:33 -05:00
Vijay Janapa Reddi
266079c816 Enables appendices in PDF output
Uncomments the appendices section in the PDF configuration
file to ensure that appendices are included in the PDF output.
2026-02-22 09:29:45 -05:00
Vijay Janapa Reddi
bccc4d2646 Misc: quarto config, vol2 chapters, vscode-ext utils, remove site_libs clipboard 2026-02-21 19:45:46 -05:00
Vijay Janapa Reddi
4053b73384 Vol2 Fleet Stack: remove vertical line, center three-column example 2026-02-21 19:44:18 -05:00
Vijay Janapa Reddi
f0ddc607d6 Improve vol2 Fleet Stack: subtitles, Part labels, Distribution icon, line wraps 2026-02-21 19:34:05 -05:00
Vijay Janapa Reddi
f44ead20bf Standardize cover images across Vol1 and Vol2; fix Vol2 PDF config
- Cover images: no caption, no fig label, consistent images/ path, fig-alt for all
- Vol1: remove captions from conclusion, data_selection
- Vol2: remove half-title, fix intro/ conclusion/ fleet_orchestration covers;
  add fig-alt to 11 chapters; fix robust_ai path ./images/ -> images/
- Vol2 PDF: use before-body-includes.tex (match Vol1, no half-title)
2026-02-21 19:25:27 -05:00
Vijay Janapa Reddi
40d606fda0 Match Vol2 PDF config to Vol1; sync about.qmd format blocks
- Vol2 PDF: remove half-title, disable lof/lot/lol, toc/number-depth 2, align titlepage
- Vol2 about.qmd: add Beyond This Book and Using This Book supplementary blocks
2026-02-21 19:13:40 -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
f954de69d2 fix: replace directional figure/table refs with explicit @tbl- cross-refs
Replace 'above'/'below' references with stable @tbl- and @fig- IDs
to avoid broken refs when content or layout changes.

Vol 1: model_compression.qmd - deployment gap table
Vol 2: collective_communication, compute_infrastructure, introduction,
       ops_scale
2026-02-21 19:00:36 -05:00
Vijay Janapa Reddi
b1d7fa6778 docs: refactor all 134 definitions across Vol 1 & 2 to Platinum Standard template 2026-02-21 18:54:57 -05:00
Vijay Janapa Reddi
8f6950a257 feat(pdf): align cover layout across volumes, add logo recolor script
- Vol 2: reference/citation at document end, sky-blue logo, cover image position
- Vol 1: match cover image position (bg-image-left 0.175, bg-image-bottom 8)
- Add recolor_cover_logo.py for hue-shift variants of cover logo
2026-02-21 16:20:05 -05:00
Vijay Janapa Reddi
417f47722a fix(pdf): align Vol 2 reference/citation location with Vol 1 (document) 2026-02-21 15:59:29 -05:00
Vijay Janapa Reddi
218ad6ad93 style(tables): use • and <br> for list cells in pipe tables
- edge_intelligence: Constraint-Solution Mapping (•&nbsp; → •<br>)
- security_privacy: Defense Selection Framework (- Item → •<br>)
- sustainable_ai: Critical Materials (semicolons → •<br>)

Consistent with hw_acceleration pattern for HTML/PDF/EPUB.
2026-02-21 15:58:32 -05:00
Vijay Janapa Reddi
b4c86de3f1 refactor(figures): div wrapper pattern, responsive CSS, remove redundant labels
- Wrap Python figures in div with fig-env, fig-pos, fig-cap, fig-alt
- Remove #| label from blocks when div has #fig-xxx
- Add responsive figure CSS (max-width, height: auto) for HTML
- Add figure headers to Python blocks (Context, Goal, Show, How, Imports, Exports)
2026-02-21 15:52:26 -05:00
Vijay Janapa Reddi
99661315eb feat(pdf): pipe table cell line breaks with <br> and makecell
- Add Lua filter to convert <br> in table cells to \makecell for PDF
- Use pipe table with • and <br> in hw_acceleration hardware evolution table
- Add makecell package; set arraystretch to 1.6; top-align makecell cells
- Register filter in PDF config
2026-02-21 15:50:37 -05:00
Vijay Janapa Reddi
eaa545f115 docs: add documentation-style headers to Python figure blocks
Add Context/Goal/Show/How/Imports/Exports headers to all Python figure
blocks (#| label: fig-*) in Vol 1 and Vol 2, matching the setup-block
pattern. Headers placed after Quarto options and before imports.
2026-02-21 14:44:24 -05:00
Vijay Janapa Reddi
b756cb7da3 fix: vscode extension activation error handling and workspace detection
- extension.ts: wrap activate() body in try/catch so activation failures
  surface in the Output channel instead of crashing silently
- workspace.ts: return undefined when no book/binder marker is found
  instead of returning the first workspace folder unconditionally
2026-02-21 14:33:43 -05:00
Vijay Janapa Reddi
9e809d21c4 feat: full-stack Pint robustness and class-based namespace isolation
Python library (mlsys/):
- constants.py: add ureg.default_format, set_application_registry, MS alias comment
- formatting.py: isinstance checks, add fmt_full(), fmt_split(), .m_as() modernization
- formulas.py: fleet formulas return Quantity, @ureg.check() decorators, .m_as() everywhere
- hardware.py: dimension-first validation in __post_init__, Quantity[float] annotations
- models.py: __post_init__ dimension checks, size_in_bytes() enforcement, ureg.count→ureg.param
- test_units.py: +50 robustness tests (wrong-unit HardwareSpec, fleet formulas, fmt_full)
- validate_pint_usage.py: new static analysis script for Pint anti-patterns in QMD files
- transform_pico_cells.py: transformation script for PICO cell restructuring

QMD chapters (Vol1 + Vol2 — all 43 chapters with Python cells):
- Wrapped all Python compute cells in class-based namespace isolation (PICO pattern)
- Added EXPORTS bridges so class-internal values are accessible to prose inline Python
- Modernized .to(unit).magnitude → .m_as(unit) throughout
- Removed bare .magnitude calls; all unit extractions now explicit
- Fleet appendices (appendix_fleet, appendix_communication, appendix_reliability):
  full Quantity-return cascade for MTBF, AllReduce, Young-Daly, checkpoint formulas

All 43 chapters verified building cleanly (HTML) after changes.
2026-02-21 14:33:36 -05:00
Vijay Janapa Reddi
b887b91a2c fix: resolve cross-cell export gaps found during comprehensive HTML build verification
After the class-based namespace isolation pass, missing EXPORTS bridge
variables were discovered by running all chapters through the HTML build pipeline.

Vol1 fixes:
- nn_computation: add hog_grid_str/hog_bins_str exports; convert generator
  expressions to for-loops (Python 3 class scope skips class namespace);
  add mnist_large/small_l1/l2 exports for footnote inline Python
- ml_systems: add cloud_compute/memory/ai_frac, mobile_tops/bw/ratio/
  bottleneck/compute/memory_frac, cloud_thresh_bw_str, edge_thresh_bw_str
  exports; complete ResnetMobile EXPORTS section
- data_selection: fix FpScalingCalc invariant (min_samples_threshold 50→150
  so 100 expected rare samples < 150 threshold holds true)
- model_compression: FusionCalc bandwidth_reduction invariant 50→40%
- nn_architectures: add 'param' unit to lighthouse-table-specs imports

Vol2 fixes:
- data_storage: add missing 'watt' import to chapter setup cell
- fault_tolerance: export per_node_gbs raw float for prose arithmetic
- appendix_fleet: export rho_7b raw float for fmt() call in prose
- appendix_c3: add .magnitude to calc_effective_flops() result (returns
  Quantity since formulas.py upgrade, not raw float)
- appendix_reliability: wrap worked-example-young-daly in class with EXPORTS

All 43 chapters with Python cells verified passing after fixes.
2026-02-21 14:20:43 -05:00
Vijay Janapa Reddi
5677633b4c Update symlinks to point to vol1 build config after Vol1 build run 2026-02-21 10:51:05 -05:00
Vijay Janapa Reddi
edb2dd17b0 Fix Vol1 standalone PDF build errors across 4 chapters
- hw_acceleration: escape % in callout title 'The Five-Percent Utilization Mystery'
  (LaTeX treats % as comment char in div attribute titles, truncating the box)
- data_selection: escape % in callout title 'The Ninety-Nine Percent Sparsity Trap'
  (same \fbxSimple runaway argument error)
- model_compression: remove 28-line orphaned stale class body (merge artifact);
  add missing mat_dim=4096 to LowRankFactorization class parameters
- model_serving: move littles-law-calc code cell before the prose that references
  its exported variables (serving_qps_str etc. used before they were defined)
2026-02-21 10:48:12 -05:00
Vijay Janapa Reddi
35cc915041 fix: ensure all 36 Vol2 chapters build as standalone PDFs
Fixes a series of LaTeX/Pandoc compilation errors across Vol2 so every
chapter builds cleanly with `binder build pdf <chapter> --vol2 -v`.

Key fixes applied:

- Citations removed from fig-caps, table cells, and footnote definitions
  (Quarto 1.8 `marginCitePlaceholderInlineWithProtection` bug with
  `citation-location: margin`); citations restored to surrounding prose
- TikZ nodes with `\\` line breaks given `align=center/left` to exit
  LR mode (robust_ai, sustainable_ai)
- `\argmax` → `\operatorname{arg\,max}` (undefined in amsmath)
- `\texorpdfstring` wrapping for math in section headers (notation)
- Multi-line `{python}` inline expressions in grid tables converted to
  pipe tables (appendix_communication)
- Math expressions split across grid table row boundaries converted to
  pipe tables to avoid `\{\beta\}\$` rendering corruption
- Stale class references (`ImageNetBottleneck`, `PrefetchBuffer`,
  `CheckpointStorage`) fixed → `StorageEconomics.*` (data_storage)
- Missing `batch_per_gpu` factor in aggregate bandwidth formula (data_storage)
- Duplicate `xytext` keyword in `ax.annotate()` call (edge_intelligence)
- `&lt;` HTML entity mixed with unescaped `$` in table cells fixed (security_privacy)
- Incorrect `check()` invariant corrected (appendix_fleet)
2026-02-21 09:44:46 -05:00
github-actions[bot]
8c373dfc58 docs: add @Pratham-ja as tinytorch contributor for code, bug 2026-02-21 14:42:31 +00:00
Vijay Janapa Reddi
94d079b57c Merge feature/tinytorch-core into dev (fixes #1184) 2026-02-21 09:39:50 -05:00
Vijay Janapa Reddi
d7d288dace Fix UnicodeDecodeError on Windows in tito module complete (fixes #1184)
Add encoding='utf-8' and errors='replace' to subprocess.run() calls in
workflow.py so unit and integration test output decode correctly on
Windows (cp1252) when output contains UTF-8 characters.

Co-authored-by: Pratham-ja <114498234+Pratham-ja@users.noreply.github.com>
2026-02-21 09:38:08 -05:00
Vijay Janapa Reddi
fc093ab8de Merge pull request #1194 from harvard-edge/fix/ch5
Update figure in chapter 5
2026-02-21 09:30:09 -05:00
Zeljko Hrcek
678a218372 Update figure in chapter 5 2026-02-21 15:20:35 +01: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
Vijay Janapa Reddi
0614676798 Adds PDF config for Volume II of the book
Creates a YAML configuration file specifically for generating the PDF version of Volume II: Machine Learning Systems at Scale.

This configuration defines the project structure, book metadata (title, author, abstract), chapter organization, and PDF-specific settings like cover page design, table of contents depth, and inclusion of LaTeX files for custom styling.

This allows for independent building and customization of the PDF output for Volume II.
2026-02-21 08:17:13 -05:00
Vijay Janapa Reddi
9e35563d00 Merge remote-tracking branch 'origin/feature/book-volumes' into feature/book-volumes 2026-02-21 08:16:50 -05:00
Vijay Janapa Reddi
c68ca02d9e Enhances data pipeline debugging flowchart
Improves the data pipeline debugging flowchart by adding visual cues.

These cues help to highlight the type of data issue being investigated
and make the flowchart easier to understand.
2026-02-21 08:15:29 -05:00
Vijay Janapa Reddi
87ffaf288d Refines content for Volume 1 conclusion
Enhances the conclusion of Volume 1, improving clarity and flow by:

- Refining wording and structure for better readability
- Clarifying the connection between theoretical invariants and practical applications
- Adding information for clarity and context
2026-02-21 07:59:34 -05:00
Vijay Janapa Reddi
718f867039 Vol1: improve book abstracts and chapter content
- Config: academic, standalone abstracts for PDF/EPUB/copyedit
- Chapters: ml_systems, nn_architectures, nn_computation, training
2026-02-21 06:58:22 -05:00
Zeljko Hrcek
96efa3bf29 Merge pull request #1190 from Zeljko-Hrcek/fix/training
Update training chapter and add missing color definition
2026-02-21 09:55:21 +01:00