feat(tinytorch): add PDF downloads with 'From Tensors to Systems' subtitle

- Add download links for Guide and Paper PDFs to top navigation bar
- Create manual GitHub Actions workflow for PDF builds (tinytorch-build-pdfs.yml)
- Update title page with 'From Tensors to Systems' in companion box
- Add make targets: paper, downloads
- Include built PDFs in _static/downloads/ for website deployment
This commit is contained in:
Vijay Janapa Reddi
2025-12-07 14:21:37 -08:00
parent cb595aeb9d
commit 980c6b2225
7 changed files with 186 additions and 9 deletions

View File

@@ -0,0 +1,127 @@
name: 📚 TinyTorch Build PDFs
# =============================================================================
# Manual PDF Build Workflow
# =============================================================================
# This is a manual-only workflow for building TinyTorch PDFs.
# It does NOT affect the main site deployment.
#
# Use: Actions → TinyTorch Build PDFs → Run workflow
# =============================================================================
on:
workflow_dispatch:
inputs:
build_guide:
description: 'Build Course Guide PDF'
required: true
type: boolean
default: true
build_paper:
description: 'Build Research Paper PDF'
required: true
type: boolean
default: true
jobs:
build-pdf-guide:
name: '📚 Build Course Guide'
runs-on: ubuntu-latest
if: inputs.build_guide
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'tinytorch/site/requirements.txt'
- name: 📦 Install dependencies
working-directory: tinytorch
run: |
pip install --upgrade pip
pip install -r site/requirements.txt
pip install -e .
- name: 📚 Generate LaTeX
working-directory: tinytorch/site
run: |
jupyter-book build . --builder latex --config _config_pdf.yml
python3 scripts/latex_postprocessor.py
cp _static/logos/fire-emoji.png _build/latex/
cp _static/logos/logo-mlsysbook.png _build/latex/
- name: 📚 Compile PDF with XeLaTeX
uses: xu-cheng/latex-action@v3
with:
root_file: tinytorch-course.tex
working_directory: tinytorch/site/_build/latex
latexmk_use_xelatex: true
- name: 📤 Upload PDF Guide
uses: actions/upload-artifact@v4
with:
name: TinyTorch-Guide
path: tinytorch/site/_build/latex/tinytorch-course.pdf
retention-days: 30
build-pdf-paper:
name: '📑 Build Research Paper'
runs-on: ubuntu-latest
if: inputs.build_paper
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 📑 Compile Paper with LuaLaTeX
uses: xu-cheng/latex-action@v3
with:
root_file: paper.tex
working_directory: tinytorch/paper
latexmk_use_lualatex: true
- name: 📤 Upload PDF Paper
uses: actions/upload-artifact@v4
with:
name: TinyTorch-Paper
path: tinytorch/paper/paper.pdf
retention-days: 30
summary:
name: '📊 Build Summary'
runs-on: ubuntu-latest
needs: [build-pdf-guide, build-pdf-paper]
if: always()
steps:
- name: 📊 Generate Summary
run: |
echo "## 📚 TinyTorch PDF Build" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| PDF | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.build_guide }}" = "true" ]; then
echo "| 📚 Course Guide | ${{ needs.build-pdf-guide.result }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| 📚 Course Guide | skipped |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ inputs.build_paper }}" = "true" ]; then
echo "| 📑 Research Paper | ${{ needs.build-pdf-paper.result }} |" >> $GITHUB_STEP_SUMMARY
else
echo "| 📑 Research Paper | skipped |" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📥 Download" >> $GITHUB_STEP_SUMMARY
echo "PDFs are available as artifacts above (valid for 30 days)." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "To add to the site, download and place in:" >> $GITHUB_STEP_SUMMARY
echo "- \`tinytorch/site/_static/downloads/TinyTorch-Guide.pdf\`" >> $GITHUB_STEP_SUMMARY
echo "- \`tinytorch/site/_static/downloads/TinyTorch-Paper.pdf\`" >> $GITHUB_STEP_SUMMARY

View File

