Detached Unattended Execution via Tmux and Stream Telemetry
Agent-Assisted Engineering Check
Prerequisites
Day 58 Preflight validation, Linux tmux/nohup process management.
Learning Objective
Launch pretraining inside a detached tmux session, streaming real-time metrics to structured telemetry logs while decoupling passive waiting time from active study minutes.
Instructions
1. Start the run detached: tmux new-session -d -s pretrain '...' creates the session without attaching. Pipe through tee -a so training.log is appended, never truncated, on a restart.
2. Confirm that both the session (tmux ls) and the process (ps aux | grep '[t]rain.py') exist.
3. Take two log tails a minute apart and check that the step number grew.
4. Disconnect test: close the SSH client without typing exit inside tmux, reconnect, and repeat steps 2 and 3. Explain why the process survived: its parent is the tmux server, not your login shell.
5. Attach with tmux attach -t pretrain to watch, and detach again with Ctrl-B then d.
6. Keep the evidence (both tails, the ps line before and after, wall-clock hours) and log only the minutes you spent reading telemetry as study time; waiting for the GPU is not study.
Time plan (120 min): reading 20 + exercise 70 + check 30. Reading: the nanoGPT train.py logging loop and the W&B experiment-tracking overview. Exercise: steps 1-5 on a mock or real run. Check: reproduce the disconnect test from memory and compare your evidence with the reference.
Practice & Prediction Log
Start a mock training run in a detached session. Verify with ps aux | grep python that it continues executing after disconnecting SSH, appending valid step telemetry to training.log.
Use nohup python3 train.py >> training.log 2>&1 & or tmux detached session.
# 1. Start the run detached. tee -a appends, so a restart never truncates earlier steps.
tmux new-session -d -s pretrain 'python3 train.py 2>&1 | tee -a training.log'
# 2. Confirm that the session and the training process both exist.
tmux ls # expect: pretrain: 1 windows (created ...)
ps aux | grep '[t]rain.py' # the [t] pattern stops grep from matching itself
# 3. Record two log tails a minute apart; the step number must grow.
tail -n 2 training.log; sleep 60; tail -n 2 training.log
# 4. Disconnect test: close the SSH client (do not type exit inside tmux), reconnect, then repeat
# step 2 and step 3. The process survives because the tmux server, not your SSH login shell,
# is its parent. nohup python3 train.py >> training.log 2>&1 & is the no-tmux fallback.
tmux attach -t pretrain # watch live; Ctrl-B then d detaches again without stopping training
# 5. Stop on purpose at the end. Ctrl-C sends SIGINT; train.py should save a checkpoint and exit.
tmux send-keys -t pretrain C-c
# Evidence to keep: the two tails (step grew), the ps line before and after the disconnect,
# and the wall-clock hours. Only the minutes you spent reading telemetry count as study time.
Successfully run a persistent detached training job that streams structured log telemetry.
Authoritative Source Resources & Provenance
Experiment Tracking and Real-Time ML Telemetry Guide
Relevant Section / Range: Experiments overview: How it works (wandb.init, run.log)
Verified Version & Date: W&B Documentation (Verified: 2026-10-30)
Widely adopted concepts for decoupling active human study time from passive unattended GPU training runs.
Loss functions, learning rate schedules, and step loops.
Offline local CSV/JSONL telemetry logging is fully provided in lesson code.
Compared Candidate Sources & Selection Analysis (2)
Local self-hosted visualizer; compared alongside cloud telemetry dashboards.
Enterprise lifecycle manager; W&B is preferred for quick LLM run telemetry.
nanoGPT: train.py pretraining loop
Relevant Section / Range: train.py: logging (wandb_log, wandb.init) and the per-iteration print of loss, time and mfu
Verified Version & Date: Git master commit 71c3905 (Verified: 2026-10-30)
Compact historical code reference for the named implementation functions; CS336 spring2025 provides the lead component exercises. Do not infer top-p, atomic persistence or cloud budget enforcement from nanoGPT.
Python, PyTorch, and Day 46-48 Transformer model architecture.
Runnable pretraining scripts and step-by-step tensor mechanics are fully self-contained in the curriculum lessons.
Compared Candidate Sources & Selection Analysis (2)
Heavy abstraction layer wrapping distributed training; nanoGPT exposes raw PyTorch loops without framework overhead.
High-performance enterprise distributed framework; unsuitable for local educational first-principles comprehension.