repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
cs249r_book
mlperf-edu/src/mlperf/power.py
.py
"""Explicit estimated-energy helper for local educational runs.""" from __future__ import annotations import platform import subprocess import time from typing import Any class PowerMeter: """Record elapsed time and a clearly labeled nominal-power estimate.""" def __init__(self, nominal_watts: float | None...
57
1,736
cs249r_book
mlperf-edu/src/mlperf/experiment.py
.py
from __future__ import annotations import copy import hashlib import json import re from pathlib import Path from typing import Any import yaml from .fingerprint import PERFORMANCE_ENVIRONMENT_ALLOWLIST EXPERIMENT_PLAN_SCHEMA = "mlperf-edu-experiment-plan/0.3" LEGACY_EXPERIMENT_PLAN_SCHEMAS = { "mlperf-edu-exp...
552
20,789
cs249r_book
mlperf-edu/src/mlperf/sut.py
.py
import abc from typing import Any, List, Dict import asyncio from .loadgen import QuerySample class SUT_Interface(abc.ABC): """ MLPerf EDU: System Under Test (SUT) Protocol. Students must inherit from this class to submit optimizations. This strictly decouples the grading framework from the studen...
33
950
cs249r_book
mlperf-edu/src/mlperf/harness.py
.py
from __future__ import annotations import math import random import time from dataclasses import dataclass, field from typing import Any, Callable SCENARIOS = ("offline", "single_stream", "server") @dataclass(frozen=True) class ScenarioConfig: scenario: str = "offline" sample_count: int = 1 batch_size:...
256
8,909
cs249r_book
mlperf-edu/src/mlperf/roofline.py
.py
""" MLPerf EDU: Roofline-coordinate emitter. Wraps a workload's hot loop in a context manager that measures wall time, then divides caller-supplied analytic FLOP and byte counts to produce (arithmetic intensity, achieved FLOPS, achieved bandwidth, dispatch utilization). These analytic sidecars are development diagnost...
244
8,872
cs249r_book
mlperf-edu/src/mlperf/reference/tiny/mlperf_tiny_resnet.py
.py
"""PyTorch adapters for the MLPerf Tiny ResNet8 CIFAR-10 model. The architecture is transcribed from the official MLCommons Tiny repository at commit ``1afd2c9820f795965a6134facd0b4dfae41ef23f``. The pinned upstream ``utils/model.py`` SHA-256 is ``4eb6abbe58eaf4b4c6c5cb2f2988636b172a206652d151282daf8041e8bc8d6b``. """...
174
6,338
cs249r_book
mlperf-edu/src/mlperf/reference/tiny/mlperf_tiny_kws.py
.py
"""PyTorch adapter for the pinned MLPerf Tiny keyword-spotting model. The adapter reads fused weights from the official float32 TFLite artifact. It does not retrain, redesign, or approximate the model topology. The source model is pinned to MLCommons Tiny commit ``1afd2c9820f795965a6134facd0b4dfae41ef23f``. """ from ...
140
5,641
cs249r_book
mlperf-edu/src/mlperf/reference/tiny/mlperf_tiny_anomaly.py
.py
"""PyTorch adapter for the pinned MLPerf Tiny anomaly-detection model. The adapter reads the fused dense weights from the official float32 TFLite artifact. It preserves the complete 640-128-128-128-128-8-128-128-128-128-640 autoencoder and does not retrain, redesign, or approximate the model. """ from __future__ impo...
101
3,493
cs249r_book
mlperf-edu/src/mlperf/reference/tiny/mlperf_tiny_vww.py
.py
"""PyTorch adapter for the pinned MLPerf Tiny visual-wake-words model. The module preserves the official MobileNetV1 0.25 topology and reads fused weights from the MLCommons float32 TFLite artifact. It does not retrain, replace, or approximate the reference model. """ from __future__ import annotations from pathlib ...
197
7,118
cs249r_book
mlperf-edu/src/mlperf/reference/timeseries/patchtst/__init__.py
.py
"""Official PatchTST supervised backbone at the pinned upstream revision.""" from .backbone import PatchTST_backbone __all__ = ["PatchTST_backbone"]
6
151
cs249r_book
mlperf-edu/src/mlperf/reference/timeseries/patchtst/revin.py
.py
# Vendored from PatchTST commit 204c21efe0b39603ad6e2ca640ef5896646ab1a9.\n# Apache-2.0; see the upstream repository for the complete license.\n# code from https://github.com/ts-kim/RevIN, with minor modifications import torch import torch.nn as nn class RevIN(nn.Module): def __init__(self, num_features: int, eps...
65
2,228
cs249r_book
mlperf-edu/src/mlperf/reference/timeseries/patchtst/backbone.py
.py
# Vendored from PatchTST commit 204c21efe0b39603ad6e2ca640ef5896646ab1a9.\n# Apache-2.0; see the upstream repository for the complete license.\n__all__ = ['PatchTST_backbone'] # Cell from typing import Callable, Optional import torch from torch import nn from torch import Tensor import torch.nn.functional as F import ...
381
18,092
cs249r_book
mlperf-edu/src/mlperf/reference/timeseries/patchtst/layers.py
.py
# Vendored from PatchTST commit 204c21efe0b39603ad6e2ca640ef5896646ab1a9.\n# Apache-2.0; see the upstream repository for the complete license.\n__all__ = ['Transpose', 'get_activation_fn', 'moving_avg', 'series_decomp', 'PositionalEncoding', 'SinCosPosEncoding', 'Coord2dPosEncoding', 'Coord1dPosEncoding', 'positional_e...
122
4,865
cs249r_book
mlperf-edu/src/mlperf/reference/cloud/gpt2_infer.py
.py
import torch import torch.nn as nn import math from torch.nn import functional as F class CausalSelfAttention(nn.Module): """Masked multi-head attention with optional KV-cache for autoregressive decode. The KV-cache path enables NanoGPTDecode (iter-3) to demonstrate bandwidth-bound decode behavior: each s...
80
3,214
cs249r_book
mlperf-edu/src/mlperf/reference/cloud/nanogpt_prefill.py
.py
""" MLPerf EDU causal language modeling, prefill phase Single forward pass over a long context while materializing the KV cache. Exercises the compute-bound regime: every weight matrix is reused across `ctx_len` tokens, giving high arithmetic intensity. Should sit on the compute side of the roofline. The prefill and ...
190
6,987
cs249r_book
mlperf-edu/src/mlperf/reference/cloud/nanogpt_train.py
.py
""" NanoGPT model definition for MLPerf EDU. The canonical training entry point is `scripts/verify_training.py`, which loads `NanoGPTWhiteBox` and trains it with the dataset_factory's character-level TinyShakespeare loader. This file exports only the model class and its tokenizer contract; do not add a `run_benchmark`...
120
4,492
cs249r_book
mlperf-edu/src/mlperf/reference/cloud/nanogpt_decode.py
.py
""" MLPerf EDU causal language modeling, decode phase Autoregressive decode with a real KV cache. Each step appends one token's K and V, and attention re-reads the entire cached K, V from DRAM -- the canonical bandwidth-bound regime that dominates LLM serving cost in production. The prefill and decode phases share on...
218
8,543
cs249r_book
mlperf-edu/src/mlperf/runners/ncf.py
.py
"""MLPerf Training v0.5 recommendation: Neural Collaborative Filtering. Thin PyTorch adapter for the retired MLPerf v0.5 recommendation benchmark. The model, dataset, leave-one-out split, evaluator, and 0.635 HR@10 target are inherited unchanged; this module adds execution, measurement boundaries, per-epoch curves, an...
448
17,839
cs249r_book
mlperf-edu/src/mlperf/runners/code_generation.py
.py
from __future__ import annotations import json import math import os import shutil import sys import subprocess import time from pathlib import Path from typing import Any import torch from mlperf.assets import ( EVALPLUS_COMMIT, HUMANEVAL_PLUS_VERSION, ensure_evalplus_evaluator, ensure_humaneval_plu...
714
24,779
cs249r_book
mlperf-edu/src/mlperf/runners/function_calling.py
.py
from __future__ import annotations import hashlib import json import math import os import re import sys import time import types from pathlib import Path from types import SimpleNamespace from typing import Any, Callable import torch from mlperf.assets import ( BFCL_ARCHIVE_SHA256, BFCL_COMMIT, BFCL_EVA...
996
40,371
cs249r_book
mlperf-edu/src/mlperf/runners/evalplus_darwin.py
.py
"""Run the pinned EvalPlus evaluator on macOS without modifying its source. EvalPlus sandboxes each candidate solution in a subprocess that first calls ``reliability_guard``, which caps memory with ``RLIMIT_AS`` and ``RLIMIT_DATA``. Darwin refuses both outright: ``setrlimit`` raises ``ValueError: current limit exceeds...
83
3,103
cs249r_book
mlperf-edu/src/mlperf/runners/nanogpt.py
.py
from __future__ import annotations import json import math import os import statistics import sys import time from pathlib import Path from typing import Any import torch from torch.utils.data import DataLoader, Dataset from mlperf.assets import ensure_tinyshakespeare, sha256_file from mlperf.fingerprint import dete...
1,246
44,304
cs249r_book
mlperf-edu/src/mlperf/runners/timeseries.py
.py
from __future__ import annotations import json import math import os import time from pathlib import Path from typing import Any import numpy as np import pandas as pd import torch from torch import nn from torch.utils.data import DataLoader, Dataset from mlperf.assets import ensure_ettm1 from mlperf.fingerprint imp...
573
20,348
cs249r_book
mlperf-edu/src/mlperf/runners/reinforcement.py
.py
from __future__ import annotations import hashlib import json import os import re import shutil import subprocess import time from pathlib import Path from typing import Any import torch from mlperf.assets import ( MINIGO_COMMIT, MINIGO_SOURCE_FILES, minigo_environment_handoff_contract, ensure_minigo...
455
16,710
cs249r_book
mlperf-edu/src/mlperf/runners/retrieval.py
.py
from __future__ import annotations import json import os import time from pathlib import Path from typing import Any import numpy as np import pandas as pd import torch from mlperf.assets import ensure_nanobeir_reranking, sha256_file from mlperf.fingerprint import detect_hardware from mlperf.manifest import build_pr...
378
14,287
cs249r_book
mlperf-edu/src/mlperf/runners/minigo.py
.py
"""MLPerf Training v0.5 MiniGo: PyTorch adapter over the pinned reference. The historical MiniGo reference is TensorFlow 1.x on CUDA, which no laptop runs. Its Go rules, feature planes, MCTS, self-play loop, SGF handling, and professional-move evaluation are all pure Python and NumPy, so only the network needs replaci...
554
21,368
cs249r_book
mlperf-edu/src/mlperf/runners/text.py
.py
from __future__ import annotations import csv import json import math import os import time from pathlib import Path from typing import Any import torch from mlperf.assets import ensure_sst2, sha256_file, sst2_paths from mlperf.fingerprint import detect_hardware from mlperf.manifest import build_provd from mlperf.re...
314
11,514
cs249r_book
mlperf-edu/src/mlperf/runners/common.py
.py
from __future__ import annotations import os import sys import time from copy import deepcopy def configured_seed(default: int = 42) -> int: """Return the benchmark seed from the shared, documented environment contract.""" for name in ("MLPERF_EDU_SEED", "MLPERF_EDU_MAX_SEED"): value = os.environ.get...
130
4,552
cs249r_book
mlperf-edu/src/mlperf/runners/image_generation.py
.py
from __future__ import annotations import hashlib import json import os import pickle import sys import time from pathlib import Path from typing import Any import numpy as np import torch from PIL import Image from mlperf.assets import ( EDM_CIFAR10_CHECKPOINT_SHA256, EDM_CIFAR10_FID_REFERENCE_SHA256, E...
991
40,203
cs249r_book
mlperf-edu/src/mlperf/runners/vision.py
.py
from __future__ import annotations import json import math import os import sys import time from pathlib import Path from typing import Any import numpy as np import torch from torch.utils.data import DataLoader, Subset from mlperf.assets import ( MLPERF_TINY_COMMIT, ensure_cifar10, ensure_mlperf_tiny_im...
311
11,625
cs249r_book
mlperf-edu/src/mlperf/runners/functional_setup.py
.py
from __future__ import annotations import hashlib import json import math import time from pathlib import Path from typing import Any, Callable import torch from torch import nn from mlperf.fingerprint import detect_hardware from mlperf.manifest import build_provd from mlperf.registry import Workload, find_project_r...
467
15,989
cs249r_book
mlperf-edu/src/mlperf/runners/tiny.py
.py
from __future__ import annotations import csv import json import math import os import sys import time from pathlib import Path from typing import Any import numpy as np import torch from mlperf.assets import ( MLPERF_TINY_ANOMALY_ARCHIVE_MD5, MLPERF_TINY_ANOMALY_COMMIT, MLPERF_TINY_ANOMALY_FLOAT_MODEL_S...
874
32,867
cs249r_book
mlperf-edu/src/mlperf/runners/graph.py
.py
from __future__ import annotations import json import math import os import time from unittest.mock import patch from pathlib import Path from typing import Any import torch import torch.nn.functional as F from mlperf.assets import ensure_ogbn_arxiv from mlperf.fingerprint import detect_hardware from mlperf.manifest...
340
12,403
cs249r_book
mlperf-edu/src/mlperf_edu/__main__.py
.py
from mlperf.edu_cli import main raise SystemExit(main())
5
59
cs249r_book
mlperf-edu/src/mlperf_edu/__init__.py
.py
"""Compatibility package for the MLPerf EDU distribution name.""" from mlperf import * # noqa: F401,F403 __version__ = "0.1.0"
6
130
cs249r_book
mlperf-edu/src/mlperf_edu/cli.py
.py
from mlperf.edu_cli import main if __name__ == "__main__": raise SystemExit(main())
6
90
cs249r_book
tinytorch/tinytorch/__init__.py
.py
""" TinyTorch - Build ML Systems From First Principles A complete educational ML framework for learning neural network internals by implementing everything from scratch. Students progressively build this package module by module. Imports are optional - only available after completing each module. """ from pathlib ...
193
6,180
cs249r_book
tinytorch/milestones/data_manager.py
.py
#!/usr/bin/env python3 """ TinyTorch Dataset Manager ======================== Handles dataset downloading and preparation for milestone examples. Students can focus on demonstrating their ML systems, not fighting with data logistics! Supported Datasets: - MNIST: Handwritten digits (28x28 grayscale) - CIFAR-10: Natura...
332
12,193
cs249r_book
tinytorch/milestones/04_1998_cnn/01_lecun_tinydigits.py
.py
#!/usr/bin/env python3 """ The CNN Revolution (1998) - LeNet Part 1: TinyDigits ==================================================== 📚 HISTORICAL CONTEXT: After backpropagation proved MLPs could learn (1986), researchers still struggled with image recognition. MLPs treated pixels independently, requiring millions of ...
595
29,675
cs249r_book
tinytorch/milestones/04_1998_cnn/02_lecun_cifar10.py
.py
#!/usr/bin/env python3 """ CIFAR-10 CNN (Modern) - Convolutional Revolution =============================================== 📚 HISTORICAL CONTEXT: Convolutional Neural Networks revolutionized computer vision by exploiting spatial structure in images. Unlike MLPs that flatten images (losing spatial relationships), CNNs...
724
37,760
cs249r_book
tinytorch/milestones/06_2018_mlperf/01_optimization_olympics.py
.py
#!/usr/bin/env python3 """ The Optimization Olympics (2018) - MLPerf Benchmarking ====================================================== 📚 HISTORICAL CONTEXT: In 2018, MLPerf was launched to standardize ML benchmarking across hardware and software. The key insight: production ML isn't just about accuracy - efficiency...
963
45,254
cs249r_book
tinytorch/milestones/06_2018_mlperf/networks.py
.py
#!/usr/bin/env python3 """ ╔══════════════════════════════════════════════════════════════════════════════╗ ║ 📦 Pre-Built Networks for Optimization ║ ║ (Same architectures from Milestones 01-05) ║ ╚═══════════════════════════════════════════════...
298
9,821
cs249r_book
tinytorch/milestones/06_2018_mlperf/02_generation_speedup.py
.py
#!/usr/bin/env python3 """ ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ⚡ MILESTONE 06.2: Generation Speedup with KV Caching ║ ║ Make YOUR Transformer Generate Faster (6-10× Speedup) ║ ╚══════════════════════════════════════════════════...
367
15,471
cs249r_book
tinytorch/milestones/02_1969_xor/01_xor_crisis.py
.py
#!/usr/bin/env python3 """ The XOR Crisis (1969) - Minsky & Papert ======================================== 📚 HISTORICAL CONTEXT: In 1969, Marvin Minsky and Seymour Papert published "Perceptrons," mathematically proving that single-layer perceptrons CANNOT solve the XOR problem. This revelation killed neural network ...
381
16,362
cs249r_book
tinytorch/milestones/02_1969_xor/02_xor_solved.py
.py
#!/usr/bin/env python3 """ XOR Solved! Multi-Layer Networks (1986) ======================================== 📚 HISTORICAL CONTEXT: After the 1969 XOR crisis killed neural networks, research funding dried up for over a decade. Then in 1986, Rumelhart, Hinton, and Williams published the backpropagation algorithm for tra...
562
28,535
cs249r_book
tinytorch/milestones/05_2017_transformer/01_vaswani_attention.py
.py
#!/usr/bin/env python3 """ Attention is All You Need (2017) - The Transformer Challenge ============================================================= 📚 HISTORICAL CONTEXT: In 2017, Vaswani et al. published "Attention is All You Need," introducing the Transformer architecture that would power GPT, BERT, and all modern...
856
37,058
cs249r_book
tinytorch/milestones/01_1958_perceptron/01_rosenblatt_forward.py
.py
#!/usr/bin/env python3 """ The Perceptron (1958) - Frank Rosenblatt [FORWARD PASS ONLY] ============================================================= 📚 HISTORICAL CONTEXT: Frank Rosenblatt's Perceptron was the first trainable artificial neural network that could learn from examples. It sparked the first AI boom and d...
438
20,561
cs249r_book
tinytorch/milestones/03_1986_mlp/01_rumelhart_tinydigits.py
.py
#!/usr/bin/env python3 """ MLP on Digits (1986) - Rumelhart, Hinton, Williams ================================================== 📚 HISTORICAL CONTEXT: In 1986, Rumelhart, Hinton, and Williams published "Learning representations by back-propagating errors" in Nature. This paper proved that multi-layer networks could l...
644
30,831
cs249r_book
tinytorch/tito/main.py
.py
""" TinyTorch CLI Main Entry Point A professional command-line interface with proper architecture: - Clean separation of concerns - Proper error handling - Logging support - Configuration management - Extensible command system """ import argparse import logging import os import sys from pathlib import Path from typin...
471
18,944
cs249r_book
tinytorch/tito/__init__.py
.py
""" TinyTorch CLI Package A professional command-line interface for the TinyTorch ML system. Organized with clean separation of concerns and proper error handling. """ from pathlib import Path as _Path def _get_version() -> str: """Read version from pyproject.toml (single source of truth).""" try: py...
25
764
cs249r_book
tinytorch/tito/tools/__init__.py
.py
""" CLI Tools package. Contains utility tools used by the CLI commands. """ from .testing import ( ModuleTestRunner, create_test_runner, run_module_tests_auto, run_module_tests ) __all__ = [ 'ModuleTestRunner', 'create_test_runner', 'run_module_tests_auto', 'run_module_tests' ]
20
314
cs249r_book
tinytorch/tito/tools/testing.py
.py
""" Shared testing infrastructure for TinyTorch modules. This module provides a standardized testing framework that ensures consistent output format and behavior across all TinyTorch modules. """ import sys import traceback import inspect from typing import List, Callable, Tuple, Optional from rich.console import Con...
280
9,585
cs249r_book
tinytorch/tito/core/exceptions.py
.py
""" Exception hierarchy for TinyTorch CLI. """ class TinyTorchCLIError(Exception): """Base exception for all CLI errors.""" pass class ValidationError(TinyTorchCLIError): """Raised when validation fails.""" pass class ExecutionError(TinyTorchCLIError): """Raised when command execution fails.""" ...
24
544
cs249r_book
tinytorch/tito/core/runtime.py
.py
""" Runtime environment detection for the TinyTorch CLI. Single source of truth for two *separate* questions that the rest of the CLI must never conflate: 1. ``is_ci()`` -- are we running inside automation (CI, a pipeline)? 2. ``is_interactive()`` -- can we safely prompt the user and read an answer? Why the...
66
2,408
cs249r_book
tinytorch/tito/core/__init__.py
.py
""" Core CLI functionality and shared utilities. """ from .console import get_console from .exceptions import TinyTorchCLIError, ValidationError, ExecutionError from .config import CLIConfig from .modules import ( get_module_mapping, get_module_name, get_module_display_name, get_next_module, normal...
35
743
cs249r_book
tinytorch/tito/core/modules.py
.py
""" Module definitions for TinyTorch CLI. Auto-discovers modules from the src/ directory structure. This ensures the CLI is always in sync with actual module folders. """ import re from dataclasses import dataclass from functools import lru_cache from pathlib import Path from typing import Dict, Tuple, Optional @da...
252
6,980
cs249r_book
tinytorch/tito/core/virtual_env_manager.py
.py
import os, sys, json from pathlib import Path DEFAULT_VENV = ".venv" CONFIG_FILE = ".tinyrc" def get_venv_bin_dir(venv_path: Path) -> Path: """Return the bin directory for a venv (Scripts/ on Windows, bin/ on Unix).""" if sys.platform == "win32" or os.name == "nt": return venv_path / "Scripts" re...
31
897
cs249r_book
tinytorch/tito/core/console.py
.py
""" Console management for consistent CLI output. """ from rich.console import Console from rich.panel import Panel from rich.text import Text from rich.table import Table from rich.tree import Tree from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn from rich.align import Align from typing import...
147
6,217
cs249r_book
tinytorch/tito/core/auth.py
.py
"""Simple secure JSON credentials storage system for TinyTorch CLI.""" from __future__ import annotations import http.server import threading import json import os import ssl import time import socket import webbrowser import uuid from pathlib import Path from typing import Optional, Dict import urllib.parse from urll...
383
12,741
cs249r_book
tinytorch/tito/core/status_analyzer.py
.py
""" Comprehensive status analysis for TinyTorch modules and environment. This module provides detailed analysis of: - Environment health - Module compliance with TinyTorch standards - Code quality and functionality - Testing status """ import ast import sys import subprocess import importlib.util import traceback imp...
500
19,902
cs249r_book
tinytorch/tito/core/submission.py
.py
""" Handles data aggregation and submission to the Supabase Edge Function. This version is refactored into a class-based handler that integrates with the TinyTorch CLI's config and console objects, using only standard libraries. """ import json import os import ssl import urllib.request import urllib.error from datacl...
343
16,205
cs249r_book
tinytorch/tito/core/config.py
.py
""" Configuration management for TinyTorch CLI. """ import os import sys from pathlib import Path from typing import Dict, Any, Optional, List, Union from dataclasses import dataclass @dataclass class CLIConfig: """Configuration for TinyTorch CLI.""" # Project paths project_root: Path assignments_di...
108
3,896
cs249r_book
tinytorch/tito/core/browser.py
.py
""" Cross-platform browser opening utility for TinyTorch CLI. Handles WSL, macOS, Linux, and Windows environments gracefully. """ import webbrowser import subprocess import platform from typing import Optional from rich.console import Console from rich.panel import Panel def is_wsl() -> bool: """Check if running ...
136
4,128
cs249r_book
tinytorch/tito/core/theme.py
.py
""" TinyTorch CLI Color Theme Consistent color palette for all CLI output. Logo-inspired but terminal-safe for both dark and light backgrounds. """ class Theme: """Centralized color constants for CLI styling.""" # ========================================== # BRAND COLORS # ==========================...
57
2,400
cs249r_book
tinytorch/tito/commands/export_utils.py
.py
""" Shared helpers for TinyTorch export workflows. These utilities are used by both ExportCommand and SrcCommand to avoid duplicate logic when converting source files to notebooks, exporting via nbdev, and protecting generated files. """ import json import re import stat import subprocess from pathlib import Path fro...
303
13,668
cs249r_book
tinytorch/tito/commands/benchmark.py
.py
""" Tiny🔥Torch Benchmark Commands Run baseline and capstone benchmarks, with automatic submission prompts. """ import json import time import platform from argparse import ArgumentParser, Namespace from datetime import datetime from pathlib import Path from typing import Dict, List, Optional, Any, Tuple import numpy...
664
25,465
cs249r_book
tinytorch/tito/commands/setup.py
.py
""" Setup command for Tiny🔥Torch CLI: First-time environment setup and configuration. This replaces the old 01_setup module with a proper CLI command that handles: - Package installation and virtual environment setup - Environment validation and compatibility checking - User profile creation for development tracking ...
682
29,931
cs249r_book
tinytorch/tito/commands/__init__.py
.py
""" CLI Commands package. Each command is implemented as a separate module with proper separation of concerns. Commands are organized into logical groups: system, module, and package. """ from .base import BaseCommand # Individual commands from .nbgrader import NBGraderCommand from .benchmark import BenchmarkCommand...
31
758
cs249r_book
tinytorch/tito/commands/milestone.py
.py
""" Milestone command group for TinyTorch CLI: capability-based learning progression. The milestone system transforms module completion into meaningful capability achievements. Instead of just finishing modules, students unlock epic milestones that represent real-world ML engineering skills. """ from argparse import ...
1,614
68,812
cs249r_book
tinytorch/tito/commands/olympics.py
.py
""" TinyTorch Olympics - Coming Soon! Special competition events where students learn and compete together. """ from argparse import ArgumentParser, Namespace from rich.panel import Panel from rich.align import Align from rich.text import Text from rich.console import Group from .base import BaseCommand class Olymp...
122
6,547
cs249r_book
tinytorch/tito/commands/community.py
.py
""" Tiny🔥Torch Community Commands Login, profile, and community status tools. """ from argparse import ArgumentParser, Namespace from rich.panel import Panel from rich.table import Table from rich import box from .base import BaseCommand from .login import LoginCommand, LogoutCommand from ..core import auth from .....
153
5,298
cs249r_book
tinytorch/tito/commands/nbgrader.py
.py
""" NBGrader integration commands for TinyTorch. This command group is an instructor/developer convenience layer around nbgrader's own workflow. TinyTorch owns module discovery and assignment staging; nbgrader owns release, collection, autograding, feedback, and export. """ import json import re import subprocess fro...
785
32,697
cs249r_book
tinytorch/tito/commands/login.py
.py
# tito/commands/login.py import time from argparse import ArgumentParser, Namespace from rich.panel import Panel from rich.prompt import Confirm from tito.commands.base import BaseCommand from tito.core.auth import AuthReceiver, save_credentials, delete_credentials, ENDPOINTS, is_logged_in from tito.core.browser import...
188
7,969
cs249r_book
tinytorch/tito/commands/base.py
.py
""" Base command class for TinyTorch CLI. """ from abc import ABC, abstractmethod from argparse import ArgumentParser, Namespace from typing import Optional from pathlib import Path import logging import sys import os from contextlib import contextmanager from ..core.config import CLIConfig from ..core.virtual_env_ma...
92
2,657
cs249r_book
tinytorch/tito/commands/module/workflow.py
.py
""" Enhanced Module Workflow for TinyTorch CLI. Implements the natural workflow: 1. tito module start 01 → Opens module 01 in Jupyter 2. Student works and saves 3. tito module complete 01 → Tests, exports, updates progress """ import os import subprocess import sys from argparse import ArgumentParser, Namespace from ...
1,880
80,242
cs249r_book
tinytorch/tito/commands/module/reset.py
.py
""" Module Reset Command for TinyTorch CLI. Simple reset functionality: - Reset a specific module to pristine state (recreate notebook from src/) - Reset all modules (fresh install) """ import json from argparse import ArgumentParser, Namespace from datetime import datetime from pathlib import Path from typing import...
307
11,138
cs249r_book
tinytorch/tito/commands/module/__init__.py
.py
"""Module command group - student workflow for developing modules.""" from .workflow import ModuleWorkflowCommand __all__ = ['ModuleWorkflowCommand']
6
152
cs249r_book
tinytorch/tito/commands/module/test.py
.py
""" Module Test Command for TinyTorch CLI. Provides comprehensive module testing functionality: - Run individual module tests with educational output - Three-phase testing: Inline → Module → Integration - Display detailed test results with WHAT/WHY context - Track test failures and successes This enables students to ...
581
23,183
cs249r_book
tinytorch/tito/commands/dev/export.py
.py
""" Developer export command: rebuilds curriculum from source files. This is a DEVELOPER command for maintainers, NOT for students. Workflow: src/*.py → modules/*.ipynb → tinytorch package files Students should use `tito module complete` which only exports their notebook work to the package (without overwriting their...
312
12,409
cs249r_book
tinytorch/tito/commands/dev/clean.py
.py
""" Developer clean command for TinyTorch CLI. Wraps clean targets so the VS Code extension and other tools can call Tito instead of raw make commands. Usage: tito dev clean Clean all generated files (project root) tito dev clean site Clean site build artifacts """ import subprocess from argpars...
69
2,462
cs249r_book
tinytorch/tito/commands/dev/preflight.py
.py
""" Preflight checks for TinyTorch development and releases. This command runs comprehensive verification before commits, PRs, or releases. The same checks can be used in CI/CD pipelines. Usage: tito dev preflight # Standard preflight (quick + structure) tito dev preflight --full # Full val...
859
32,702
cs249r_book
tinytorch/tito/commands/dev/__init__.py
.py
"""Developer command group for TinyTorch CLI.""" from .dev import DevCommand from .test import DevTestCommand from .build import DevBuildCommand from .clean import DevCleanCommand __all__ = ['DevCommand', 'DevTestCommand', 'DevBuildCommand', 'DevCleanCommand']
9
263
cs249r_book
tinytorch/tito/commands/dev/test.py
.py
""" Unified Developer Test Command for TinyTorch. Simple, explicit test types: tito dev test # Default: unit tests tito dev test --unit # Unit tests only tito dev test --integration # Integration tests tito dev test --e2e # End-to-end tests tito dev test --all ...
1,144
46,744
cs249r_book
tinytorch/tito/commands/dev/build.py
.py
""" Developer build command for TinyTorch CLI. Wraps site/paper build targets so the VS Code extension and other tools can call Tito instead of raw make commands. Usage: tito dev build html Build HTML site tito dev build serve Build and serve locally tito dev build pdf Build PDF course guide ...
96
2,962
cs249r_book
tinytorch/tito/commands/dev/dev.py
.py
""" Developer command group for TinyTorch CLI. These commands are for TinyTorch developers and instructors, not students. Primary command: tito dev test (unified testing) """ from argparse import ArgumentParser, Namespace from rich.panel import Panel from ..base import BaseCommand from .test import DevTestCommand fr...
141
6,081
cs249r_book
tinytorch/tito/commands/package/reset.py
.py
""" Reset command for TinyTorch CLI: resets package and user data. """ import json import shutil from datetime import datetime from argparse import ArgumentParser, Namespace from pathlib import Path from rich.panel import Panel from rich.text import Text from ..base import BaseCommand class ResetCommand(BaseCommand)...
407
15,441
cs249r_book
tinytorch/tito/commands/package/nbdev.py
.py
""" nbdev command for TinyTorch CLI: runs nbdev commands for notebook development. """ import subprocess from argparse import ArgumentParser, Namespace from rich.panel import Panel from ..base import BaseCommand class NbdevCommand(BaseCommand): @property def name(self) -> str: return "nbdev" @pr...
95
3,912
cs249r_book
tinytorch/tito/commands/package/__init__.py
.py
"""Package command group - package management and nbdev integration.""" from .package import PackageCommand __all__ = ['PackageCommand']
6
139
cs249r_book
tinytorch/tito/commands/package/package.py
.py
""" Package command group for TinyTorch CLI: nbdev integration and package management. """ from argparse import ArgumentParser, Namespace from rich.panel import Panel from ..base import BaseCommand from .reset import ResetCommand from .nbdev import NbdevCommand class PackageCommand(BaseCommand): @property de...
76
2,582
cs249r_book
tinytorch/tito/commands/system/reset.py
.py
""" System Reset Command for TinyTorch CLI. Resets the TinyTorch development environment to a pristine state: - Clears modules/ directory (student notebooks) - Clears tinytorch/core/ (exported package code) - Optionally resets progress tracking This is useful for: - Testing fresh install experience - CI/CD pipeline r...
164
5,942
cs249r_book
tinytorch/tito/commands/system/health.py
.py
""" Health command for TinyTorch CLI: environment health check and validation. """ import sys import os import subprocess from argparse import ArgumentParser, Namespace from pathlib import Path from rich.panel import Panel from rich.table import Table from ..base import BaseCommand class HealthCommand(BaseCommand): ...
318
13,089
cs249r_book
tinytorch/tito/commands/system/info.py
.py
""" Info command for TinyTorch CLI: shows system and environment information. """ from argparse import ArgumentParser, Namespace import json as json_module import sys import os import platform import shutil from pathlib import Path from rich.panel import Panel from rich.table import Table from ..base import BaseComma...
172
5,633
cs249r_book
tinytorch/tito/commands/system/__init__.py
.py
"""System command group - environment and configuration management.""" from .system import SystemCommand __all__ = ['SystemCommand']
6
135
cs249r_book
tinytorch/tito/commands/system/system.py
.py
""" System command group for TinyTorch CLI: environment, configuration, and system tools. """ from argparse import ArgumentParser, Namespace from rich.panel import Panel from ..base import BaseCommand from .info import InfoCommand from .health import HealthCommand from .jupyter import JupyterCommand from .update impo...
126
4,421
cs249r_book
tinytorch/tito/commands/system/update.py
.py
""" TinyTorch Update Command Check for updates using GitHub API and perform in-place updates. Uses tinytorch-v* tags to determine latest version. IMPORTANT: This command preserves student work during updates: - modules/ (student notebooks in progress) - tinytorch/core/ (student implementations) - .tito/ ...
438
15,606
cs249r_book
tinytorch/tito/commands/system/logo.py
.py
""" Logo command for TinyTorch CLI: explains the symbolism and meaning behind TinyTorch. """ from argparse import ArgumentParser, Namespace from rich.console import Console from rich.panel import Panel from rich.text import Text from rich.align import Align from pathlib import Path from ..base import BaseCommand cla...
145
6,289
cs249r_book
tinytorch/tito/commands/system/jupyter.py
.py
""" Jupyter command for TinyTorch CLI: starts Jupyter notebook server. """ import subprocess from argparse import ArgumentParser, Namespace from rich.panel import Panel from ..base import BaseCommand class JupyterCommand(BaseCommand): @property def name(self) -> str: return "jupyter" @property ...
53
1,928
cs249r_book
tinytorch/tools/dev/validate_cli_docs.py
.py
#!/usr/bin/env python3 """ Validate that CLI commands referenced in documentation match actual tito CLI. This script extracts all `tito X Y` commands from markdown files and validates them against the actual CLI structure. Runs as a pre-commit hook to catch documentation drift before it reaches the repo. Usage: p...
243
8,661
cs249r_book
tinytorch/tools/dev/collapse_blank_lines.py
.py
#!/usr/bin/env python3 """ Collapse multiple consecutive blank lines into single blank lines. For markdown files, this preserves content inside code blocks (```...```) to avoid interfering with language-specific formatting. """ import sys def collapse_blank_lines(content): """Replace multiple consecutive blank ...
89
2,503
cs249r_book
tinytorch/tools/dev/fix_ascii_boxes.py
.py
#!/usr/bin/env python3 """ Fix ASCII Box and Table Alignment This script finds ASCII art boxes and tables in Python files and ensures the right-side vertical bars (│) are perfectly aligned with the top border. Handles: - Simple boxes (content lines with exactly 2 │) - Boxes with ├───┤ separator lines - Tables with co...
564
18,549