@@ -200,6 +200,10 @@ docs/chapters/modules/*
site/_build/
.envrc
# BUT: Include PDF downloads for the website (shipped with repo)
!site/_static/downloads/
!site/_static/downloads/*.pdf
# Generated tinytorch package (auto-generated from src/ via nbdev_export)
# Single source of truth: src/*/*.py files
tinytorch/*

View File

@@ -1,14 +1,16 @@
# TinyTorch Book Build Makefile
# Convenient shortcuts for building HTML and PDF versions
.PHONY: help html pdf clean install test restore-emoji
.PHONY: help html pdf paper downloads clean install test restore-emoji
help:
@echo "Tiny🔥Torch Build Commands"
@echo "=========================="
@echo ""
@echo " make html - Build HTML version (website)"
@echo " make pdf - Build PDF via XeLaTeX"
@echo " make pdf - Build PDF course guide via XeLaTeX"
@echo " make paper - Build research paper via LuaLaTeX"
@echo " make downloads - Build both PDFs and copy to assets/downloads/"
@echo " make clean - Remove all build artifacts"
@echo " make restore-emoji - Restore original markdown files (if build interrupted)"
@echo " make install - Install Python dependencies"
@@ -79,6 +81,40 @@ restore-emoji:
@echo "🔄 Restoring original markdown files..."
@python3 scripts/emoji_preprocessor.py --restore
paper:
@echo "📑 Building TinyTorch Research Paper via LuaLaTeX..."
@echo ""
@# Check dependencies
@command -v lualatex >/dev/null 2>&1 || { echo "❌ Error: lualatex not found. Install TeX Live from https://www.tug.org/texlive/"; exit 1; }
@echo "✅ Dependencies OK"
@echo ""
@# Build paper
@cd ../paper && lualatex -interaction=nonstopmode paper.tex
@cd ../paper && bibtex paper 2>/dev/null || true
@cd ../paper && lualatex -interaction=nonstopmode paper.tex
@cd ../paper && lualatex -interaction=nonstopmode paper.tex
@echo ""
@# Check if build succeeded
@if [ -f "../paper/paper.pdf" ]; then \
PDF_SIZE=$$(du -h "../paper/paper.pdf" | cut -f1); \
echo "✅ Paper build complete!"; \
echo "📄 Output: ../paper/paper.pdf"; \
echo "📊 Size: $${PDF_SIZE}"; \
else \
echo "❌ Paper compilation failed - check errors above"; \
exit 1; \
fi
downloads: pdf paper
@echo ""
@echo "📦 Copying PDFs to assets/downloads/..."
@mkdir -p _build/html/assets/downloads
@cp _build/latex/tinytorch-course.pdf _build/html/assets/downloads/TinyTorch-Guide.pdf
@cp ../paper/paper.pdf _build/html/assets/downloads/TinyTorch-Paper.pdf
@echo ""
@echo "✅ Downloads ready:"
@ls -lh _build/html/assets/downloads/
# Default target
.DEFAULT_GOAL := help

View File

@@ -228,15 +228,17 @@ sphinx:
colframe=bodygray!4,
boxrule=0pt,
arc=6pt,
width=0.52\textwidth,
width=0.58\textwidth,
halign=center,
left=24pt,
right=24pt,
top=12pt,
bottom=14pt
top=14pt,
bottom=16pt
]
{\fontsize{7}{9}\selectfont\color{bodygray!60}The Build-It-Yourself Companion to the\par}
\vspace{10pt}
{\fontsize{9}{11}\selectfont\color{torchnavy}\textit{From Tensors to Systems}\par}
\vspace{8pt}
{\fontsize{7}{9}\selectfont\color{bodygray!60}A Build-It-Yourself Companion to the\par}
\vspace{8pt}
{\fontsize{8.5}{11}\selectfont\color{torchnavy}\textbf{Machine Learning Systems} textbook\par}
\vspace{6pt}
{\fontsize{7}{9}\selectfont\color{flameorange}\textit{\href{https://mlsysbook.ai}{mlsysbook.ai}}\par}

Binary file not shown.

Binary file not shown.

View File

@@ -17,6 +17,14 @@ document.addEventListener('DOMContentLoaded', function() {
<span class="tinytorch-bar-badge">Under Construction</span>
</div>
<div class="tinytorch-bar-links">
<a href="_static/downloads/TinyTorch-Guide.pdf" class="download-link" title="Download Course Guide (PDF)">
<span class="link-icon">↓</span>
<span class="link-text">Guide</span>
</a>
<a href="_static/downloads/TinyTorch-Paper.pdf" class="download-link" title="Download Research Paper (PDF)">
<span class="link-icon">↓</span>
<span class="link-text">Paper</span>
</a>
<a href="https://mlsysbook.ai" target="_blank">
<span class="link-icon">📖</span>
<span class="link-text">MLSysBook</span>
@@ -25,11 +33,11 @@ document.addEventListener('DOMContentLoaded', function() {
<span class="link-icon">✉️</span>
<span class="link-text">Subscribe</span>
</a>
<a href="https://github.com/mlsysbook/TinyTorch" target="_blank">
<a href="https://github.com/harvard-edge/cs249r_book" target="_blank">
<span class="link-icon">⭐</span>
<span class="link-text">Star</span>
</a>
<a href="https://tinytorch.ai/join" target="_blank">
<a href="community/?action=join" target="_blank">
<span class="link-icon">🌍</span>
<span class="link-text">Community</span>
</a>