Commit Graph

10423 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
3bb6c5d8da style(ml_systems): remove lone sub-headers that fragment prose
Removed three #### headers (Distributed Processing Architecture,
Battery and Thermal Constraints, Extreme Resource Constraints) that
were the only sub-header under their parent ### section. The content
flows directly as prose under the parent header instead.
2026-02-07 21:17:48 -05:00
Vijay Janapa Reddi
3efe11dff4 style: convert overly granular headers to narrative prose in introduction
The ##### headers under Data/Model/System/Ethical Challenges sections
were too fine-grained — each covered only 1-2 paragraphs under a parent
#### that already named the theme. Converted to flowing prose with
inline emphasis for key terms.

Also updated CLAUDE.md style guide with "too granular for headers"
exception to prevent this pattern in future edits.
2026-02-07 21:16:59 -05:00
Vijay Janapa Reddi
309144ab90 style: convert bold pseudo-headers to proper section headers across all vol1 chapters
Apply consistent formatting rules from the new style guide (CLAUDE.md):
- Bold-start paragraphs that introduce topics with their own discussion
  converted to proper Markdown headers at the appropriate level
- Bold labels inside callout boxes preserved (pedagogical structure)
- Fallacy/Pitfall format preserved (established pattern)
- Bold terms in list items preserved
- Parallel definition-style lists preserved (3+ items, 1-2 sentences)
- Header hierarchy verified strict (no skipped levels)

Affects all 16 main chapters: introduction, ml_systems, dl_primer,
dnn_architectures, training, frameworks, workflow, data_engineering,
data_selection, hw_acceleration, benchmarking, serving, ops,
model_compression, responsible_engr, conclusion.

~200+ individual conversions across 826 insertions, 373 deletions.
2026-02-07 21:14:50 -05:00
Vijay Janapa Reddi
9f786c1879 docs: add section header and bold text style guide to CLAUDE.md
Codifies rules for consistent use of headers vs bold text across
all QMD chapters. Headers for section divisions, bold only inside
callouts, definition lists, fallacy/pitfall labels, and list items.
2026-02-07 20:35:55 -05:00
Vijay Janapa Reddi
a517ef5df6 refactor: editorial improvements across vol1 chapters
Training and Frameworks chapters restructured for clarity.
Data Selection chapter expanded. Header-includes.tex updated.
Various minor fixes across all chapter files.
2026-02-07 20:35:14 -05:00
github-actions[bot]
2ac790601e chore(tinytorch): bump version to tinytorch-v0.1.8 2026-02-07 20:55:09 +00:00
Vijay Janapa Reddi
419eeeb9cf refactor(dnn_architectures): three editorial passes, restructure Evolution section, add cross-chapter hooks
- Fix factual error: FLOPs misconception callout used parameter ratio instead of FLOPs ratio
- Harmonize contradictory energy figures (1 pJ vs 4.6 pJ MAC) with process-node context
- Eliminate six redundancies: RNN memory discussion, information-theoretic restatement,
  double model-compression forward-refs, skip-connection re-introduction, two architecture
  recap paragraphs in Selection Framework
- Fix formatting: Unicode N² → LaTeX $N^2$, inconsistent × notation, empty table row
- Fix self-referential cross-reference, clarify O(1) depth → O(1) sequential steps
- Restructure "Architectural Evolution" → "Cross-Architecture Building Blocks":
  organize by portable engineering primitive (GEMM, skip connections, normalization,
  gating) instead of architecture chronology, with new Born-In/Problem-Solved table
- Add targeted cross-chapter hooks to Vol 1 chapters: @sec-ai-acceleration (8→14),
  @sec-ai-training (1→3), @sec-ai-frameworks (1→3) at natural pedagogical points
