rohitg00/ai-engineering-from-scratch · error · SystemExit
torch is required for this lesson. Install with: pip install
Error message
torch is required for this lesson. Install with: pip install torch
What it means
Error "torch is required for this lesson. Install with: pip install torch" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:30
steps on a fixed batch, prints a per-step log, and renders the schedule.
Run: python3 code/main.py
"""
from __future__ import annotations
import csv
import dataclasses
import math
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Callable, Iterable
try:
import torch
from torch import nn
except ImportError as exc:
raise SystemExit(
"torch is required for this lesson. Install with: pip install torch"
) from exc
PLOT_HEIGHT = 12
PLOT_WIDTH = 60
@dataclass
class CosineWithWarmup:
"""Stateless cosine-with-warmup learning-rate schedule.
Step indexing convention: step zero is the very first training update. At
step zero the rate is exactly zero (the warmup ramp starts there). At
step warmup_steps the rate is exactly lr_max. At step total_steps the
rate is exactly lr_min. Past total_steps the rate stays at lr_min.
"""
View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/12e035d11d8bc4e8.
Report an issue: GitHub.