mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-11-09 10:39:41 -06:00
Release-hardening and transformer-era release of TinyTorch, audited as one tree. This commit brings tinytorch/ and the TinyTorch CI workflows to the state of the audit/tinytorch-release branch, where the individual changes are recorded commit by commit. - Milestones: transformer-era parts (TinyGPT, sequence routing, TinyCopilot, conversational Q&A), Milestone 06 "MLPerf to Generative Serving (2018)", Milestone 07 kernels; per-part recording; NumPy-referenced losses and causality, attention-content and position probes; try-it prompts after a pass. - Framework: dropout eval mode, target gradients, float32 stays float32, layer validation, LoRA adapters. - tito: loopback login callback with a state nonce, consented progress sync, TLS-verified update check, Ctrl-C after a pass keeps the pass. - Grading: graded tests compare values against NumPy references; tests that could not fail now check something. - CI: the publish preflight runs its tests and ships the commit it tested; workflow inputs pass through env; third-party actions pinned. - Guide and book: read line by line against the code; every demo is a real recording. See tinytorch/CHANGELOG.md, section 0.2.0.
296 lines
9.6 KiB
YAML
296 lines
9.6 KiB
YAML
# =============================================================================
|
|
# TINYTORCH: THE XV6 OF MACHINE LEARNING SYSTEMS : QUARTO CONFIGURATION
|
|
# Publication-Grade Textbook Format (Swift Book / Stripe Press / Pragmatic Style)
|
|
# =============================================================================
|
|
|
|
project:
|
|
type: book
|
|
output-dir: _build
|
|
# Code listings are extracted from ../src by symbol name (see tools/listings.yml).
|
|
# A renamed function fails the build here instead of drifting from the chapter.
|
|
pre-render:
|
|
- python3 tools/listings.py --check
|
|
- python3 tools/check_tex_fonts.py
|
|
|
|
book:
|
|
title: "TinyTorch"
|
|
subtitle: "From Tensors to Transformers"
|
|
author: "Vijay Janapa Reddi"
|
|
date: today
|
|
output-file: TinyTorch-Book
|
|
cover-image: assets/images/cover.png
|
|
|
|
chapters:
|
|
- index.qmd
|
|
- preface.qmd
|
|
- 00_welcome.qmd
|
|
- part: "The Core Engine"
|
|
chapters:
|
|
- 01_tensors.qmd
|
|
- 02_activations.qmd
|
|
- 03_layers.qmd
|
|
- 04_losses.qmd
|
|
- 05_dataloader.qmd
|
|
- 06_autograd.qmd
|
|
- 07_optimizers.qmd
|
|
- 08_training.qmd
|
|
- synthesis_01.qmd
|
|
- part: "Deep Architectures"
|
|
chapters:
|
|
- 09_convolutions.qmd
|
|
- 10_tokenization.qmd
|
|
- 11_embeddings.qmd
|
|
- 12_attention.qmd
|
|
- 13_transformers.qmd
|
|
- synthesis_02.qmd
|
|
- part: "Systems & Acceleration"
|
|
chapters:
|
|
- 14_profiling.qmd
|
|
- 15_quantization.qmd
|
|
- 16_compression.qmd
|
|
- 17_acceleration.qmd
|
|
- 18_memoization.qmd
|
|
- 19_benchmarking.qmd
|
|
- 20_capstone.qmd
|
|
- synthesis_03.qmd
|
|
- part: "Extensions & Accelerators"
|
|
chapters:
|
|
- 21_extensions.qmd
|
|
- conclusion.qmd
|
|
|
|
metadata-files:
|
|
- ../../books/config/shared/base/crossref-labels.yml
|
|
- ../../books/config/shared/base/custom-numbered-blocks.yml
|
|
- ../../shared/config/navbar-common.yml
|
|
- ../../shared/config/footer-common.yml
|
|
|
|
format:
|
|
html:
|
|
theme: cosmo
|
|
code-line-numbers: true
|
|
code-block-bg: "#FFF8F0"
|
|
code-block-border-left: "#FF8246"
|
|
highlight-style: tango
|
|
pdf:
|
|
documentclass: book
|
|
papersize: letter
|
|
geometry:
|
|
- inner=1.0in
|
|
- outer=2.2in
|
|
- top=1.0in
|
|
- bottom=1.0in
|
|
- marginparwidth=1.65in
|
|
- marginparsep=0.3in
|
|
pdf-engine: lualatex
|
|
# Use the TeX distribution checked on PATH, not a different private TinyTeX.
|
|
latex-tinytex: false
|
|
reference-location: margin
|
|
citation-location: margin
|
|
|
|
mainfont: "texgyrepagella"
|
|
mainfontoptions:
|
|
- "Extension=.otf"
|
|
- "UprightFont=*-regular"
|
|
- "BoldFont=*-bold"
|
|
- "ItalicFont=*-italic"
|
|
- "BoldItalicFont=*-bolditalic"
|
|
- "Ligatures=TeX"
|
|
sansfont: "texgyreheros"
|
|
sansfontoptions:
|
|
- "Extension=.otf"
|
|
- "UprightFont=*-regular"
|
|
- "BoldFont=*-bold"
|
|
- "ItalicFont=*-italic"
|
|
- "BoldItalicFont=*-bolditalic"
|
|
monofont: "texgyrecursor"
|
|
monofontoptions:
|
|
- "Extension=.otf"
|
|
- "UprightFont=*-regular"
|
|
- "BoldFont=*-bold"
|
|
- "ItalicFont=*-italic"
|
|
- "BoldItalicFont=*-bolditalic"
|
|
- "Scale=0.88"
|
|
|
|
toc: true
|
|
toc-depth: 2
|
|
number-sections: true
|
|
linestretch: 1.12
|
|
colorlinks: true
|
|
linkcolor: torchnavy
|
|
urlcolor: flameorange
|
|
citecolor: torchnavy
|
|
|
|
template-partials:
|
|
- tex/title.tex
|
|
include-before-body:
|
|
- tex/cover.tex
|
|
include-in-header:
|
|
text: |
|
|
\usepackage{tikz}
|
|
\usetikzlibrary{calc,positioning,decorations.pathmorphing}
|
|
\usepackage[most]{tcolorbox}
|
|
\usepackage{fancyhdr}
|
|
\usepackage{titlesec}
|
|
\usepackage{enumitem}
|
|
\usepackage{marginnote}
|
|
\usepackage{marginfix}
|
|
\setlist[enumerate]{itemsep=0.3em,topsep=0.3em}
|
|
\setlist[itemize]{itemsep=0.3em,topsep=0.3em}
|
|
|
|
\renewcommand*{\marginfont}{\normalfont\sffamily\fontsize{7.5pt}{9.5pt}\selectfont\color{bodygray!85}}
|
|
\renewcommand\raggedrightmarginnote{\raggedright}
|
|
\renewcommand\raggedleftmarginnote{\raggedright}
|
|
|
|
|
|
|
|
\definecolor{torchnavy}{RGB}{27,58,95}
|
|
\definecolor{flameorange}{RGB}{255,130,70}
|
|
\definecolor{flamered}{RGB}{210,35,65}
|
|
\definecolor{bodygray}{RGB}{40,40,40}
|
|
\definecolor{codebackground}{RGB}{255,248,240}
|
|
\definecolor{accentwarm}{RGB}{255,160,100}
|
|
|
|
\usepackage{fvextra}
|
|
\renewcommand{\theFancyVerbLine}{\tiny\color{bodygray!60}\arabic{FancyVerbLine}}
|
|
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{%
|
|
breaklines,%
|
|
breakanywhere,%
|
|
fontsize=\small,%
|
|
numbersep=8pt,%
|
|
xleftmargin=18pt,%
|
|
breaksymbolleft={\color{flameorange!60}\hookrightarrow\space},%
|
|
breaksymbolright={},%
|
|
breakanywheresymbolpre={},%
|
|
breakanywheresymbolpost={},%
|
|
commandchars=\\\{\}%
|
|
}
|
|
\RecustomVerbatimEnvironment{verbatim}{Verbatim}{%
|
|
breaklines,%
|
|
breakanywhere,%
|
|
fontsize=\small,%
|
|
breaksymbolleft={\color{flameorange!60}\hookrightarrow\space},%
|
|
breaksymbolright={}%
|
|
}
|
|
|
|
\usepackage[export]{adjustbox}
|
|
\let\TTOrigIncludeGraphics\includegraphics
|
|
\input{tex/print-support.tex}
|
|
|
|
|
|
\makeatletter
|
|
\renewcommand{\l@part}[2]{%
|
|
\addpenalty{-\@highpenalty}%
|
|
\addvspace{2.25em \@plus\p@}%
|
|
\begingroup
|
|
\renewcommand{\numberline}[1]{}%
|
|
\begin{center}
|
|
\bfseries\large\color{torchnavy} #1 \\
|
|
\vspace{0.5em}
|
|
{\color{flameorange!50}\rule{2in}{0.5pt}}
|
|
\end{center}
|
|
\endgroup
|
|
\par\nobreak
|
|
\vspace{1em \@plus\p@}%
|
|
}
|
|
\makeatother
|
|
|
|
\widowpenalty=10000
|
|
\clubpenalty=10000
|
|
\raggedbottom
|
|
|
|
\setlength{\headheight}{20pt}
|
|
\setlength{\headsep}{16pt}
|
|
\renewcommand{\chaptermark}[1]{\markboth{Chapter \thechapter\ · #1}{}}
|
|
\renewcommand{\sectionmark}[1]{\markright{\thesection\ · #1}}
|
|
\fancypagestyle{tinytorch}{%
|
|
\fancyhf{}%
|
|
\fancyhead[LE]{\footnotesize\color{torchnavy!80}\thepage\quad\textcolor{flameorange!60}{\textbar}\quad\color{torchnavy!70}\scshape\nouppercase{\leftmark}}%
|
|
\fancyhead[RO]{\footnotesize\color{torchnavy!70}\scshape\nouppercase{\rightmark}\quad\textcolor{flameorange!60}{\textbar}\quad\color{torchnavy!80}\thepage}%
|
|
\renewcommand{\headrulewidth}{0pt}%
|
|
\renewcommand{\footrulewidth}{0pt}%
|
|
\renewcommand{\headrule}{%
|
|
\vbox to 0pt{%
|
|
\vskip 3pt%
|
|
{\color{flameorange!40}\hrule height 0.4pt}%
|
|
\vss%
|
|
}%
|
|
}%
|
|
}
|
|
\pagestyle{tinytorch}
|
|
\fancypagestyle{plain}{%
|
|
\fancyhf{}%
|
|
\fancyfoot[C]{\small\color{torchnavy!70}\thepage}%
|
|
\renewcommand{\headrulewidth}{0pt}%
|
|
\renewcommand{\footrulewidth}{0pt}%
|
|
}
|
|
|
|
\titleformat{\chapter}[display]
|
|
{\raggedright\normalfont\sffamily}
|
|
{\color{flameorange}\Large\bfseries
|
|
\raisebox{-2pt}{%
|
|
\includegraphics[height=1em]%
|
|
{assets/images/logos/fire-emoji.png}%
|
|
}\,Chapter \thechapter}
|
|
{0.6em}
|
|
{\color{torchnavy}\Huge\bfseries}
|
|
[\vspace{0.5em}%
|
|
{\color{torchnavy!30}\titlerule[0.4pt]}]
|
|
\titlespacing*{\chapter}{0pt}{10pt}{28pt}
|
|
|
|
\titleformat{\part}[display]
|
|
{\centering\normalfont\sffamily}
|
|
{\vspace*{0.15\textheight}%
|
|
{\color{flameorange!50}\titlerule[0.6pt]}\vspace{1em}%
|
|
{\color{flameorange}\large\bfseries\MakeUppercase{\partname~\thepart}}}
|
|
{0.8em}
|
|
{\color{torchnavy}\Huge\bfseries}
|
|
[\vspace{1em}{\color{flameorange!50}\titlerule[0.6pt]}]
|
|
\titlespacing*{\part}{0pt}{0pt}{0pt}
|
|
|
|
\titleformat{\section}
|
|
{\normalfont\sffamily\Large\bfseries\color{torchnavy}}
|
|
{\color{flameorange}\mdseries\thesection}{0.75em}{}
|
|
\titleformat{\subsection}
|
|
{\normalfont\sffamily\large\bfseries\color{torchnavy!85}}
|
|
{\color{torchnavy!60}\thesubsection}{0.6em}{}
|
|
\titleformat{\subsubsection}
|
|
{\normalfont\sffamily\normalsize\bfseries\color{torchnavy!75}}
|
|
{}{0em}{}
|
|
\titlespacing*{\section}{0pt}{1.4em}{0.6em}
|
|
\titlespacing*{\subsection}{0pt}{1.1em}{0.4em}
|
|
\titlespacing*{\subsubsection}{0pt}{0.9em}{0.3em}
|
|
|
|
\setlength{\parskip}{0pt plus 0.5pt}
|
|
\setlength{\parindent}{1.2em}
|
|
\renewcommand{\arraystretch}{1.2}
|
|
|
|
\definecolor{quarto-callout-note-color}{RGB}{27,58,95}
|
|
\definecolor{quarto-callout-tip-color}{RGB}{45,122,61}
|
|
\definecolor{quarto-callout-warning-color}{RGB}{255,130,70}
|
|
\definecolor{quarto-callout-caution-color}{RGB}{210,35,65}
|
|
\definecolor{quarto-callout-important-color}{RGB}{196,82,96}
|
|
\definecolor{quarto-callout-note-color-frame}{RGB}{27,58,95}
|
|
\definecolor{quarto-callout-tip-color-frame}{RGB}{45,122,61}
|
|
\definecolor{quarto-callout-warning-color-frame}{RGB}{255,130,70}
|
|
\definecolor{quarto-callout-caution-color-frame}{RGB}{210,35,65}
|
|
\definecolor{quarto-callout-important-color-frame}{RGB}{196,82,96}
|
|
|
|
\tcbset{%
|
|
fonttitle=\bfseries\sffamily\color{torchnavy},%
|
|
beforeafter skip=6pt%
|
|
}
|
|
|
|
fig-pos: "H"
|
|
fig-align: center
|
|
code-line-numbers: true
|
|
code-block-bg: "#FFF8F0"
|
|
code-block-border-left: "#FF8246"
|
|
highlight-style: tango
|
|
|
|
execute:
|
|
enabled: false
|
|
|
|
filters:
|
|
- strip-emojis.lua
|
|
- ../guide/tools/diagrams/svg-to-pdf.lua
|