- Update dl_primer intro paragraph and other Vol 1 chapter refinements
2026-02-07 15:52:07 -05:00
Vijay Janapa Reddi
967f07cc09 refactor: standardize vol1 cover images and update chapter content
Downscale 3 cover images (hw_acceleration, workflow, conclusion) to
1000x571 to match the majority of chapters. Data_engineering, serving,
and data_selection covers left at original dimensions due to different
aspect ratios requiring lossy cropping. Also includes prose and LaTeX
updates across multiple chapters.
2026-02-07 12:54:39 -05:00
Vijay Janapa Reddi
68b0f24b0f chore: stop tracking index_figures.txt (build artifact) 2026-02-07 10:42:02 -05:00
Vijay Janapa Reddi
18be3650e4 refactor: improve prose flow and add EPUB config for Vol 1
- Remove redundant "This chapter..." openers from section starts
- Improve ml_systems chapter transitions and explanations
- Add EPUB build configuration for Volume 1
- Add index_figures.txt to .gitignore (build artifact)
2026-02-07 10:41:55 -05:00
Vijay Janapa Reddi
4ae406160d feat: add Quarto equation labels and cross-references across Vol 1
Add proper equation labels ({#eq-...}) and prose references (@eq-...)
to 138 equations across 15 Volume 1 chapters following the gold-standard
pattern from serving.qmd.

Key changes:
- Label all display math equations with {#eq-kebab-case-name}
- Add @eq-name references in prose before each equation
- Equations include: Iron Law, Amdahl's Law, Roofline Model,
  activation functions, backpropagation, attention mechanisms,
  queuing theory, quantization, and system throughput formulas

Also includes:
- PDF formatting improvements (newpage directives for Vol 2)
- LaTeX header updates for chapter styling
- Pre-commit config and validation script updates
2026-02-07 09:40:01 -05:00
Vijay Janapa Reddi
8f7cbbd58e feat: add Harris & Harris-style chapter opening design
- Add large decorative chapter number in upper-right corner using TikZ
- Remove redundant "Chapter X" prefix (number serves this purpose)
- Rewrite dropcap filter to process elements in document order
  (fixes bug where filter processed all headers before any paragraphs)
- Add PDF-conditional page break before Learning Objectives in intro
- Adjust section spacing for tighter layout

Design inspired by Harris & Harris "Digital Design and Computer Architecture"
2026-02-06 16:38:14 -05:00
Vijay Janapa Reddi
7ef35ebc1c refactor: standardize Python compute cells across Volume 1
- Move 38 Python cells from inside callouts to before callouts
- Add header box formatting to all 268 compute cells (100% compliance)
- Fix unescaped dollar signs for currency values
- Fix inline Python inside LaTeX math blocks
- Update validator to exclude _str variables from false positives

Chapters updated: serving, training, data_engineering, ml_systems,
data_selection, dl_primer, benchmarking, dnn_architectures,
hw_acceleration, model_compression, conclusion, frameworks,
introduction, ops, workflow, responsible_engr, appendix_*

Validation: 3,708 inline refs, 0 errors, 0 warnings
2026-02-06 16:06:30 -05:00
Vijay Janapa Reddi
44a61a0ab1 fix: resolve duplicate cell label 'foundation-cost-calc' in data_selection
Rename to 'foundation-amortization-data' to avoid collision with the
existing 'foundation-cost-calc' cell earlier in the chapter.
2026-02-06 10:02:09 -05:00
Vijay Janapa Reddi
0343a8a536 fix: resolve pre-commit errors (footnote, label, formatting)
- ml_systems: move [^fn-dgx-spark-edge] footnote out of table cell
  into the table caption text
- data_selection: rename fig-foundation-cost-data to foundation-cost-calc
  (computation cell, not a figure)
- Auto-formatter fixes: collapse blank lines, prettify pipe tables
2026-02-06 10:00:45 -05:00
Vijay Janapa Reddi
3d54da6305 fix: resolve inline Python build errors across Vol 1 chapters
Fix NameError build failures in ml_systems, data_engineering, and
benchmarking chapters caused by missing imports and variables referenced
before their defining code cells.

- ml_systems: add missing Kparam and Bparam imports from physx.constants
- data_engineering: compute transfer_time_10g_md preview in setup cell,
  add md_math import, add deduplication-dividend-calc cell, convert
  hardcoded values to physics engine units
- benchmarking: compute BERT roofline preview values in roofline-example-calc
  cell before they are referenced in narrative text, convert hardcoded
  values to inline Python, condense redundant footnotes

Also includes physics engine integration improvements across all Vol 1
chapters: unit-safe conversions, inline Python for previously hardcoded
values, streamlined footnotes with cross-references, and new content
validation scripts.

All 21 Vol 1 chapters pass PDF build tests.
2026-02-06 09:57:25 -05:00
github-actions[bot]
b01b83506b docs: add @Takosaga as tinytorch contributor for doc, bug 2026-02-06 12:10:07 +00:00
Vijay Janapa Reddi
1d19aa676b refactor: remove conceptual redundancies across Volume 1 chapters
Systematic redundancy removal for MIT Press submission. Applied two-phase
editorial process: (1) identified all conceptual repetition and near-duplication
across main text, examples, and callouts; (2) executed targeted edits to
eliminate redundant content while preserving tone and structure.

Files modified (22 chapters):
- Frontmatter: about, acknowledgements, notation
- Part I: introduction, ml_systems, workflow, data_engineering
- Part II: dl_primer, dnn_architectures, frameworks, training
- Part III: data_selection, hw_acceleration, benchmarking
- Part IV: serving, ops, responsible_engr, conclusion
- Appendices: appendix_dam, appendix_machine, appendix_algorithm, appendix_data

Net reduction: ~72 lines of redundant content removed
2026-02-06 06:49:25 -05:00
Vijay Janapa Reddi
0e17889b20 fix: add caption and alt-text to composite figure in socratiq.qmd
The fig-quizzes composite figure was missing required fig-cap and
fig-alt attributes. Added descriptive caption and accessibility text.
2026-02-06 06:10:48 -05:00
Vijay Janapa Reddi
56657d8152 fix: move footnotes out of forbidden locations (callouts, tables)
- data_engineering.qmd: Move pricing footnote after callout block
- data_engineering.qmd: Convert SATA footnote to inline text
- dl_primer.qmd: Move GPT-4 estimate note to table caption
- introduction.qmd: Move Box quote after callout, remove unused fn-algorithm

All footnotes now follow Quarto rendering rules.
2026-02-06 06:07:08 -05:00
Vijay Janapa Reddi
e942b552ba fix: resolve cross-reference issues and add missing table/figure refs
- Update check_unreferenced_labels.py to detect YAML id: frontmatter
- Add references to all unreferenced tables and listings in Vol1
- Scope unreferenced labels hook to Vol1 only (Vol2 has WIP chapters)
- Fix inline Python in LaTeX math blocks across multiple chapters
- Update test_units.py to use Dense (not Sparse) H100 FLOPS values
- Update validate_inline_refs.py regex to ignore escaped dollar signs

Key files fixed:
- appendix_algorithm.qmd: @tbl-tensor-op-ref, @fig-broadcasting-rules
- appendix_data.qmd: @tbl-data-gravity, @tbl-serialization-cost
- appendix_dam.qmd: @tbl-dam-overlap, @tbl-bottleneck-actions, etc.
- appendix_machine.qmd: @tbl-latency-hierarchy, @tbl-hardware-cheatsheet
- frameworks.qmd: @lst-gradient-accumulation, @lst-custom-autograd-function
- dnn_architectures.qmd: @lst-conv_layer_spatial
2026-02-06 06:03:19 -05:00
Vijay Janapa Reddi
962427ffa2 refactor: continue Physics Engine integration across Volume 1
- Update appendix files with dynamic variable references
- Consolidate references.bib entries
- Apply inline Python patterns to remaining chapters
- Fix notation and formatting consistency
2026-02-06 05:18:43 -05:00
Vijay Janapa Reddi
23d76ac82e Refactor Volume 1 to use dynamic variables from Physics Engine
- Audited all .qmd files in Volume 1 to identify hardcoded numerical constants.
- Replaced hardcoded numbers with dynamic Python variables derived from `physx/constants.py`.
- Updated `physx/constants.py` with missing constants (e.g., battery specs, dataset sizes).
- Created new Python calculation blocks in chapters to derive local metrics (e.g., energy per inference, training costs) from global constants.
- Ensured mathematical consistency across chapters by linking all values to a single source of truth.
- Fixed a citation in references.bib.

This ensures that future updates to core constants (e.g., hardware specs) will automatically propagate throughout the text.
2026-02-06 04:59:21 -05:00
Vijay Janapa Reddi
e5d9dc06e1 refactor: replace remaining hardcoded byte sizes with constants
Additional locations updated to use BYTES_FP32, BYTES_FP16, and ALLREDUCE_FACTOR
from physx/constants.py instead of hardcoded values.

Files updated:
- appendix_algorithm.qmd: bytes_per_fp32 → BYTES_FP32.magnitude
- dl_primer.qmd: bytes_per_param for MNIST → BYTES_FP32.magnitude
- hw_acceleration.qmd: bytes_per_float for tensor calc → BYTES_FP32.magnitude
- serving.qmd: bytes_per_param for KV cache → BYTES_FP16.magnitude
- training.qmd: bytes_per_param_fp16 → BYTES_FP16.magnitude
2026-02-06 03:30:01 -05:00
Vijay Janapa Reddi
2f9899153c style: pre-commit fixes and inline Python improvements
- Fix LaTeX equations in appendix_dam using md() for proper rendering
- Bibtex tidy reformatting of references.bib
- Table alignment fixes across multiple chapters
- Minor formatting cleanup from pre-commit hooks
2026-02-06 03:28:13 -05:00
Vijay Janapa Reddi
8ce4e20549 refactor: use global constants for byte sizes and model parameters
Replace hardcoded byte sizes (2 for FP16, 4 for FP32) and model parameters
with global constants from physx/constants.py for consistency.

Changes:
- Add model_memory() helper to physx/formulas.py for standardized memory calculations
- Replace manual memory calculations with model_memory(params, bytes_per_param, unit)
- Use BYTES_FP16, BYTES_FP32 constants instead of hardcoded 2/4 values
- Use GPT2_PARAMS, GPT3_PARAMS constants instead of local 1.5e9/175e9 values

Files updated: hw_acceleration, dnn_architectures, training, data_engineering,
dl_primer, frameworks
2026-02-06 03:26:33 -05:00
Vijay Janapa Reddi
184fdf34b8 Fix and verify bibliography references
Comprehensive verification and cleanup of references.bib:

- Verified and updated 38 entries with missing URLs/ISBNs/DOIs
- Fixed critical error in vaswani2017attention (Transformer paper)
  - Had incorrect DOI from "Shenzhen Medical Academy" dated 2025
  - Corrected to proper 2017 NeurIPS publication with arXiv URL
- Removed 4 fabricated/unverifiable references
  - Chowdhery2021 (fake Edge TPU paper, not cited)
  - Cheng2022 (fake memory-efficient DL survey)
  - huang2023adaptive (fake autonomous driving paper)
  - yu2023efficient (fake early exit paper)
- Added 2 verified replacement references
  - chen2024eellm (EE-LLM: ICML 2024)
  - seo2023neuroflow (NeuroFlow: arXiv 2023)
- Updated citations in model_compression.qmd to use verified sources

Key papers verified: GPT-3, BERT, Transformer, InstructGPT, Switch
Transformers, Vision Transformer, CLIP, DALL-E, ResNet, SimCLR,
AlpaServe, Ansor, GShard, Clockwork, DeepSpeed, TensorFlow Lite Micro,
MLPerf Mobile, Edge Impulse, and many more.

Results: 759 entries (down from 760), 92.5% with verification metadata,
all critical errors and fabrications eliminated.
2026-02-06 02:17:31 -05:00
Dang Truong
af23c13999 fix small typo (#1163) 2026-02-06 02:09:30 -05:00
Vijay Janapa Reddi
75bb63d9e3 style: standardize compute cell headers with PURPOSE/INPUT/PROCESS/OUTPUT
Apply consistent header format to setup cells in appendix_machine.qmd
and appendix_dam.qmd. All compute cells now follow the same structured
pattern used throughout ml_systems.qmd and other chapters.
2026-02-06 01:33:49 -05:00
Vijay Janapa Reddi
c1a3d08284 refactor: replace hardcoded arithmetic with computed inline refs across Vol1
Convert magic numbers and hardcoded calculations to Python-computed
inline references following the Computed Arithmetic Rule. Changes span
appendices (D·A·M, Machine Foundations), all main chapters, and glossary.

Key improvements:
- Amdahl's/Gustafson's Law examples now compute all derived values
- Training time formula example uses computed days/minutes
- Little's Law example computes concurrent requests from QPS×latency
- Bandwidth-latency example parameterizes link speed and ping
- Glossary consolidates forward pass/forward propagation entries
- Add audit_narrative.py script for prose validation
2026-02-06 01:32:17 -05:00
Vijay Janapa Reddi
2cee4e9b81 Add lead-in sentence for Statistics of Representation callout
Add contextual lead-in before the notebook callout to maintain
consistency with other chapters' callout patterns.
2026-02-06 00:55:31 -05:00
Vijay Janapa Reddi
40e71b54c7 Improve figure reference narrative and fix factual inaccuracies across Vol1
Improve how all ~260 figure references flow in the prose across all 16
chapters and appendices. Replace generic verbs (illustrates, shows, depicts)
with directive, student-engaging language that tells readers what to observe
and why.

Also fix 16 factual inaccuracies found during verification audit:
- introduction: correct compute growth from "five" to "eight" orders of magnitude
- frameworks: fix inverted slope descriptions and crossover magnitudes in
  compilation continuum; correct "embedded targets" to "language bindings"
- data_engineering: remove fabricated "feature engineering" stage from TFX
  pipeline; remove unverifiable animal species names from hard labels
- benchmarking: correct power units from "microwatts/megawatts" to
  "milliwatts/hundreds of kilowatts"
- responsible_engr: correct governance pillar labels to match figure caption
- ml_systems: fix cloud ML examples, mobile ML characteristics, and hybrid
  sync description to match actual figure content
- training: correct LLM scaling curve attribution; fix node color description
- hw_acceleration: fix tiling diagram description
- model_compression: fix quantization error distribution description
- dnn_architectures: fix im2col kernel size; fix attention visualization
2026-02-06 00:08:02 -05:00
Vijay Janapa Reddi
41ef0cacdb wip: isolate hw_acceleration chapter and fix missing imports
- Comment out all chapters except hw_acceleration in PDF config for focused testing
- Add missing physx.constants imports to ml_systems TCO calculation block
- Update figure manifest to reflect single-chapter build
2026-02-05 22:18:03 -05:00
Vijay Janapa Reddi
17c2de646d docs: apply stashed prose improvements and tighten figure references 2026-02-05 21:17:56 -05:00
Vijay Janapa Reddi
3f12a6555e refactor: rename DAM Taxonomy to D·A·M taxonomy and standardize terminology 2026-02-05 21:09:52 -05:00
Vijay Janapa Reddi
956e7277c8 feat(site): auto-generate team page from .all-contributorsrc
Add generate_team.py script that reads .all-contributorsrc and generates
the team.md page automatically. This keeps the website team page in sync
with the README contributors.

- Add tinytorch/site/scripts/generate_team.py
- Update both deploy workflows to run the script before building
- Contributors added via @all-contributors now appear on the website

The script runs during site build, so team.md stays fresh with each deploy.
2026-02-05 20:25:02 -05:00
github-actions[bot]
6c33a3e3ab docs: add @oscarf189 as tinytorch contributor for doc 2026-02-06 01:20:45 +00:00
Vijay Janapa Reddi
c1c8c11eec fix(layers): correct Xavier/Glorot initialization terminology
The formula sqrt(1/fan_in) is actually LeCun initialization (1998),
not Xavier/Glorot. True Xavier uses sqrt(2/(fan_in+fan_out)).

- Rename XAVIER_SCALE_FACTOR → INIT_SCALE_FACTOR
- Update all comments to say "LeCun-style initialization"
- Add note explaining difference between LeCun, Xavier, and He init
- Keep the simpler formula for pedagogical clarity

Fixes #1161
2026-02-05 20:11:50 -05:00
Vijay Janapa Reddi
605c48737d Docs: clarify Vol1 figure context
Tighten surrounding narrative for key figures to note units and illustrative
assumptions without changing the book's structure or tone.
2026-02-05 15:44:53 -05:00
Vijay Janapa Reddi
852bc5c2fc fix(ci): download slide decks from release during deployment
Slides were not loading on the live site because the PDFs exist in a
GitHub Release (tinytorch-slides-v0.1.0) but were never downloaded
during the build process. The .gitignore has *.pdf which prevents
slides from being committed to git.

Add a step to both deployment workflows to download all slide PDFs
from the release and inject them into _static/slides/ before deploy.

Fixes harvard-edge/cs249r_book#1162
2026-02-05 15:43:55 -05:00
Vijay Janapa Reddi
83f05a51b5 feat(pdf): update layout to MIT Press 8x10 specifications
Per MIT Press production feedback (Feb 2026):
- Change paper size from 7x10 to 8x10 inches
- Set 1/2" top margin to header
- Set 5/8" bottom margin
- Set 7/8" gutter (inner margin)
- Move page numbers to outside edge (standard book convention)
- Change PDF layout from TwoPageRight to SinglePage for preflight

Also adds copyedit configs for double-spaced PDFs:
- _quarto-pdf-vol1-copyedit.yml
- _quarto-pdf-vol2-copyedit.yml
2026-02-05 14:28:36 -05:00
kai
0cfebb6f42 index.html comm site with arxiv 2026-02-04 22:23:11 -05:00
Vijay Janapa Reddi
20b54a774e chore: update volume configs and frontmatter assets
Remove legacy _quarto.yml and figure index, adjust volume config files,
refresh acknowledgements/references, and add theme and epub assets.
2026-02-04 17:42:17 -05:00
Vijay Janapa Reddi
0fba57e1b0 docs: annotate egress pricing baseline
Document AWS 2024 egress pricing as the baseline and note it in the data gravity callout.
2026-02-04 17:41:07 -05:00
Vijay Janapa Reddi
354bbeee31 refactor: standardize vol1 constants and conversions
Route canonical time, precision, pricing, and reference values through physx.
Update vol1 QMDs to use shared constants and conversion factors.
2026-02-04 17:32:43 -05:00
Vijay Janapa Reddi
563061a0aa refactor: centralize canonical constants in physx
Move energy, network, AlexNet, and carbon baselines into physx constants.
Wire vol1 QMDs to consume those constants for consistent formatting.
2026-02-04 17:21:11 -05:00
Vijay Janapa Reddi
19fb2fba78 fix: use accelerator-first terminology in purpose sections
Purpose sections are abstract by design—they teach principles,
not specific hardware. Replace GPU/TPU references with
"accelerators" in the three Vol 1 purpose sections that
named specific hardware (serving, hw_acceleration, dl_primer).
2026-02-04 17:20:10 -05:00
Vijay Janapa Reddi
47bd285d29 fix: clarify carbon conversion and derive low-util energy
Make the CO2 conversion formula explicit about the hour term.
Compute low-utilization joules/token from idle power and throughput.
2026-02-04 16:38:22 -05:00
Vijay Janapa Reddi
668cc25030 refactor: inline QMD plots and slim viz helpers
Move remaining plot logic into QMD blocks and keep physx/viz styling-only.
Update preview scripts to use local plot code.
2026-02-04 16:34:31 -05:00
Vijay Janapa Reddi
ab9d9b49a5 feat: Add volume-specific theming system
- Vol1: Harvard Crimson (#A51C30)
- Vol2: ETH Zurich Blue (#1F407A)

Architecture:
- themes/_theme-harvard.scss, _theme-eth.scss: Color variables
- _base-styles.scss, _dark-mode-base.scss: Shared styles using $accent
- style-vol1/2.scss, dark-mode-vol1/2.scss: Entry points per volume

Each volume now has its own distinct visual identity while sharing
the same underlying style rules.
2026-02-04 15:48:52 -05:00