ObjectiveRun a small Transformer locally and produce a resource ledger from token IDs to logits.
ArchitectureTokenizer → PyTorch model → profiler trace → latency/memory report. CPU is acceptable; a GPU adds kernel and memory observations.
ImplementationUse model.eval() and torch.inference_mode(): inference mode does not disable dropout by itself. Warm up, synchronize CUDA before and after wall-clock timing (or use CUDA events), and record tensor shapes, parameter bytes, wall time, and peak allocated memory.
ExperimentsSweep prompt lengths 16/64/256/1024 and device-supported precisions. Separate cold start from steady state.
Expected observationsWeight memory stays mostly fixed; activation work grows with tokens; first-run compilation and cache effects distort cold measurements.
Debugging exerciseExplain low GPU utilization: is the model too small, is the CPU/tokenizer gating launches, or are asynchronous launches being timed without waiting for completion?
Optimization exerciseTry inference mode, supported reduced precision, and batching. Predict the limiting resource before measuring.
Final challengeWrite a one-page recommendation: which change helped, why, what metric confirmed it, and what trade-off it introduced.
Score at least 4/5 before marking the module complete.