Not in the top 1,000 by GitHub stars
Hanyuyuan6/remote-gpu-trainer
An Agent Skill for Claude Code, Codex and other coding agents: train on rented GPUs without losing checkpoints or paying for idle machines.
History
Review weekly changes to SKILL.md before updating. Dates mark the weeks in which we observed each version; checks apply to the recorded commits.
View weekly changes
SKILL.md
Week of Oct 26, 2026 · Line counts unavailable
Before Not checked yet → After Network or broad shell
First observation → fe01c55c8bae
No earlier version was observed for comparison.
Heat
1.5- Star growth, last 7 daysNot available
- Star growth, last 24 hoursNot available
- Rank movement, last 7 daysNot available
- Commits, last 30 daysNot available
- Accounts asking about it through MCP, last 7 daysNot available
- Hot votes this weekNot available
Heat never changes the order by stars, and sponsorship never touches it. How heat works
Stars over time
30-day change not yet available: not enough history.
Individual skills in this repository
How it works
remote-gpu-trainer
When your agent uses it
AutoDL/vast.ai/RunPod/Lambda/Paperspace远程GPU启动、调试、监控、续训、并行、停止及卡住/OOM/NaN/全零指标排查;可验证状态/selection-best checkpoint/拉回结果。释放实例销毁机器及数据盘,不等同关机。长期镜像/恢复→mirror-research-artifacts。
What it loads into context
Frontmatter
132 tokensAlways available to the agent
SKILL.md
2,899 tokensWhen the skill is activated
Reference documents
190,918 tokensLoaded on request
Token counts are estimates. Scripts run separately; they are not counted as reference context.
The playbook
- Mission
- Start with the outcome, not a package
- Consequence-based assurance
- RUN
- Monitor without burning model turns
- Pull, shutdown, and release are different consequences
- VERIFY
- DELIVER
- Resource router
Scripts executed separately
evals/run_evals.pyevals/test_instruction_surface.pyscripts/aggregate_to_fs.shscripts/build_pull_manifest.pyscripts/check_staleness.pyscripts/compare_acceptance.pyscripts/download_loop.shscripts/gpu_health.shscripts/health_patrol.sh.templatescripts/manifest_scaffold.pyscripts/mem_monitor.shscripts/preflight_audit.pyscripts/reap_vram_zombies.shscripts/reconcile.pyscripts/repro.sh.templatescripts/run_one.sh.templatescripts/run_queue.sh.templatescripts/setup-china-mirrors.shscripts/test_reconcile.pyscripts/verify_artifact_bundle.pyscripts/verify_local.pyscripts/wandb_forensics.py
Files
.gitattributesasset255 bytes.github/ISSUE_TEMPLATE/bug_report.ymlasset721 bytes.github/ISSUE_TEMPLATE/config.ymlasset256 bytes.github/ISSUE_TEMPLATE/new_gotcha.ymlasset1,261 bytes.github/ISSUE_TEMPLATE/new_platform_profile.ymlasset1,309 bytes.github/ISSUE_TEMPLATE/platform_fact_correction.ymlasset1,277 bytes.github/workflows/evals.ymlasset1,019 bytes.gitignoreasset415 bytesLICENSEasset1,067 bytesREADME.mddoc19,833 bytesSECURITY.mddoc1,221 bytesSKILL.mdcore13,453 bytesSKILL.mdcore13,453 bytesSKILL.mdcore13,453 bytesSKILL.mdcore13,453 bytesSKILL.mdcore13,453 bytesTHIRD_PARTY_LICENSESasset2,615 bytesevals/README.mddoc2,669 bytesevals/RESULTS.mddoc3,932 bytesevals/cases.jsonlasset52,645 bytesevals/run_evals.pyruns3,784 bytesevals/test_instruction_surface.pyruns2,242 bytesprofiles/_schema.mddoc5,984 bytesprofiles/autodl.mddoc34,043 bytesprofiles/china.mddoc27,180 bytesprofiles/generic-ssh.mddoc35,699 bytesprofiles/lambda.mddoc25,515 bytesprofiles/local.mddoc12,699 bytesprofiles/paperspace.mddoc26,232 bytesprofiles/runpod.mddoc26,848 bytesprofiles/vastai.mddoc27,923 bytesreferences/delivering/legacy-publication-guidance.mddoc6,502 bytesreferences/run-local/env-hygiene.mddoc9,673 bytesreferences/run-local/launch.mddoc9,819 bytesreferences/run-local/local-oom.mddoc6,098 bytesreferences/run-local/multi-gpu.mddoc3,652 bytesreferences/run-remote/artifact-layout.mddoc9,117 bytesreferences/run-remote/china-network.mddoc11,444 bytesreferences/run-remote/control-economy.mddoc7,859 bytesreferences/run-remote/gotchas_universal.mddoc45,872 bytesreferences/run-remote/lifecycle_checklist.mddoc17,746 bytesreferences/run-remote/monitoring_patterns.mddoc25,543 bytesreferences/run-remote/multinode.mddoc12,083 bytesreferences/run-remote/parallel_ablation.mddoc11,330 bytesreferences/run-remote/principles.mddoc10,215 bytesreferences/run-remote/production-matrix-acceptance.mddoc6,866 bytesreferences/run-remote/spot-resilience.mddoc13,711 bytesreferences/run-remote/ssh_transport.mddoc14,472 bytesreferences/self-improvement.mddoc4,865 bytesreferences/training/by-domain.mddoc31,855 bytesreferences/training/checkpoint-resume.mddoc23,358 bytesreferences/training/convergence-debugging.mddoc38,143 bytesreferences/training/data-pipeline.mddoc23,619 bytesreferences/training/distributed-launch.mddoc27,059 bytesreferences/training/oom-memory.mddoc22,133 bytesreferences/training/precision-stability.mddoc22,150 bytesreferences/training/throughput-profiling.mddoc29,330 bytesreferences/verifying/methodology.mddoc40,208 bytesreferences/verifying/representation-collapse.mddoc8,355 bytesreferences/verifying/smoke-hidden-failures.mddoc6,886 bytesscripts/aggregate_to_fs.shruns3,423 bytesscripts/build_pull_manifest.pyruns5,438 bytesscripts/check_staleness.pyruns2,873 bytesscripts/compare_acceptance.pyruns2,860 bytesscripts/download_loop.shruns4,554 bytesscripts/gpu_health.shruns9,278 bytesscripts/health_patrol.sh.templateruns8,851 bytesscripts/manifest_scaffold.pyruns4,214 bytesscripts/mem_monitor.shruns3,158 bytesscripts/preflight_audit.pyruns15,684 bytesscripts/reap_vram_zombies.shruns7,952 bytesscripts/reconcile.pyruns12,646 bytesscripts/repro.sh.templateruns2,652 bytesscripts/run_one.sh.templateruns7,944 bytesscripts/run_queue.sh.templateruns3,955 bytesscripts/setup-china-mirrors.shruns2,106 bytesscripts/test_reconcile.pyruns5,160 bytesscripts/verify_artifact_bundle.pyruns8,895 bytesscripts/verify_local.pyruns11,510 bytesscripts/wandb_forensics.pyruns5,977 bytes
Read SKILL.md
# Remote GPU Trainer
## Mission
Move one experiment through **RUN → VERIFY → DELIVER** with the least control work that safely advances the
user's outcome. This is the compute/control layer and owns one compute attempt. When the task spans several
runs, nodes, independent side-effect lanes, or paper-wide closeout, route scheduling and state projection to
`research-artifact-hygiene` (closeout ledger); do not duplicate a second controller here. Companion skills named
anywhere in this skill (`research-artifact-hygiene`, `mirror-research-artifacts`, `superpowers:*`,
`huggingface-skills:*`) are optional separate installs: without one, do the equivalent step with your own tools.
## Start with the outcome, not a package
Before tools, write a compact internal decision:View the complete source on GitHubSkills included
- remote-gpu-trainer
Repository facts
- License
- MIT
- Created
- Jun 18, 2026
- Last pushed
- Oct 28, 2026
- Forks
- 6
- Open issues
- 0
- Project activity
- Active
Before you install
Network or broad shellAutomated signals, not a guarantee
Checked Nov 4, 2026
Not fully analyzed: some files were too long, unreadable or missing. This never lowers the level.
Show 8 notes
SKILL.md:1Analysis incomplete: Referenced executable target unavailable; not analyzedSKILL.md:1Analysis incomplete: Referenced executable target unavailable; not analyzedSKILL.md:1Analysis incomplete: Referenced executable target unavailable; not analyzedSKILL.md:1Analysis incomplete: Referenced executable target unavailable; not analyzedevals/cases.jsonl:27Analysis incomplete: physical or joined line exceeds character limitevals/cases.jsonl:28Analysis incomplete: physical or joined line exceeds character limitevals/cases.jsonl:29Analysis incomplete: physical or joined line exceeds character limitreferences/verifying/methodology.md:124Analysis incomplete: physical or joined line exceeds character limit
- No broad tool permissions
- 23 dangerous shell commandsin 11 files: profiles/lambda.md:4 references/training/convergence-debugging.md:10 README.md:17 and 8 more
- 494 network referencesin 23 files: references/training/throughput-profiling.md:32 references/training/by-domain.md:20 references/training/convergence-debugging.md:20 and 20 more
- No hidden or obfuscated text
- No instruction overrides
- 22 executable scriptsin 22 files: evals/run_evals.py:1 evals/test_instruction_surface.py:1 scripts/aggregate_to_fs.sh:1 and 19 more
- 55 references to secretsin 18 files: references/run-remote/ssh_transport.md:10 profiles/lambda.md:39 profiles/vastai.md:36 and 15 more
- No requests to vote in Hot
Show all 594 signals by file
.github/ISSUE_TEMPLATE/config.yml
- Network accessline 2
contact_links: - name: Contributing guide url: https://github.com/Hanyuyuan6/remote-gpu-trainer#contributing - Network accessline 3
- name: Contributing guide url: https://github.com/Hanyuyuan6/remote-gpu-trainer#contributing about: The bar a new gotcha or profile has to clear (root-caused, reproduced, generalizable) before it lands. - Network accessline 4
url: https://github.com/Hanyuyuan6/remote-gpu-trainer#contributing
.gitignore
README.md
- Network accessline 3
[](https://github.com/Hanyuyuan6/remote-gpu-trainer/actions/workflows/evals.yml) - Network accessline 4
[](LICENSE) - Network accessline 12
remote-gpu-trainer is an [Agent Skill](https://agentskills.io) for Claude Code, Codex and other coding agents. It lets your agent launch, monitor, resume and stop training on AutoDL, RunPod, vast.ai, Lambda, Paperspace, four other Chinese G - Dangerous shell operationline 17
- **Paying for idle machines.** A stopped RunPod Pod bills its volume at twice the running rate, a stopped vast.ai instance bills its disk indefinitely, and `sudo shutdown` on Lambda leaves the meter running. The skill knows which action ac - Network accessline 28
Install the remote-gpu-trainer agent skill. Read https://raw.githubusercontent.com/Hanyuyuan6/remote-gpu-trainer/main/README.md - Network accessline 29
https://raw.githubusercontent.com/Hanyuyuan6/remote-gpu-trainer/main/README.md - Network accessline 37
git clone https://github.com/Hanyuyuan6/remote-gpu-trainer.git \ - Network accessline 44
git clone https://github.com/Hanyuyuan6/remote-gpu-trainer.git \ - Dangerous shell operationline 84
| Lambda | `terminate`, which wipes the local NVMe | No stop state; `sudo shutdown` keeps billing; NFS bills until deleted | - Network accessline 99
| Host (linked to its docs) | User skills directory | |---|---| | [Claude Code](https://code.claude.com/docs/en/skills) | `~/.claude/skills/` | - Network accessline 100
|---|---| | [Claude Code](https://code.claude.com/docs/en/skills) | `~/.claude/skills/` | | [OpenAI Codex](https://learn.chatgpt.com/docs/build-skills) | `~/.agents/skills/` | - Network accessline 101
| [Claude Code](https://code.claude.com/docs/en/skills) | `~/.claude/skills/` | - Network accessline 102
| [OpenAI Codex](https://learn.chatgpt.com/docs/build-skills) | `~/.agents/skills/` | - Network accessline 103
| [Cursor](https://cursor.com/docs/skills) | `~/.agents/skills/` | - Network accessline 104
| [Gemini CLI](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/skills.md) | `~/.agents/skills/` | - Network accessline 105
| [GitHub Copilot](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills) | `~/.agents/skills/` | - Network accessline 116
git -C "$SKILLS_DIR/remote-gpu-trainer" pull --ff-only else git clone https://github.com/Hanyuyuan6/remote-gpu-trainer.git \ - Network accessline 117
else git clone https://github.com/Hanyuyuan6/remote-gpu-trainer.git \ "$SKILLS_DIR/remote-gpu-trainer" - Network accessline 118
git clone https://github.com/Hanyuyuan6/remote-gpu-trainer.git \ - Network accessline 124
- Keep the folder name exactly `remote-gpu-trainer`. The Agent Skills spec requires it to match the skill's `name`. - If a non-empty folder of that name exists but is not a git clone, `git clone` stops with an error. Ask the user before rep - Network accessline 125
- If a non-empty folder of that name exists but is not a git clone, `git clone` stops with an error. Ask the user before replacing that folder. - Without git, download `https://github.com/Hanyuyuan6/remote-gpu-trainer/archive/refs/heads/mai - Network accessline 126
- Without git, download `https://github.com/Hanyuyuan6/remote-gpu-trainer/archive/refs/heads/main.tar.gz`, extract it into the skills directory, and rename `remote-gpu-trainer-main` to `remote-gpu-trainer`. - Network accessline 190
The skill is self-contained. Where a separate skill deepens a step, it names one: [superpowers](https://github.com/obra/superpowers) for verification before completion and parallel dispatch, and [Hugging Face skills](https://github.com/hugg - Network accessline 206
Issues and pull requests are welcome, and outside contributions have been merged: [PR #6](https://github.com/Hanyuyuan6/remote-gpu-trainer/pull/6) by [@hector25](https://github.com/hector25) added teardown and billing gotchas for RunPod, va - Network accessline 212
Report vulnerabilities privately through **Security → Advisories → Report a vulnerability** on this repository, not in a public issue, and never include a live secret. Details are in [SECURITY.md](https://github.com/Hanyuyuan6/remote-gpu-tr - Network accessline 243
title = {remote-gpu-trainer: an Agent Skill for the DL experiment lifecycle on owned or rented GPUs}, year = {2026}, url = {https://github.com/Hanyuyuan6/remote-gpu-trainer} - Network accessline 244
year = {2026}, url = {https://github.com/Hanyuyuan6/remote-gpu-trainer} } - Network accessline 245
url = {https://github.com/Hanyuyuan6/remote-gpu-trainer}
evals/cases.jsonl
- Dangerous shell operationline 53
{"id": "node-idles-on-permission-prompt", "prompt": "I launched remote training from my local agent session; the agent then ran some local cleanup that stopped on a permission prompt. Nobody answered overnight and the rented GPU billed for
evals/run_evals.py
- Executable scriptline 1
#!/usr/bin/env python3
evals/test_instruction_surface.py
- Executable scriptline 1
#!/usr/bin/env python3
profiles/autodl.md
- Access to secretsline 43
[Credential-related source omitted] - Access to secretsline 48
[Credential-related source omitted] - Dangerous shell operationline 116
expandable — prefer expand over silently shrinking the experiment (principle #9); present exact `rm -rf` - Network accessline 256
`snapshot_download` hangs or `ConnectTimeout` on big `.safetensors` shards. *Root cause:* (a) HF's Xet CAS backend is not mirror-proxied; (b) `no_proxy` lists `modelscope.com` not `modelscope.cn` (domestic source forced through internationa - Network accessline 257
backend is not mirror-proxied; (b) `no_proxy` lists `modelscope.com` not `modelscope.cn` (domestic source forced through international proxy = slower); (c) a curl test run without turbo measures the wrong path. *Fix:* `export HF_HUB_DISABLE - Network accessline 258
forced through international proxy = slower); (c) a curl test run without turbo measures the wrong path. - Network accessline 259
*Fix:* `export HF_HUB_DISABLE_XET=1` (or `pip uninstall -y hf_xet`) with `HF_ENDPOINT=https://hf-mirror.com`, - Network accessline 291
**AD7 — platform TensorBoard pinned to `/root/tf-logs`; events elsewhere invisible.** *Symptom:* the events file is non-empty and `curl http://127.0.0.1:6007/` returns 200, but the AutoPanel TB tile shows - Network accessline 292
events file is non-empty and `curl http://127.0.0.1:6007/` returns 200, but the AutoPanel TB tile shows - Network accessline 294
/root/tf-logs` and the tile proxies that pid; `--logdir` is hard-pinned and not reconfigurable in-container. *Fix:* write `SummaryWriter(log_dir="/root/tf-logs/<run>")`, or `ln -sfn <your-tb> /root/tf-logs/<run>` (the pinned TB's `--reload= - Network accessline 295
*Fix:* write `SummaryWriter(log_dir="/root/tf-logs/<run>")`, or `ln -sfn <your-tb> /root/tf-logs/<run>` (the pinned TB's `--reload=5` picks it up in ~5 s); verify with `curl … /data/runs`, not `ss`. (Also: restart the TB server to evict STA - Network accessline 296
(the pinned TB's `--reload=5` picks it up in ~5 s); verify with `curl … /data/runs`, not `ss`. (Also: - Network accessline 391
SCRATCH='latest.pth' # mutable resume anchor; active only, never export it HF_HOME=$CACHE_ROOT/huggingface # regenerable cache stays in the exact project layout (AD5) HF_ENDPOINT=https://hf-mirror.com # + HF_HUB_D - Network accessline 392
HF_HOME=$CACHE_ROOT/huggingface # regenerable cache stays in the exact project layout (AD5) HF_ENDPOINT=https://hf-mirror.com # + HF_HUB_DISABLE_XET=1 (AD2) DETACH=tmux # nohup fallback when tmux is absen - Network accessline 393
HF_ENDPOINT=https://hf-mirror.com # + HF_HUB_DISABLE_XET=1 (AD2) - Access to secretsline 402
[Credential-related source omitted]
profiles/china.md
- Network accessline 105
**The entire mirror / proxy / resumable-download story is shared across all CN platforms and lives in `references/run-remote/china-network.md` — do NOT duplicate it here.** That reference owns the mirrors table (PyPI/conda/HF), `HF_ENDPOINT - Network accessline 106
`references/run-remote/china-network.md` — do NOT duplicate it here.** That reference owns the mirrors table (PyPI/conda/HF), `HF_ENDPOINT=https://hf-mirror.com`, the ModelScope fallback, the resumable-download retry ladder, the `hf_transfe - Network accessline 107
(PyPI/conda/HF), `HF_ENDPOINT=https://hf-mirror.com`, the ModelScope fallback, the resumable-download retry - Network accessline 111
- **Gpushare — has a real academic proxy** (the closest analog to AutoDL's `/etc/network_turbo`): `export https_proxy=http://turbo.gpushare.com:<PORT> http_proxy=http://turbo.gpushare.com:<PORT>` - Network accessline 112
`export https_proxy=http://turbo.gpushare.com:<PORT> http_proxy=http://turbo.gpushare.com:<PORT>` - Access to secretsline 130
[Credential-related source omitted] - Network accessline 302
- **Detect a stuck / throttled download.** `du -sh <cache-dir>` twice ~30 s apart — flat size = stalled (often the GFW or a left-on Gpushare turbo proxy restricting a non-whitelisted host, GS2). Cross-check with `curl -sI -x "$https_pro - Network accessline 303
the GFW or a left-on Gpushare turbo proxy restricting a non-whitelisted host, GS2). Cross-check with `curl -sI -x "$https_proxy" https://hf-mirror.com` / `env | grep -i proxy`; `unset http_proxy https_proxy` and retry on the mirror. - Network accessline 304
`curl -sI -x "$https_proxy" https://hf-mirror.com` / `env | grep -i proxy`; `unset http_proxy https_proxy` - Access to secretsline 328
[Credential-related source omitted] - Access to secretsline 333
[Credential-related source omitted]
profiles/generic-ssh.md
- Access to secretsline 34
[Credential-related source omitted] - Network accessline 72
- **Egress/proxy:** host-dependent; there is no platform proxy hook. If the box sits behind the GFW, set the mirror manually — `export HF_ENDPOINT=https://hf-mirror.com` (or `HF_HUB_ENABLE_HF_TRANSFER=1` - Network accessline 73
set the mirror manually — `export HF_ENDPOINT=https://hf-mirror.com` (or `HF_HUB_ENABLE_HF_TRANSFER=1` - Network accessline 174
DATA_DIR=$HOME/proj (working dir / data disk on the box) DURABLE_DIR=$HOME/proj (durable mount; restore canonical bytes to an independent consumer before teardown) PROXY_HOOK= (none by default; set HF_ENDPOINT=https://hf-mirror.co - Network accessline 175
DURABLE_DIR=$HOME/proj (durable mount; restore canonical bytes to an independent consumer before teardown) PROXY_HOOK= (none by default; set HF_ENDPOINT=https://hf-mirror.com only if behind the GFW) CRED_FILE=~/.netrc on the box's lo - Network accessline 176
PROXY_HOOK= (none by default; set HF_ENDPOINT=https://hf-mirror.com only if behind the GFW) - Access to secretsline 177
[Credential-related source omitted] - Access to secretsline 353
[Credential-related source omitted]
profiles/lambda.md
- Dangerous shell operationline 4
meter_stop_verb: terminate # the ONLY action that stops billing; sudo shutdown does NOT - Network accessline 37
- **Web console** at `cloud.lambda.ai` → Instances → Launch (pick GPU type + region, attach a filesystem here if one is needed — see §2; attach any per-instance firewall ruleset here too — see §3/LAM4). - **REST API** — `https://cloud.lam - Network accessline 38
[Credential-related source omitted] - Network accessline 39
[Credential-related source omitted] - Access to secretsline 39
[Credential-related source omitted] - Access to secretsline 48
[Credential-related source omitted] - Dangerous shell operationline 127
`terminate`, or an **improper `sudo shutdown`** that pushes the box to **Alert** while still billing - Dangerous shell operationline 144
> shutdown -h now` or `sudo systemctl poweroff` … These commands will not work as expected and will cause - Dangerous shell operationline 171
AutoDL tmux pattern. Install if absent (`sudo apt install -y tmux`); fall back to - Dangerous shell operationline 197
- **LAM3 — `sudo shutdown` / `poweroff` keeps the meter running (Alert state).** - Dangerous shell operationline 257
`for so in /usr/lib/python3/dist-packages/tensorflow/libcudnn*; do sudo ln -s "$so" /usr/lib/x86_64-linux-gnu/; done` - Network accessline 270
`torch==2.2.0` fails to resolve. → Root cause: GH200 is aarch64; the default PyPI torch wheel for aarch64 is CPU-only. → Fix: use Lambda Stack's pre-compiled ARM PyTorch (e.g. 2.4.1) as-is, or install from the CUDA index `pip install to - Network accessline 271
aarch64 is CPU-only. → Fix: use Lambda Stack's pre-compiled ARM PyTorch (e.g. 2.4.1) as-is, or install from the CUDA index `pip install torch --index-url https://download.pytorch.org/whl/cu128` (aarch64 GPU wheels live there), or compil - Network accessline 272
from the CUDA index `pip install torch --index-url https://download.pytorch.org/whl/cu128` (aarch64 GPU - Network accessline 285
[Credential-related source omitted] - Network accessline 286
[Credential-related source omitted] - Network accessline 287
[Credential-related source omitted] - Access to secretsline 287
[Credential-related source omitted] - Network accessline 288
[Credential-related source omitted] - Network accessline 289
[Credential-related source omitted] - Access to secretsline 289
[Credential-related source omitted] - Access to secretsline 315
[Credential-related source omitted]
profiles/local.md
- Network accessline 78
weights/datasets directly; there is no fatter "on-box pipe" to prefer because the box *is* local. - **China mirror:** only if **your** connection sits behind the GFW — then `export HF_ENDPOINT=https://hf-mirror.com` (detail: `references/r - Network accessline 79
- **China mirror:** only if **your** connection sits behind the GFW — then `export HF_ENDPOINT=https://hf-mirror.com` (detail: `references/run-remote/china-network.md`); otherwise irrelevant. - **Port exposure:** services are already on l - Network accessline 80
HF_ENDPOINT=https://hf-mirror.com` (detail: `references/run-remote/china-network.md`); otherwise irrelevant. - Network accessline 82
then open `http://localhost:6006`. No SSH tunnel, no console port-forward. - Network accessline 160
DATA_DIR=$HOME/proj (working dir / data on your local disk) DURABLE_DIR=$HOME/proj (durable = your own disk; it IS local — no "pull to local" step, but back up irreplaceables yourself) PROXY_HOOK= (none; set HF_ - Network accessline 161
DURABLE_DIR=$HOME/proj (durable = your own disk; it IS local — no "pull to local" step, but back up irreplaceables yourself) PROXY_HOOK= (none; set HF_ENDPOINT=https://hf-mirror.com only if YOUR connection is behind the - Network accessline 162
PROXY_HOOK= (none; set HF_ENDPOINT=https://hf-mirror.com only if YOUR connection is behind the GFW) - Access to secretsline 163
[Credential-related source omitted]
profiles/paperspace.md
profiles/runpod.md
- Network accessline 80
- **Spot / interruptible** — set `interruptible: true` (REST) or bid via legacy GraphQL. Roughly **~50% cheaper** than On-Demand (verified runpod.io/blog/spot-vs-on-demand-instances-runpod: e.g. A6000 spot $0.232 vs on-demand $0.491/gpu/hr - Network accessline 81
- **On-Demand** — non-interruptible while running, but carries the sneakier **zero-GPU-on-restart** trap (RP1): a stopped Pod is pinned to its host, and if that GPU is rented away the Pod can only restart **with zero GPUs** ("there are no G - Network accessline 93
- **Terminate is the meter-stop verb AND it is destructive.** "Terminating permanently deletes all data not stored in a network volume. Export important data first." (verified docs.runpod.io/pods/manage-pods 2026-06). Move every needed arti - Network accessline 94
- **Low-balance auto-stop → silent deletion.** When the account balance can no longer cover remaining runtime, RunPod **auto-stops all Pods**; storage then keeps accruing on the stopped volume disk, and **a depleted balance can have Pods + - Network accessline 95
- **Billing granularity:** compute + container/volume disk bill **per second**; Network Volumes bill **hourly** (verified https://docs.runpod.io/references/billing-information 2026-06). - Network accessline 108
- **RP1 — Zero-GPU-on-restart.** Symptom: a stopped Pod restarts with no GPU attached and refuses compute work ("Zero GPU Pods"). Root cause: a stopped Pod stays bound to its physical host; another user rented that GPU while it was stopped. - Access to secretsline 119
[Credential-related source omitted] - Access to secretsline 143
[Credential-related source omitted]
profiles/vastai.md
- Network accessline 34
**Entry points** (all equivalent): web console (`cloud.vast.ai`), the `vastai` CLI / Python SDK, the REST API (`https://console.vast.ai/api/v1/...`, Bearer token), and SSH into the running container. The CLI is the - Network accessline 35
API (`https://console.vast.ai/api/v1/...`, Bearer token), and SSH into the running container. The CLI is the - Access to secretsline 36
[Credential-related source omitted] - Network accessline 131
**China relevance: none at the platform level.** No China datacenters, no `/etc/network_turbo` equivalent, no built-in HF mirror. The HF-unreachable problem still exists at the *workload* level from some hosts, but the fix is the job's **ow - Network accessline 132
built-in HF mirror. The HF-unreachable problem still exists at the *workload* level from some hosts, but the fix is the job's **own** `HF_ENDPOINT=https://hf-mirror.com` / `hf_transfer`, not a platform script — see `references/run-remote/go - Network accessline 133
fix is the job's **own** `HF_ENDPOINT=https://hf-mirror.com` / `hf_transfer`, not a platform script — see - Access to secretsline 277
[Credential-related source omitted] - Network accessline 329
DURABLE_DIR=off-box # no destroy-surviving mount: vastai copy / vastai cloud copy before destroy (§5) # PROXY_HOOK — none at platform level (no /etc/network_turbo). HF mirror is the JOB's own env if needed: PROXY_HOOK='' - Network accessline 330
# PROXY_HOOK — none at platform level (no /etc/network_turbo). HF mirror is the JOB's own env if needed: PROXY_HOOK='' # set HF_ENDPOINT=https://hf-mirror.com in the job env only if a host can't reach HF # CRED_FILE — emp - Network accessline 331
PROXY_HOOK='' # set HF_ENDPOINT=https://hf-mirror.com in the job env only if a host can't reach HF - Access to secretsline 332
[Credential-related source omitted] - Access to secretsline 333
[Credential-related source omitted] - Access to secretsline 342
[Credential-related source omitted]
references/run-local/env-hygiene.md
- Access to secretsline 82
[Credential-related source omitted]
references/run-remote/china-network.md
- Network accessline 15
| Channel | Set | Endpoint(s) | |---|---|---| | **PyPI** | `pip config set global.index-url <url>` or `pip install -i <url> pkg` | Tsinghua TUNA `https://pypi.tuna.tsinghua.edu.cn/simple` · Aliyun `https://mirrors.aliyun.com/pypi/simple` · - Network accessline 16
|---|---|---| | **PyPI** | `pip config set global.index-url <url>` or `pip install -i <url> pkg` | Tsinghua TUNA `https://pypi.tuna.tsinghua.edu.cn/simple` · Aliyun `https://mirrors.aliyun.com/pypi/simple` · USTC `https://pypi.mirrors.ustc. - Network accessline 17
| **PyPI** | `pip config set global.index-url <url>` or `pip install -i <url> pkg` | Tsinghua TUNA `https://pypi.tuna.tsinghua.edu.cn/simple` · Aliyun `https://mirrors.aliyun.com/pypi/simple` · USTC `https://pypi.mirrors.ustc.edu.cn/simple` - Network accessline 18
| **conda** | channels in `~/.condarc` (TUNA Anaconda) | `https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main` + `.../free` + the `cloud/` channels (pytorch, conda-forge) | | **HuggingFace** | `export HF_ENDPOINT=https://hf-mirror.com` - Network accessline 19
| **HuggingFace** | `export HF_ENDPOINT=https://hf-mirror.com` | drop-in reverse proxy — identical repo IDs, identical `hf download` / `from_pretrained` calls | - Network accessline 32
Source: HF-Mirror `https://hf-mirror.com/`; TUNA PyPI `https://mirrors.tuna.tsinghua.edu.cn/help/pypi/`; - Network accessline 33
TUNA Anaconda `https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/`; ModelScope client - Network accessline 34
`https://github.com/modelscope/modelscope_hub`. - Network accessline 42
# --- mirror routing --- export HF_ENDPOINT=https://hf-mirror.com # MUST precede any HF import (see trap below) - Network accessline 43
export HF_ENDPOINT=https://hf-mirror.com # MUST precede any HF import (see trap below) - Network accessline 58
# Inline on the command — the env is set before the interpreter starts: HF_ENDPOINT=https://hf-mirror.com python train.py - Network accessline 59
HF_ENDPOINT=https://hf-mirror.com python train.py - Network accessline 61
export HF_ENDPOINT=https://hf-mirror.com # then later: python -m src.train ... - Network accessline 70
Source: HF-Mirror `https://hf-mirror.com/`; ModelScope client - Network accessline 71
`https://github.com/modelscope/modelscope_hub`. - Network accessline 123
Source: hf CLI resume `https://github.com/huggingface/huggingface_hub/issues/3580`; hf_transfer hang `https://github.com/huggingface/hf_transfer/issues/30`; ModelScope download - Network accessline 124
`https://github.com/huggingface/hf_transfer/issues/30`; ModelScope download - Network accessline 125
`https://deepwiki.com/modelscope/modelscope/3.1-model-download-and-caching`. - Network accessline 162
Source: requests `no_proxy` `https://github.com/psf/requests/issues/4871`; no_proxy guide - Network accessline 163
`https://www.browserstack.com/guide/no_proxy-environment-variable`; Clash pip ProxyError - Network accessline 164
`https://github.com/clash-verge-rev/clash-verge-rev/issues/2607`. - Network accessline 170
1. **hf-mirror first** — `HF_ENDPOINT=https://hf-mirror.com`. Drop-in, same repo IDs, no proxy, no - Network accessline 189
Source: HF-Mirror `https://hf-mirror.com/`; ModelScope `https://github.com/modelscope/modelscope_hub`.
references/run-remote/gotchas_universal.md
- Access to secretsline 116
[Credential-related source omitted] - Access to secretsline 120
[Credential-related source omitted] - Network accessline 398
(`profiles/generic-ssh.md`, `profiles/lambda.md`). Before blaming the panel, verify ground truth: the event file is non-empty (`ls -la <logdir>; du -sh <logdir>`) and TB answers locally (`curl -s localhost:<port>/ | head`). For curves that - Network accessline 399
panel, verify ground truth: the event file is non-empty (`ls -la <logdir>; du -sh <logdir>`) and TB answers locally (`curl -s localhost:<port>/ | head`). For curves that must **survive teardown**, don't depend on a box-local panel at all → - Network accessline 400
answers locally (`curl -s localhost:<port>/ | head`). For curves that must **survive teardown**, don't - Access to secretsline 656
[Credential-related source omitted]
references/run-remote/lifecycle_checklist.md
- Access to secretsline 13
[Credential-related source omitted] - Access to secretsline 14
[Credential-related source omitted] - Dangerous shell operationline 75
- [ ] **The node runs itself before anything local can wait on a human.** Start the on-node chain first — probe → gate → dead-man (`scripts/run_one.sh.template`) → run → power-off — and only then take local steps that can stop on a question
references/run-remote/multinode.md
- Network accessline 35
URL: https://support.crusoecloud.com/hc/en-us/articles/46061806112155-NCCL-Hangs-and-Multi-Node-Training-Stalls-Caused-by-Failed-nvidia-fabricmanager - Network accessline 56
URL: https://github.com/NVIDIA/nccl/issues/1580 - Network accessline 78
URL: https://repost.aws/questions/QURXddiuikQLesRDGz39RhIw/nccl-socket-timeout-when-using-large-dataset-in-multi-node-pretraining - Network accessline 100
URL: https://github.com/moby/moby/issues/4378 - Network accessline 124
URL: https://docs.pytorch.org/tutorials/beginner/ddp_series_fault_tolerance.html - Network accessline 146
URL: https://horovod.readthedocs.io/en/stable/elastic_include.html
references/run-remote/spot-resilience.md
- Network accessline 16
| Platform | Detection signal | Grace window | Implication | |---|---|---|---| | **AWS EC2 Spot** | IMDS `http://169.254.169.254/latest/meta-data/spot/instance-action` (404 = none, 200 = pending); rebalance-recommendation fires ~10–20 min e - Network accessline 17
|---|---|---|---| | **AWS EC2 Spot** | IMDS `http://169.254.169.254/latest/meta-data/spot/instance-action` (404 = none, 200 = pending); rebalance-recommendation fires ~10–20 min earlier | **~120 s** | On-signal flush of a *small* checkpoint - Network accessline 18
| **AWS EC2 Spot** | IMDS `http://169.254.169.254/latest/meta-data/spot/instance-action` (404 = none, 200 = pending); rebalance-recommendation fires ~10–20 min earlier | **~120 s** | On-signal flush of a *small* checkpoint is viable; still - Network accessline 26
URLs: AWS [spot-instance-termination-notices](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-instance-termination-notices.html), - Network accessline 27
[rebalance-recommendations](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/rebalance-recommendations.html); - Network accessline 28
GCP [preemptible](https://docs.cloud.google.com/compute/docs/instances/preemptible), - Network accessline 29
[spot](https://docs.cloud.google.com/compute/docs/instances/spot); - Network accessline 30
Azure [scheduled-events](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/scheduled-events); - Network accessline 31
Slurm [sbatch `--signal`](https://slurm.schedmd.com/sbatch.html); - Network accessline 32
RunPod [spot-vs-on-demand](https://www.runpod.io/blog/spot-vs-on-demand-instances-runpod); - Network accessline 33
vast.ai [Rental-Types](https://vast.ai/article/Rental-Types). - Network accessline 79
URLs: Young/Daly [robustness paper, INRIA](https://people.bordeaux.inria.fr/gaupy/ressources/pub/confs/icpp20_robustness.pdf), - Network accessline 80
[Optimal Checkpointing Period, LAWN 281](https://www.netlib.org/lapack/lawnspdf/lawn281.pdf), - Network accessline 81
[Optimal Checkpointing for Iterative Applications, IEEE](https://ieeexplore.ieee.org/document/9495174/). - Network accessline 117
URLs: [Check-N-Run, arXiv](https://arxiv.org/pdf/2010.08679), - Network accessline 118
[SkyPilot training-guide](https://docs.skypilot.co/en/latest/reference/training-guide.html), - Network accessline 119
[SageMaker resume-from-checkpoint](https://docs.aws.amazon.com/sagemaker/latest/dg/model-checkpoints-resume.html). - Network accessline 128
region/cloud to chase capacity, then re-runs the task). Caveat: it auto-recovers **only** preemption/hardware failures — a user-code non-zero exit is **not** auto-recovered. [managed-jobs](https://docs.skypilot.co/en/latest/examples/man - Network accessline 129
preemption/hardware failures — a user-code non-zero exit is **not** auto-recovered. [managed-jobs](https://docs.skypilot.co/en/latest/examples/managed-jobs.html). - **AWS SageMaker Managed Spot** — set `use_spot_instances=True` + `checkpo - Network accessline 130
[managed-jobs](https://docs.skypilot.co/en/latest/examples/managed-jobs.html). - Network accessline 133
**`max_wait` must be greater than `max_run`** — `max_wait` covers wait-for-capacity *plus* run time *plus* interruption gaps; set it too tight and the job is killed mid-resume. [managed-spot docs](https://docs.aws.amazon.com/sagemaker/l - Network accessline 135
[managed-spot docs](https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html). - Access to secretsline 154
[Credential-related source omitted]
references/run-remote/ssh_transport.md
- Access to secretsline 10
[Credential-related source omitted] - Access to secretsline 14
[Credential-related source omitted] - Access to secretsline 20
[Credential-related source omitted] - Access to secretsline 37
[Credential-related source omitted] - Access to secretsline 40
[Credential-related source omitted] - Access to secretsline 41
[Credential-related source omitted] - Access to secretsline 42
[Credential-related source omitted] - Access to secretsline 48
[Credential-related source omitted] - Access to secretsline 58
[Credential-related source omitted] - Access to secretsline 68
[Credential-related source omitted] - Access to secretsline 178
[Credential-related source omitted] - Access to secretsline 179
[Credential-related source omitted] - Access to secretsline 190
[Credential-related source omitted] - Access to secretsline 196
[Credential-related source omitted]
references/training/by-domain.md
- Network accessline 20
**Symptom**: a fine-tuned causal LM produces garbage, or DPO/batched-generation logprobs disagree with single-example decoding. **Root cause**: causal-LM **training** wants **right-padding** (pad lands after content, attention mask zeroes i - Network accessline 22
**Fix**: `tokenizer.padding_side="right"` for SFT collation; `"left"` for generation/eval/DPO — set it per phase, not globally. ([HF causal-LM](https://huggingface.co/docs/transformers/tasks/language_modeling), [TRL DPO](https://huggingface - Network accessline 25
**Symptom**: SFT "trains" but parrots the prompt / barely follows instructions; loss plausible but flat. **Root cause**: HF LM loss is `CrossEntropyLoss(ignore_index=-100)` — only `-100` positions are skipped. Leaving the prompt-prefix labe - Network accessline 27
**Fix**: set labels to `-100` at **both** the prompt prefix (train only on the completion) and all padding positions. TRL `SFTTrainer` `completion_only_loss` / `DataCollatorForCompletionOnlyLM` does the prefix masking — verify it fired (dec - Network accessline 35
**Symptom**: throughput jumps after enabling packing, but quality drops vs unpacked; the model "completes" one doc with content from a packed neighbor. **Root cause**: naive packing concatenates examples into one `max_len` sequence; a vanil - Network accessline 37
**Fix**: **document masking** — emit `position_ids` that reset per sub-sequence + an attention impl that honors boundaries. TRL/HF `DataCollatorWithFlattening` packs into one stream, returns `position_ids`, and sets each example's first lab - Network accessline 40
**Symptom**: a 4k-context model is incoherent past ~4k at inference even when trained on longer sequences; or long-context finetune won't converge. **Root cause**: RoPE frequencies are calibrated to the pretrain context; longer positions ex - Network accessline 42
**Fix**: set `rope_scaling={"type":"linear"|"dynamic"|"yarn","factor":<target/orig>}` in config and finetune **with scaling active** (`"yarn"` for big jumps, `"linear"` only ≤4×). Train-time vs inference-time `rope_scaling` mismatch is a si - Network accessline 45
**Symptom**: pretraining/long-SFT loss is stable then spikes; in bf16/fp16 it can NaN; logits grow unboundedly over training. **Root cause**: the softmax normalizer `log Z` drifts from 0 as logits grow → low-precision overflow + gradient in - Network accessline 47
**Fix**: add **z-loss** `1e-4 · log²(Z)` (the PaLM / ST-MoE coefficient) to pull `log Z` toward 0. The general divergence ladder (warmup, grad-clip, skip-the-batch, qk-norm, bf16-over-fp16) is **references/training/precision-stability.md** - Network accessline 50
**Symptom**: reported PPL implausible, or differs from a published number on the same checkpoint+data. **Root cause**: PPL = `exp(mean NLL over scored tokens)`. Including pad/prompt tokens, or a sliding window that double-counts overlap con - Network accessline 52
**Fix**: score only non-`-100` positions; for long docs use the HF strided window where overlap tokens are `-100` (context, not scored). Whether the number is comparable across runs is metric validity, not mechanics. ([HF perplexity](https: - Network accessline 55
**Symptom**: TRL trainer runs but learns nothing, or errors on a missing column; preference data in an SFT trainer (or vice versa) silently mistrains. **Root cause**: **SFT** = prompt+completion (train on completion); **DPO/preference** = ` - Network accessline 57
**Fix**: match trainer to schema; for conversational data confirm the chat template fired (decode one example — look for role tags). Prefer the **explicit-prompt** form `{prompt, chosen, rejected}` over implicit. Recommended order SFT → DPO - Network accessline 60
**Symptom**: `rewards/margins` ~0 or `rewards/accuracies` ~0.5; or `logps/chosen` and `logps/rejected` both plunge (suppresses everything). **Root cause**: `beta` controls deviation from the frozen reference — too **small** → policy drifts - Network accessline 62
**Fix**: start `beta=0.1`, raise to 0.3–0.5 if text degrades, lower if the margin won't move. Use `learning_rate≈1e-6` (TRL DPO default; `≈1e-5` for LoRA) — too high is the classic collapse. Health signal: `rewards/margins` ↑, `rewards/accu - Network accessline 65
**Symptom**: `401`/`GatedRepoError` when the Trainer loads a Llama/Gemma/Mistral base despite granted access; or `push_to_hub` can't write. **Root cause**: the token must be visible to the process **before** the gated `from_pretrained` / Tr - Network accessline 67
[Credential-related source omitted] - Access to secretsline 67
[Credential-related source omitted] - Network accessline 72
**Symptom**: training loss falls but val/test is near-chance; or a fine-tuned backbone is far worse than its pretrained eval. **Root cause**: pretrain `(mean,std)` (ImageNet `mean=[.485,.456,.406] std=[.229,.224,.225]`) differs between trai - Network accessline 74
**Fix**: use the **exact** pretrain normalization, identically in train and eval; match channel order. Print one input tensor's per-channel mean/std — should be ~`N(0,1)`; a gap that survives this fix is a real effect, not the bug. ([why-no - Network accessline 82
**Symptom**: detection loss decreases normally but mAP is exactly 0 (or ~0) at every eval. **Root cause**: a format mismatch the loss tolerates but eval doesn't — (1) box format `cxcywh`/`xywh` vs evaluator's `xyxy`, or normalized `[0,1]` v - Network accessline 84
**Fix**: assert the eval pipeline's box format + class indexing, convert explicitly (`torchvision.ops.box_convert`), and visualize 2–3 predicted boxes before trusting the metric. mAP=0 with healthy loss is almost never the model — it's eval - Network accessline 92
**Symptom**: seg loss trains but mIoU is 0 (or a class NaN); or loss is NaN from step 1. **Root cause**: label/class-index inconsistency — a void value (commonly `255`) not excluded → treated as a class id ≥ `num_classes` (out-of-range / po - Network accessline 94
**Fix**: set the **same** `ignore_index` in **both** loss and metric — `CrossEntropyLoss(ignore_index=255)` and mIoU mask `(label != 255)`; confirm `label.max() < num_classes` after any shift; apply reduction identically. mIoU=0 with fallin - Network accessline 109
**Symptom**: the noise-prediction MSE converges nicely but samples are blurry, mode-collapsed, or wrong. **Root cause**: diffusion loss (predict noise at a random timestep) is **weakly correlated with sample quality** — good average noise-p - Network accessline 111
**Fix**: the textbook **is-the-number-real** fork → cross-link **references/verifying/methodology.md** (**REQUIRED**; it owns loss-low-output-bad). Mechanically walk DF2→DF6; the single most common miss is evaluating **raw** weights instead - Network accessline 114
**Symptom**: samples from the just-saved checkpoint look worse than expected; quality jumps with an EMA checkpoint. **Root cause**: diffusion quality depends heavily on EMA — a running average (`decay≈0.999`, ~1000-update window) that denoi - Network accessline 116
**Fix**: maintain EMA during training and **sample/evaluate from EMA weights** (`diffusers` `EMAModel`); verify the eval path actually loaded EMA. Checkpointing the EMA shadow weights (and what breaks when they are lost) → `references/train - Network accessline 119
**Symptom**: latent-diffusion (SD-style) training is unstable / produces noise or blank output; or a swapped-in custom VAE degrades everything. **Root cause**: the model assumes ~unit-variance latents; the VAE output is multiplied by a cali - Network accessline 121
**Fix**: scale by the VAE's `config.scaling_factor` on encode, divide on decode. For a **custom** VAE, **measure** empirical latent std on a sample and set factor `1/std` — don't inherit `0.18215`. Print latent mean/std before training (~0/ - Network accessline 129
**Symptom**: changing `guidance_scale` at inference barely changes output, or the model ignores conditioning. **Root cause**: CFG needs a learned **unconditional** path, trained by randomly replacing the condition with a null embedding for - Network accessline 131
**Fix**: during training drop the condition `p_drop≈0.1` (replace with null embedding). At inference use `guidance_scale` ~5–15 for T2I (higher = more prompt adherence, lower diversity). Model-ignores-input is DF1's fork; the training-side - Network accessline 139
**Symptom**: samples are systematically blurry / low-detail despite long training. **Root cause**: uniform loss weight over-weights high-noise (easy) steps relative to low-noise steps that carry fine detail; the gradient is dominated by the - Network accessline 141
**Fix**: apply **Min-SNR-γ** weighting (γ≈5) so low-noise steps get their share; `diffusers` scripts expose `--snr_gamma`. Compounds with DF2/DF3 — fix these details together, not in isolation. ([Min-SNR](https://arxiv.org/abs/2303.09556)) - Network accessline 144
**Symptom**: training or fine-tuning an SD3 / Flux-class **flow-matching** model; the loss is low and stable but samples are noisy/structureless — and noticeably worse away from the training resolution. **Root cause**: flow matching predict - Network accessline 146
**Fix**: keep training and sampling on the **identical** schedule — same flow-matching scheduler, same `shift`/`use_dynamic_shifting`, and set `mu` from the actual image sequence length at inference. A mismatched scheduler/`prediction_type` - Network accessline 151
**Symptom**: average reward suddenly drops, responses get short/repetitive or refuse, length collapses. **Root cause**: reward hacking / over-optimization — the policy exploits the reward model's blind spots and drifts far, often after the - Network accessline 153
**Fix**: strengthen the KL penalty (raise the KL coefficient), lower LR (`≈1e-6` for LLM PPO), reduce PPO update epochs/batch, add a length penalty if length is gamed. Watch reward **and** KL together — a reward jump with a KL spike is hack - Network accessline 156
**Symptom**: KL grows without bound; generations go incoherent; "diverges" though loss isn't NaN. **Root cause**: the KL penalty is too weak (or adaptive-KL target too loose); aggressive updates push the policy far, and a huge KL term can d - Network accessline 158
**Fix**: use an **adaptive KL controller** with a target (e.g. 6), or a fixed coefficient large enough to hold KL bounded; clip the ratio (`cliprange≈0.2`); cap update epochs. Confirm the frozen reference isn't being updated. Same axis DPO' - Network accessline 161
**Symptom**: high-variance, brittle training; small reward-scale changes destabilize everything. **Root cause**: raw reward/advantage magnitudes vary wildly across batches; PPO gradients are scale-sensitive. **Fix**: **whiten** advantages p - Network accessline 163
**Fix**: **whiten** advantages per minibatch (subtract mean, divide by std) — the standard PPO trick, more stabilizing than plain reward normalization (double-normalizing reward **and** advantage is often redundant). For classic-control RL, - Network accessline 176
**Symptom**: identical hyperparameters + different seeds give non-overlapping curves; an ablation "win" disappears on re-run. **Root cause**: extreme seed variance from algorithm, policy sampling, and environment stochasticity (comparing 5- - Network accessline 178
**Fix**: report aggregate over **≥5 seeds** (more for noisy envs), use **IQM** (interquartile mean) over mean/median, show CIs. A single-seed delta is not a result — squarely **references/verifying/methodology.md** territory (bug-vs-real-ef - Network accessline 183
**Symptom**: a LLaVA-style VLM doesn't ground on images (ignores visual tokens), or text quality collapses after multimodal finetune. **Root cause**: VLM training is **staged**, each stage freezing different towers. Stage 1 (alignment): fre - Network accessline 185
**Fix**: set `requires_grad` per tower per stage per the recipe; print trainable-param counts at each stage start to confirm the freeze took. "Ignores its input image" is model-ignores-input → X5. ([LLaVA recipe](https://rohitbandaru.github - Network accessline 188
**Symptom**: stage-1 alignment loss is unstable or the projector output is garbage. **Root cause**: the projector (linear or 2-layer MLP, often concatenating groups of vision tokens into the LLM embedding space) is **randomly initialized**; - Network accessline 190
**Fix**: stage 1 trains the projector **alone** against a frozen LLM so it learns the LLM's embedding space first; only then (stage 2) unfreeze the LLM. Confirm projector output dim == LLM hidden size (else a silent shape-broadcast bug). ([ - Network accessline 193
**Symptom**: a shared LR either over-updates the pretrained vision encoder (forgets visual features) or leaves projector/LLM undertrained. **Root cause**: towers are at different maturities — a pretrained vision encoder needs a tiny LR (or - Network accessline 195
**Fix**: **parameter groups** with per-group LRs (`AdamW([{"params":proj.parameters(),"lr":1e-3},{"params":llm.parameters(),"lr":2e-5}])`), or freeze the vision encoder. Log each group's LR to confirm. ([LLaVA LRs](https://rohitbandaru.gith - Network accessline 198
**Symptom**: VLM training errors on image-token-count mismatch, or intermittently ignores images on long examples. **Root cause**: image placeholders expand into many tokens (hundreds per image); a `max_length` truncation cuts them, breakin - Network accessline 200
**Fix**: set `max_length=None` (or large enough never to truncate image tokens) for VLM trainers, or verify truncation never removes placeholders across the whole dataset. Count image tokens vs expected per example as a smoke check. ([TRL V
references/training/checkpoint-resume.md
- Network accessline 28
**Fix**: every checkpoint must carry the full state (PyTorch tutorial [saving multiple / general checkpoint](https://docs.pytorch.org/tutorials/recipes/recipes/saving_and_loading_a_general_checkpoint.html); - Network accessline 29
[saving multiple / general checkpoint](https://docs.pytorch.org/tutorials/recipes/recipes/saving_and_loading_a_general_checkpoint.html); - Network accessline 109
offloading each to CPU on rank 0, so peak GPU memory stays bounded and non-rank-0 workers skip the GPU→CPU copy entirely ([HF Accelerate FSDP guide](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp), - Network accessline 110
copy entirely ([HF Accelerate FSDP guide](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp), [Lightning issue #11207](https://github.com/Lightning-AI/pytorch-lightning/issues/11207)). The full dict - Network accessline 111
([HF Accelerate FSDP guide](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp), - Network accessline 112
[Lightning issue #11207](https://github.com/Lightning-AI/pytorch-lightning/issues/11207)). The full dict - Network accessline 138
**Fix**: use `torch.distributed.checkpoint` (DCP), the current PyTorch-2.x sharded-checkpoint API ([DCP recipe](https://docs.pytorch.org/tutorials/recipes/distributed_checkpoint_recipe.html), - Network accessline 139
([DCP recipe](https://docs.pytorch.org/tutorials/recipes/distributed_checkpoint_recipe.html), - Network accessline 140
[2.12 reference](https://docs.pytorch.org/docs/2.12/distributed.checkpoint.html)). **Save**: get canonical - Network accessline 156
**Fix** ([DeepSpeed model-checkpointing](https://deepspeed.readthedocs.io/en/stable/model-checkpointing.html), - Network accessline 157
[ZeRO tutorial](https://www.deepspeed.ai/tutorials/zero/)): - Network accessline 182
**Fix** ([Trainer docs](https://huggingface.co/docs/transformers/main/en/main_classes/trainer)): - Network accessline 200
**Fix** ([Accelerate checkpoint guide](https://huggingface.co/docs/accelerate/en/usage_guides/checkpoint)): - Network accessline 216
`.ckpt` is a full dump — epoch, global step, LightningModule `state_dict`, **all** optimizer + LR-scheduler states, callback states, loop state, and the 16-bit scaling factor (AMP) ([Lightning checkpointing basics](https://lightning.ai/docs - Network accessline 218
([Lightning checkpointing basics](https://lightning.ai/docs/pytorch/stable/common/checkpointing_basic.html)). - Network accessline 282
**Root cause**: the `GradScaler` holds dynamic state — `scale`, `growth_factor`, `backoff_factor`, `growth_interval`, `_growth_tracker` — that evolves during training; dropping it resets the scaler ([PyTorch AMP recipe](https://docs.pytorch - Network accessline 283
`growth_interval`, `_growth_tracker` — that evolves during training; dropping it resets the scaler ([PyTorch AMP recipe](https://docs.pytorch.org/tutorials/recipes/recipes/amp_recipe.html), [forum: No inf checks were recorded](https://discu - Network accessline 284
([PyTorch AMP recipe](https://docs.pytorch.org/tutorials/recipes/recipes/amp_recipe.html), - Network accessline 285
[forum: No inf checks were recorded](https://discuss.pytorch.org/t/resume-training-with-mixed-precision-lead-to-no-inf-checks-were-recorded-for-this-optimizer/115828)). - Dangerous shell operationline 294
**Symptom**: pre-resume eval (using EMA weights) is good; post-resume eval drops sharply, then recovers
references/training/convergence-debugging.md
- Dangerous shell operationline 10
- **It isn't learning at all (start here)** — O1 overfit-one-batch · O2 params-not-in-optimizer · O3 loss-detached-from-graph · O4 zero_grad/backward/step-order · O5 train()/eval()-mode - Network accessline 20
**Symptom**: training "runs" (no error, normal throughput) but loss plateaus near its init value or wanders without trending down, across LRs/optimizers/architectures. You're tuning hyperparameters blind because nothing proves the loop can - Network accessline 22
**Fix**: take ONE fixed mini-batch (2 examples is enough) and loop forward/backward/step on **that same batch** for hundreds of iters — a correct loop drives train loss → ~0. Turn **off** augmentation, shuffling, dropout, and weight decay f - Network accessline 25
**Symptom**: overfit-one-batch fails; a snapshotted param is unchanged before/after `optimizer.step()`; grad-norm may even be nonzero. No error. **Root cause**: the optimizer updates a **different** set of tensors than the model forwards th - Network accessline 27
**Fix**: build the optimizer **after** `model.to(device)`. Assert it sees every trainable param: `opt_ids={id(p) for g in optimizer.param_groups for p in g['params']}; assert all(id(p) in opt_ids for p in model.parameters() if p.requires_gr - Network accessline 30
**Symptom**: overfit fails with every `p.grad is None`; or `loss.backward()` raises *"element 0 of tensors does not require grad and does not have a grad_fn"*. **Root cause**: the loss tensor was severed from autograd before `backward`. Com - Network accessline 32
**Fix**: before `backward`, `assert loss.requires_grad and loss.grad_fn is not None`. Keep the differentiable loss tensor distinct from logging scalars (log `loss.item()`, back-prop the raw tensor). Reserve `no_grad`/`inference_mode` for ev - Network accessline 35
**Symptom**: overfit fails; weights never move, or training is erratic despite nonzero grads. **Root cause**: PyTorch's contract is *"gradients by default add up; to prevent double-counting we explicitly zero them each iteration"*, `backwar - Network accessline 37
**Fix**: the canonical order, exactly — `optimizer.zero_grad(set_to_none=True)` → forward → `loss=loss_fn(out,y)` → `loss.backward()` → `optimizer.step()` (under AMP: `scaler.scale(loss).backward()` → `scaler.step(optimizer)` → `scaler.upda - Dangerous shell operationline 40
**Symptom**: two faces — (1) trained under `eval()`: BN uses frozen running stats and never updates them, Dropout is off → underfits / loss barely moves; (2) evaluated under `train()`: BN uses noisy per-batch stats and Dropout fires → val l - Network accessline 40
**Symptom**: two faces — (1) trained under `eval()`: BN uses frozen running stats and never updates them, Dropout is off → underfits / loss barely moves; (2) evaluated under `train()`: BN uses noisy per-batch stats and Dropout fires → val l - Dangerous shell operationline 41
**Root cause**: `train()`/`eval()` set a per-module flag that *"has an effect only on certain modules ... e.g. Dropout, BatchNorm"* (`eval()` == `train(False)`). In eval mode BN switches to stored `running_mean/var` and **stops** updating t - Network accessline 42
**Fix**: bracket phases explicitly — `model.train()` atop each train epoch; `model.eval()` + `with torch.no_grad():` for every val/test pass; `model.train()` again before resuming. After build/load, `assert model.training` before the train - Network accessline 47
**Symptom**: `weight_decay` on `torch.optim.Adam` barely regularizes (or hurts) vs the literature's AdamW recipe; or a from-scratch transformer/CNN trains worse than a reference at the "same" wd; or small models destabilize when LayerNorm/B - Network accessline 49
**Fix**: use `torch.optim.AdamW`, not `Adam(weight_decay=...)`. Split into two param groups with `weight_decay=0.0` on the no-decay group — nanoGPT's rule: decay `p.dim()>=2` (matmul/embedding weights), no-decay `p.dim()<2` (all biases + al - Network accessline 52
**Symptom**: no divergence, no NaN, grads finite — loss just falls glacially or plateaus high; throughput is fine but the model "won't learn." Often after copying an LR from a different-batch/optimizer recipe or defaulting to a tiny "safe" - Network accessline 54
**Fix**: run an **LR range test** (Smith) — from a tiny LR, multiply it geometrically each batch over ~100–1000 steps, plot loss vs LR, pick ~1 decade below where loss starts to diverge. Tools: `pytorch-lr-finder` `LRFinder(model,opt,crit). - Network accessline 57
**Symptom**: PyTorch warns *"Detected call of `lr_scheduler.step()` before `optimizer.step()`"* and the LR curve is off-by-one; OR a cosine/warmup schedule sized in optimizer steps barely moves (stepped per-epoch) or decays to ~0 in one epo - Network accessline 59
**Fix**: order it `optimizer.step(); scheduler.step()`. Step at the granularity its `total_steps` was computed in — per optimizer step for warmup/cosine/OneCycle (inside the `if (i+1)%accum==0` block, **not** every micro-batch), per epoch o - Network accessline 62
**Symptom**: switching from batch `B` to (micro-batch `B/N` × N accumulation) "at the same config" trains hotter/diverges — loss/grad magnitude ~N× too big, i.e. you silently get N× the LR. For token tasks the accumulated loss also differs - Network accessline 64
**Fix**: divide before backward — `loss = loss_fn(out,y) / accum_steps; loss.backward()`, with `step()`/`zero_grad()` only on the boundary. For token-level losses, normalize by the **total** non-pad tokens across the accumulation window (ac - Network accessline 67
**Symptom**: a run stable in fp32 develops update spikes/NaNs once optimizer math is half precision; or AdamW behaves as if `eps=0` (huge updates where the second moment `v` is small). Most visible with fp16 optimizer states or foreach/8-bi - Network accessline 69
**Fix**: raise eps for half-precision optimizer math — `eps=1e-7` (proposed in pytorch#26218 for fp16) up to `1e-6` for bf16; or keep optimizer states / master weights in **fp32** (FSDP `MixedPrecision`, DeepSpeed bf16 keep an fp32 master) - Network accessline 72
**Symptom**: `AdamW(fused=True)` raises (e.g. on `_foreach_sub_` of `device_found_inf`) or mis-steps under GradScaler / bf16-mixed / FSDP; **or** the default `foreach` path OOMs at the optimizer step on a model that fit during forward/backw - Network accessline 74
**Fix**: on a fused error/suspicious step under AMP/FSDP/bf16-mixed, fall back to `fused=False` (lets `foreach` default) or upgrade past the fixed issue — confirm a parity loss-curve before trusting fused for a real datapoint. If the **step - Network accessline 79
**Symptom**: a model with a softmax (or log_softmax) final layer trains far slower than expected, plateaus high, or barely learns; loss is sluggish but not NaN. Classic when porting a Keras/TF model (expects probabilities) to PyTorch, or af - Network accessline 81
**Fix**: pass **raw logits** of shape `(N,C)` — remove any `nn.Softmax`/`F.log_softmax`/`nn.LogSoftmax` from the head. Apply softmax only at inference (for probabilities) or argmax (for the class). If you genuinely need log-probs in-graph, - Network accessline 84
**Symptom**: a binary / multi-label head shows NaN or inf loss (often once outputs saturate toward 0/1), or spiky loss; the model has an explicit `torch.sigmoid` before `nn.BCELoss`. Under imbalance it also collapses to always predicting th - Network accessline 86
**Fix**: feed **raw logits** to `nn.BCEWithLogitsLoss` — it fuses sigmoid+BCE with the log-sum-exp trick, avoiding `log(0)`. Remove the explicit sigmoid (apply only at inference). For imbalance pass `pos_weight = #neg/#pos` per class (`>1` - Network accessline 89
**Symptom**: any of — `RuntimeError: 0D or 1D target tensor expected, multi-target not supported` (one-hot target); `expected scalar type Long but found Float`; `IndexError: Target N is out of bounds` / CUDA `device-side assert ... t >= 0 & - Network accessline 91
**Fix**: hard labels → `targets.long()` of shape `(N,)`; remap ids to contiguous `0..C-1` (`{orig:i for i,orig in enumerate(sorted(set(labels)))}`; subtract 1 if 1-indexed); `assert targets.min()>=0 and targets.max()<C`. Don't one-hot the s - Network accessline 94
**Symptom**: a seq/NLP model's loss looks suspiciously small from step 0 and scales with how much padding is in the batch (more pad → lower loss); the model under-learns real tokens; changing batch size or max-length changes the loss magnit - Network accessline 96
**Fix**: skip padding. Easiest: `nn.CrossEntropyLoss(ignore_index=PAD_ID)` — *"the loss is averaged over non-ignored targets"* (sums valid positions, divides by valid count). Otherwise compute `reduction='none'`, multiply by a 0/1 mask, and - Network accessline 99
**Symptom**: a model uses `nn.NLLLoss` but has no `LogSoftmax`/`F.log_softmax` before it (or a plain `Softmax`): training "runs" with no error but loss is nonsensical / won't converge, accuracy stuck near chance. **Root cause**: `nn.NLLLoss - Network accessline 101
**Fix**: put `F.log_softmax(logits, dim=1)` (or an `nn.LogSoftmax(dim=1)` final layer) immediately before `nn.NLLLoss` (class dim = 1 for `(N,C)`). Simpler and less error-prone: drop NLLLoss+LogSoftmax and use `nn.CrossEntropyLoss` on raw l - Network accessline 106
**Symptom**: you set `requires_grad=False` on the backbone (or set it **after** building the optimizer over `model.parameters()`), yet the frozen weights keep moving every step; pretrained features drift and degrade though no real gradient - Network accessline 108
**Fix**: exclude frozen params from the optimizer at construction — `optim.SGD([p for p in model.parameters() if p.requires_grad], lr=...)` (or per-module param groups). If you froze after building the optimizer, rebuild it, or set `param.g - Dangerous shell operationline 111
**Symptom**: the backbone is "frozen" (`requires_grad=False`) yet val accuracy is unstable / worse than train, or `eval()` vs `train()`-mode inference disagree; small fine-tuning batches make it worse. The frozen features keep shifting batc - Network accessline 111
**Symptom**: the backbone is "frozen" (`requires_grad=False`) yet val accuracy is unstable / worse than train, or `eval()` vs `train()`-mode inference disagree; small fine-tuning batches make it worse. The frozen features keep shifting batc - Network accessline 113
**Fix**: put the frozen Norm layers in eval mode after `model.train()`: `for m in backbone.modules():\n if isinstance(m,(nn.BatchNorm1d,nn.BatchNorm2d,nn.BatchNorm3d)): m.eval()` — or build them `track_running_stats=False`. Re-apply ever - Network accessline 116
**Symptom**: fine-tuning with a single LR either (too high) destroys the pretrained representations on the first updates and accuracy collapses below a frozen-feature baseline, or (too low) the random new head can't move. Both are the same - Network accessline 118
**Fix**: discriminative fine-tuning — per-layer param groups with LR decaying toward the input (head highest, stem lowest), e.g. `AdamW([{'params':head,'lr':1e-3},{'params':backbone,'lr':1e-5}])`. Combine with **gradual unfreezing** (train - Network accessline 121
**Symptom**: you replaced the classifier for a new `num_classes` and pass `strict=False` expecting it to skip the head, but loading still crashes: `RuntimeError: ... size mismatch for fc.weight: copying a param with shape [1000,...] ..., th - Network accessline 123
**Fix**: drop the incompatible head entries before loading, then load non-strict — `sd={k:v for k,v in ckpt.items() if not k.startswith('fc.')}; missing,unexpected = model.load_state_dict(sd, strict=False)` — and inspect `missing/unexpected - Network accessline 126
**Symptom**: after `get_peft_model(...)`, `print_trainable_parameters()` shows ~0% (or far fewer than expected) and loss won't drop; or a PEFT classifier reloads with a **random** head / shifted metrics after `save_pretrained`. **Root cause - Network accessline 128
**Fix**: enumerate real names with `[n for n,_ in model.named_modules()]` and set `LoraConfig(target_modules=[...])` (or `'all-linear'`); confirm with `model.print_trainable_parameters()` and that you see `lora.Linear` layers. Add the new h - Network accessline 133
**Symptom**: loss barely moves (under-stepping) or is jittery (over-stepping), and the bare grad-norm can't tell you which — it isn't scale-relative to the weights. **Root cause**: what matters is the size of the **actual update** relative - Network accessline 135
**Fix**: log it every K steps — snapshot `w0={n:p.detach().clone() for n,p in model.named_parameters()}` before `step()`, then `(p.detach()-w0[n]).norm()/(w0[n].norm()+1e-12)` per name after. Lever: `≪1e-3` → raise that group's LR; `≫1e-3` - Network accessline 138
**Symptom**: you log `cfg.lr` (a constant) so the dashboard LR is flat — yet you're on warmup+cosine. You can't see warmup, decay, a restart, or a frozen scheduler; LR-related loss behavior (spike on ramp, stall at the floor) is invisible. - Network accessline 140
**Fix**: log `scheduler.get_last_lr()` (a list — one per param group; log them all if you use differential LRs) or read `optimizer.param_groups[0]['lr']` directly, every step. Don't use `get_lr()` for logging. If the logged LR plateaus when - Network accessline 148
**Symptom**: capacity quietly vanishes — a layer's outputs are increasingly all-zero, loss plateaus above where it should, and adding width doesn't help. No crash; it just under-fits. Worst case the net degenerates toward a constant functio - Network accessline 150
**Fix**: instrument the zero/saturation fraction per activation with a forward hook — `(out==0).float().mean()` for ReLU (or `|out|>0.99` for tanh/sigmoid), logged every K steps per layer. Healthy: a stable modest dead fraction (ReLU is spa - Network accessline 153
**Symptom**: scalar dashboards (loss, one grad-norm) look fine yet the model under-performs or destabilizes — a mean/norm hides the shape: activations drifting to a saturated tail, weights collapsing to a spike at 0 (a layer dying, O25), or - Network accessline 155
**Fix**: periodically (every few hundred steps — histograms aren't free) log `SummaryWriter.add_histogram(tag, values, global_step)` for each layer's **weights**, its **gradients** (after `backward`, before `zero_grad`), and key **activatio
references/training/data-pipeline.md
- Network accessline 17
**Symptom**: with `num_workers>0`, different workers emit the **same** random augmentation parameters (same crop coords, flips, noise) within a batch, and the exact same random sequence repeats **every epoch**. Augmentation diversity collap - Network accessline 19
**Fix**: pass a `worker_init_fn` that reseeds numpy from torch's already-per-worker seed: `def wif(_): np.random.seed(torch.initial_seed() % 2**32)`. `torch.initial_seed()` = `base_seed+worker_id` and `base_seed` is redrawn each epoch, givi - Network accessline 22
**Symptom**: an `IterableDataset` with `num_workers=N` yields each sample **N times** (an "epoch" is N× too long, samples repeat within a batch); and under DDP every **rank** streams the **same** data, so `all_reduce` averages identical gra - Network accessline 24
**Fix**: shard by **both** dimensions inside `__iter__`. Workers: `wi=torch.utils.data.get_worker_info()`, then keep records where `idx % wi.num_workers == wi.id` (or contiguous ranges). Ranks: fold in `dist.get_rank()`/`get_world_size()` — - Network accessline 27
**Symptom**: after correctly sharding an `IterableDataset` by rank, training intermittently **hangs at the last batch** of an epoch (NCCL collective timeout), or some ranks run one extra step. **Root cause**: streaming shards rarely divide - Network accessline 29
**Fix**: make every rank run the **same** number of steps — (a) compute a global min steps/epoch and stop all ranks there (drop the ragged tail), (b) pad short shards by cycling samples, or (c) wrap the loop in the DDP **Join** context mana - Network accessline 34
**Symptom**: iteration crashes at batch assembly — `RuntimeError: stack expects each tensor to be equal size, but got [..] at entry 0 and [..] at entry 1` — for variable-length sequences, variable bbox counts, or differently-sized images/ma - Network accessline 36
**Fix**: pass `DataLoader(..., collate_fn=my_collate)`. Sequences: `pad_sequence(seqs, batch_first=True, padding_value=pad_id)` + emit a length/attention mask (then mask the loss → O15, by-domain L2). Detection-style ragged targets: keep th - Network accessline 39
**Symptom**: after wrapping batches in a custom class (a `Batch` object, a graph batch, a dataclass) and setting `pin_memory=True`, the async H2D copy (`.to('cuda', non_blocking=True)`) no longer overlaps — throughput regresses to a blockin - Network accessline 41
**Fix**: implement `def pin_memory(self): self.x=self.x.pin_memory(); self.y=self.y.pin_memory(); return self` (return `self`) — the pin worker calls it per batch. Then keep `pin_memory=True` and transfer with `.to(device, non_blocking=True - Network accessline 44
**Symptom**: on Windows/macOS, `num_workers>0` raises `AttributeError: Can't pickle local object '<locals>.<lambda>'`; OR worse, it proceeds but transforms silently vanish (samples come back un-augmented). The identical code runs fine with - Network accessline 46
**Fix**: make everything the worker reconstructs a top-level importable callable — replace `collate_fn=lambda b: ...` and lambda transforms with module-level `def`s; bind args with `functools.partial(top_level_fn, ...)` not a closure; for p - Network accessline 49
**Symptom**: either (a) `IndexError`/`KeyError` from `__getitem__` partway through an epoch, or (b) no error but training quietly sees duplicated/skipped samples — when `__getitem__` does `self.items[idx % len(...)]` or indexes a shorter li - Network accessline 51
**Fix**: compute `__len__` and `__getitem__` from the **same** collection (materialize the kept-index list in `__init__`, index through it). Remove any `idx % N`/clamping — let an out-of-range index raise. Sanity once: `assert len(ds)==<exp - Network accessline 54
**Symptom**: training runs most of an epoch then dies at the **last** batch with `ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, C, ...])`. Happens when `len(dataset) % batch_size == 1`. **Ro - Dangerous shell operationline 56
**Fix**: `DataLoader(..., drop_last=True)` on the **train** loader discards the incomplete final batch (the standard fix). Alternatives if you can't drop data: swap BatchNorm → `nn.GroupNorm`/`nn.LayerNorm` (no batch-stat dependence), or fr - Network accessline 56
**Fix**: `DataLoader(..., drop_last=True)` on the **train** loader discards the incomplete final batch (the standard fix). Alternatives if you can't drop data: swap BatchNorm → `nn.GroupNorm`/`nn.LayerNorm` (no batch-stat dependence), or fr - Network accessline 59
**Symptom**: RAM climbs steadily across iters/epochs until a bare `Killed` (exit 137, no traceback) — typically from a Dataset that lazy-caches decoded samples (`if idx not in self.cache: self.cache[idx]=load(idx)`). With `num_workers>0` th - Network accessline 61
**Fix**: don't accumulate unbounded Python objects in `__getitem__`. Options: (a) precompute to a single `np.memmap` / Arrow / LMDB / `.npy` in `__init__` and read slices (the OS page cache **is** shared across forked workers); (b) bound th - Network accessline 66
**Symptom**: the model loads and runs without error, but a pretrained backbone scores far below its reported number, or your own val accuracy is a few points under train for no obvious reason; predictions are systematically biased (reds↔blu - Dangerous shell operationline 67
**Root cause**: the per-channel mean/std are correct numbers applied in the wrong space or order. (1) Stats must be computed on the **train split only** and reused verbatim at eval (the sklearn contract: `fit_transform` on train, `transform - Network accessline 68
**Fix**: compute stats once on train and reuse the same constants/transform at eval. For a torchvision pretrained model don't hand-roll it — use `weights.transforms()` (e.g. `ResNet50_Weights.IMAGENET1K_V2.transforms()`), which bundles resi - Network accessline 71
**Symptom**: a pipeline mixing `cv2` for I/O and a PIL/torchvision-trained (RGB) model: no exception, but color-sensitive predictions degrade; visualizing the array shows reds appearing blue. Often surfaces only when you switch the loader ( - Network accessline 73
**Fix**: convert immediately after a cv2 load — `img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)` (or `img = img[:, :, ::-1].copy()` — the `.copy()` matters, a negative-stride view breaks `torch.from_numpy`). Or switch I/O to `torchvision.io.rea - Network accessline 76
**Symptom**: loss is huge or NaN from step 0, or activations/gradients are enormous, when the input came from a float numpy array, a `.npy`, a 16-bit/HDR image (PIL mode `I`/`F`), or a tensor already in `[0,1]`. The same model works fine on - Network accessline 78
**Fix**: don't rely on `ToTensor` for non-uint8 scaling. For float inputs scale explicitly: `t = torch.from_numpy(arr).float() / 255.0` (or the correct max for 16-bit). In the v2 API prefer `transforms.v2.ToImage()` + `transforms.v2.ToDtype - Network accessline 81
**Symptom**: dataset construction or the first `__getitem__` raises `TypeError: tensor should be a torch tensor. Got <class 'PIL.Image.Image'>` (or `img should be Tensor`). **Root cause**: `transforms.Normalize` operates on a float tensor s - Network accessline 83
**Fix**: order the pipeline — PIL ops → `ToTensor()` → `Normalize(mean, std)`, e.g. `Compose([Resize(256), CenterCrop(224), ToTensor(), Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])])`. `mean`/`std` lengths must equal the channel count - Network accessline 86
**Symptom**: two shuffle failures — (a) `ValueError: sampler option is mutually exclusive with shuffle` the moment you add any sampler; (b) no error, but in DDP every epoch iterates the data in the **identical** order, so the train-loss cur - Network accessline 88
**Fix**: (a) when you must use a sampler (DistributedSampler, WeightedRandomSampler), set `shuffle=False` and let the sampler own ordering. (b) call `train_sampler.set_epoch(epoch)` at the **start of each epoch** before iterating (Lightning - Network accessline 91
**Symptom**: `DataLoader worker (pid N) is killed by signal: Bus error`, or `RuntimeError: unable to write to file </torch_...>` / `received 0 items of ancdata` — on a **rented container** while the identical code runs fine on your workstat - Network accessline 93
**Fix**: enlarge it at launch — `docker run --shm-size=8g` (or `--ipc=host`); where you can't set that (a fixed rental), switch the IPC strategy `torch.multiprocessing.set_sharing_strategy("file_system")` (fd-passing, slower but uncapped) a
references/training/distributed-launch.md
- Network accessline 27
**Fix**: launch through `torchrun`, which sets the full contract per process ([torchrun docs](https://docs.pytorch.org/docs/2.12/elastic/run.html)): - Network accessline 28
([torchrun docs](https://docs.pytorch.org/docs/2.12/elastic/run.html)): - Access to secretsline 39
[Credential-related source omitted] - Network accessline 52
**Fix** ([torchrun docs](https://docs.pytorch.org/docs/2.12/elastic/run.html)): - Access to secretsline 75
[Credential-related source omitted] - Network accessline 83
**Root cause**: both jobs default to `MASTER_PORT=29500`; the c10d TCP store can't bind a port the first job holds ([pytorch#85604](https://github.com/pytorch/pytorch/issues/85604)). - Network accessline 84
first job holds ([pytorch#85604](https://github.com/pytorch/pytorch/issues/85604)). - Network accessline 99
**Root cause**: Accelerate wraps the same env contract (D1) but sources it from `~/.cache/huggingface/accelerate/default_config.yaml` (written by `accelerate config`) or CLI flags ([launch docs](https://huggingface.co/docs/accelerate/en/bas - Network accessline 101
([launch docs](https://huggingface.co/docs/accelerate/en/basic_tutorials/launch)). - Network accessline 118
(`worker-1 slots=8`), distinct from torchrun's rendezvous. Under HF it's usually cleaner to let `accelerate launch` (with a DeepSpeed plugin/config) drive it ([HF DeepSpeed](https://huggingface.co/docs/accelerate/en/usage_guides/deepspeed)) - Network accessline 120
([HF DeepSpeed](https://huggingface.co/docs/accelerate/en/usage_guides/deepspeed)). - Network accessline 129
- **Model does NOT fit (params+optim+grads ≈ 18 B/param, see `references/training/oom-memory.md` M1)** → shard it: **FSDP** (PyTorch-native) or **DeepSpeed ZeRO** (richer offload). Sharding-to-fit ladder → `references/training/oom-memory.md - Network accessline 130
- **HF ecosystem / Trainer** → **Accelerate** as the launcher; flip a config field to choose DDP/FSDP/ZeRO. - **Need CPU/NVMe offload of params *and* optimizer separately, or ZeRO-Infinity** → **DeepSpeed** (FSDP**1** offload is all-or-noth - Network accessline 131
- **Need CPU/NVMe offload of params *and* optimizer separately, or ZeRO-Infinity** → **DeepSpeed** (FSDP**1** offload is all-or-nothing; FSDP2/`fully_shard` is finer-grained; [HF concept guide](https://github.com/huggingface/accelerate/blob - Network accessline 138
**Symptom**: `RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. ... parameters that were not used in producing loss` ([HF discuss](https://discuss.huggingface.co/t/runtimeerror-expected-to-h - Network accessline 140
([HF discuss](https://discuss.huggingface.co/t/runtimeerror-expected-to-have-finished-reduction-in-the-prior-iteration-before-starting-a-new-one-this-error-indicates-that-your-module-has-parameters-that-were-not-used-in-producing-loss/64760 - Network accessline 146
**Fix — in priority order**: 1. **Best**: make every output participate in the loss (often the real bug is a dropped/detached head). 2. If a branch is *legitimately* unused some steps, `DDP(model, find_unused_parameters=True)` — but it adds - Network accessline 147
1. **Best**: make every output participate in the loss (often the real bug is a dropped/detached head). 2. If a branch is *legitimately* unused some steps, `DDP(model, find_unused_parameters=True)` — but it adds a full graph traversal each - Network accessline 148
2. If a branch is *legitimately* unused some steps, `DDP(model, find_unused_parameters=True)` — but it adds a full graph traversal each step and **can be drastically slower** ([PyTorch forum](https://discuss.pytorch.org/t/process-got-stuck- - Network accessline 154
**Symptom**: training completes most of an epoch then **freezes on the final batch**; one rank had fewer samples and exited the loop while the others wait in allreduce forever ([PyTorch forum](https://discuss.pytorch.org/t/understanding-dis - Network accessline 156
([PyTorch forum](https://discuss.pytorch.org/t/understanding-distributedsampler-and-dataloader-drop-last/206271)). - Network accessline 166
`from torch.distributed.algorithms.join import Join; with Join([model]): for batch in loader: ...` — which mirrors the missing ranks' collectives so finished ranks don't deadlock ([Join tutorial](https://docs.pytorch.org/tutorials/advan - Network accessline 167
— which mirrors the missing ranks' collectives so finished ranks don't deadlock ([Join tutorial](https://docs.pytorch.org/tutorials/advanced/generic_join.html)). `model.join()` is the legacy spelling of the same context manager. - Network accessline 168
([Join tutorial](https://docs.pytorch.org/tutorials/advanced/generic_join.html)). `model.join()` is the - Network accessline 204
**Root cause**: with no `auto_wrap_policy`, FSDP makes the **entire model one FSDP unit** — it must all-gather all parameters at once, defeating sharding ([FSDP tutorial](https://docs.pytorch.org/tutorials/intermediate/FSDP_tutorial.html)). - Network accessline 206
([FSDP tutorial](https://docs.pytorch.org/tutorials/intermediate/FSDP_tutorial.html)). - Network accessline 215
Under Accelerate set `fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP` + `fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer` ([HF FSDP](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp)). FSDP2 (`fully_shard`) is the - Network accessline 216
`fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer` ([HF FSDP](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp)). FSDP2 (`fully_shard`) is the current API; the wrapping principle is identical. - Network accessline 217
([HF FSDP](https://huggingface.co/docs/accelerate/en/usage_guides/fsdp)). FSDP2 (`fully_shard`) is the - Network accessline 240
`reduce_dtype=fp32` (or vice versa) changes gradient-reduction precision; FSDP keeps fp32 master weights and casts to bf16 for forward ([pytorch#146114](https://github.com/pytorch/pytorch/issues/146114)). - Network accessline 242
([pytorch#146114](https://github.com/pytorch/pytorch/issues/146114)). - Network accessline 269
**Root cause**: DeepSpeed reads from the JSON, and several Accelerate/Trainer fields are **ignored** once a `deepspeed_config_file` is supplied ([HF Accelerate DeepSpeed](https://huggingface.co/docs/accelerate/en/usage_guides/deepspeed)). - Network accessline 271
([HF Accelerate DeepSpeed](https://huggingface.co/docs/accelerate/en/usage_guides/deepspeed)). - Network accessline 297
config *and* the JSON to non-`"auto"` values multiplies them. (b) With DeepSpeed's own AMP, gradient scaling lives inside the engine — calling bare `loss.backward()` instead of `model_engine.backward(loss)` skips scaling ([DeepSpeed engine] - Network accessline 299
skips scaling ([DeepSpeed engine](https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/engine.py)). - Network accessline 320
**Fix — set these and relaunch the hang**: - `export TORCH_DISTRIBUTED_DEBUG=DETAIL` + `export TORCH_CPP_LOG_LEVEL=INFO` → on mismatch PyTorch prints `Detected mismatch between collectives on ranks`, naming the op + sequence number per rank - Network accessline 321
- `export TORCH_DISTRIBUTED_DEBUG=DETAIL` + `export TORCH_CPP_LOG_LEVEL=INFO` → on mismatch PyTorch prints `Detected mismatch between collectives on ranks`, naming the op + sequence number per rank ([PyTorch forum](https://discuss.pytorch.o - Network accessline 346
SyncBN, or a metric `all_reduce`) placed inside a rank-conditional branch. Rank 0 calls it; others skip it; everyone deadlocks. The classic is "save/log on rank 0 only" where the save path triggers a collective ([Lightning#19604](https://gi - Network accessline 348
collective ([Lightning#19604](https://github.com/Lightning-AI/pytorch-lightning/issues/19604)). - Network accessline 384
> `parallelize_module(model, m["tp"], plan)` mapping submodules to `ColwiseParallel` / `RowwiseParallel` / > `SequenceParallel`; then shard the data dim with FSDP2 `fully_shard(model, mesh=m["dp"])`. > ([PyTorch TP docs](https://docs.pytorc - Network accessline 386
> ([PyTorch TP docs](https://docs.pytorch.org/docs/stable/distributed.tensor.parallel.html))
references/training/oom-memory.md
- Network accessline 30
Source: HF model-memory-anatomy (https://huggingface.co/docs/transformers/en/model_memory_anatomy) gives - Network accessline 51
Sources: PyTorch forums thread on the trace fields (https://discuss.pytorch.org/t/torch-outofmemoryerror-cuda-out-of-memory/217669); the reserved-vs-allocated - Network accessline 52
(https://discuss.pytorch.org/t/torch-outofmemoryerror-cuda-out-of-memory/217669); the reserved-vs-allocated - Network accessline 94
sub-batches before one optimizer step — same math, lower peak activation memory. Keep micro-batch as large as fits (batch 4 × accum 16 beats batch 1 × accum 64 — better GPU utilization). Source: https://huggingface.co/docs/transformers/main - Network accessline 95
as fits (batch 4 × accum 16 beats batch 1 × accum 64 — better GPU utilization). Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (gradient accumulation). Caveat: accumulation also multiplies the effective LR unles - Network accessline 96
Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (gradient accumulation). - Network accessline 107
and fp32 weight copies); **prefer bf16 over fp16** where supported → `references/training/precision-stability.md` P1. Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (mixed precision; bf16 needs - Network accessline 108
`references/training/precision-stability.md` P1. Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (mixed precision; bf16 needs Ampere+). - Network accessline 109
Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (mixed precision; bf16 needs - Network accessline 117
`torch.utils.checkpoint.checkpoint(...)` manually. Only a subset of activations is stored; the rest are **recomputed** during backward — cuts activation memory substantially at **~20–30% slower** training. Source: https://huggingface.co/doc - Network accessline 118
**recomputed** during backward — cuts activation memory substantially at **~20–30% slower** training. Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one ("~20% slower"). Gotcha: with HF generate/caching set `model.c - Network accessline 119
Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one ("~20% slower"). Gotcha: with - Network accessline 129
starts; `PYTORCH_CUDA_ALLOC_CONF` is the canonical name). It backs segments with CUDA VMM so they grow/shrink instead of each `cudaMalloc` being an unmergeable block — which is the root of fragmentation. Source: PyTorch CUDA notes (https:// - Network accessline 130
instead of each `cudaMalloc` being an unmergeable block — which is the root of fragmentation. Source: PyTorch CUDA notes (https://docs.pytorch.org/docs/stable/notes/cuda.html) and the allocator devlog (https://docs.pytorch.org/devlogs/eager - Network accessline 131
Source: PyTorch CUDA notes (https://docs.pytorch.org/docs/stable/notes/cuda.html) and the allocator devlog - Network accessline 132
(https://docs.pytorch.org/devlogs/eager/2026-06-01-cuda-caching-allocator/). Alternative knob if fragmenting - Network accessline 148
- **ZeRO-3 / FSDP `FULL_SHARD`** — also partition **parameters** (the 6 B). Maximum savings; needs high-bandwidth interconnect (NVLink/NVSwitch) because params are all-gathered per layer. Source: DeepSpeed ZeRO tutorial (https://www.deeps - Network accessline 149
high-bandwidth interconnect (NVLink/NVSwitch) because params are all-gathered per layer. Source: DeepSpeed ZeRO tutorial (https://www.deepspeed.ai/tutorials/zero/) and HF DeepSpeed integration (https://huggingface.co/docs/transformers/en/de - Network accessline 150
Source: DeepSpeed ZeRO tutorial (https://www.deepspeed.ai/tutorials/zero/) and HF DeepSpeed integration - Network accessline 151
(https://huggingface.co/docs/transformers/en/deepspeed); FSDP's `ShardingStrategy` maps 1:1 to these stages. - Network accessline 160
**ZeRO-Infinity** offloads to both for huge models. QLoRA's **paged optimizers** (M12) are a lighter form — optimizer state pages to CPU only on memory spikes. Source: DeepSpeed ZeRO docs (https://deepspeed.readthedocs.io/en/stable/zero3.ht - Network accessline 161
optimizer state pages to CPU only on memory spikes. Source: DeepSpeed ZeRO docs (https://deepspeed.readthedocs.io/en/stable/zero3.html); ZeRO-Infinity (https://www.deepspeed.ai/2021/03/07/zero3-offload.html). Cost: PCIe/NVMe bandwidth becom - Network accessline 162
(https://deepspeed.readthedocs.io/en/stable/zero3.html); ZeRO-Infinity - Network accessline 163
(https://www.deepspeed.ai/2021/03/07/zero3-offload.html). Cost: PCIe/NVMe bandwidth becomes the bottleneck — - Network accessline 184
`optim="adafactor"` (stores row/column moments instead of per-element → much less memory, **slower convergence**). **Paged** variants additionally page optimizer state to CPU on spikes to survive transient peaks. Source: https://huggingface - Network accessline 185
convergence**). **Paged** variants additionally page optimizer state to CPU on spikes to survive transient peaks. Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (optimizers) and model-memory-anatomy ("quantized - Network accessline 186
peaks. Source: https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one (optimizers) and - Network accessline 197
optimizers), train fp16/bf16 adapters on top — reported to finetune a **65B model on a single 48 GB GPU** with no accuracy degradation vs 16-bit. Source: QLoRA paper (https://arxiv.org/abs/2305.14314) and repo (https://github.com/artidoro/q - Network accessline 198
with no accuracy degradation vs 16-bit. Source: QLoRA paper (https://arxiv.org/abs/2305.14314) and repo (https://github.com/artidoro/qlora). Note: LoRA *changes model capacity* — it is a different optimization target, not a free OOM trick, - Network accessline 199
(https://arxiv.org/abs/2305.14314) and repo (https://github.com/artidoro/qlora). Note: LoRA *changes model - Network accessline 228
**Fix**: set `per_device_eval_batch_size` explicitly (don't inherit a too-large value); set **`eval_accumulation_steps=N`** so predictions move to CPU every N steps instead of piling on the GPU (https://huggingface.co/docs/transformers/main - Network accessline 229
**`eval_accumulation_steps=N`** so predictions move to CPU every N steps instead of piling on the GPU (https://huggingface.co/docs/transformers/main_classes/trainer). In a custom loop: wrap eval in `torch.no_grad()` / `torch.inference_mode( - Network accessline 230
(https://huggingface.co/docs/transformers/main_classes/trainer). In a custom loop: wrap eval in - Network accessline 253
not at construction. Peak therefore jumps after step 1. Reserved memory also climbs as the allocator caches backward buffers. Source: the memory-snapshot timeline shows optimizer state appearing after iter 1 (https://pytorch.org/blog/unders - Network accessline 255
(https://pytorch.org/blog/understanding-gpu-memory-1/). - Network accessline 271
`torch.cuda.max_memory_allocated()` for the true peak (reset with `reset_peak_memory_stats()` between phases to isolate forward vs backward vs optimizer). Source: https://docs.pytorch.org/docs/stable/notes/cuda.html (memory management funct - Network accessline 273
https://docs.pytorch.org/docs/stable/notes/cuda.html (memory management functions). - Network accessline 288
Drag `oom_snapshot.pickle` onto **https://pytorch.org/memory_viz** (snapshots are not uploaded server-side), - Network accessline 290
**parameters / gradients / optimizer state / activations / temporaries** separately, so the tallest band at the OOM moment names the bucket to attack (→ map back to M5–M13). Available PyTorch **2.1+**. Source: https://pytorch.org/blog/under - Network accessline 291
the OOM moment names the bucket to attack (→ map back to M5–M13). Available PyTorch **2.1+**. Source: https://pytorch.org/blog/understanding-gpu-memory-1/. On a remote box: dump the pickle, `scp` it down (references/run-remote/ssh_transport - Network accessline 292
https://pytorch.org/blog/understanding-gpu-memory-1/. On a remote box: dump the pickle, `scp` it down - Network accessline 303
anyway). It only helps a *second* process on the same GPU, or it reduces fragmentation at a ~10% speed cost (HF `torch_empty_cache_steps=N` runs it every N steps — https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one). It - Network accessline 304
cost (HF `torch_empty_cache_steps=N` runs it every N steps — https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one). It is **not** a fix for a model that genuinely doesn't fit. - Network accessline 305
https://huggingface.co/docs/transformers/main/en/perf_train_gpu_one). It is **not** a fix for a model that
references/training/precision-stability.md
- Network accessline 33
bf16 handles large dot-products / attention logits better than fp16, which saturates and triggers scaler-step-skipping. URLs: https://docs.pytorch.org/docs/2.12/amp.html · - Network accessline 34
scaler-step-skipping. URLs: https://docs.pytorch.org/docs/2.12/amp.html · - Network accessline 35
https://www.runpod.io/articles/guides/fp16-bf16-fp8-mixed-precision-speed-up-my-model-training - Network accessline 54
`"high"` = TF32; `"highest"` = true fp32 (default); `"medium"` = even coarser. HF Trainer exposes `--tf32 1`. Most nets converge identically with TF32 as with fp32. URLs: https://github.com/pytorch/pytorch/pull/76509 · - Network accessline 55
Most nets converge identically with TF32 as with fp32. URLs: https://github.com/pytorch/pytorch/pull/76509 · https://docs.pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html · - Network accessline 56
https://github.com/pytorch/pytorch/pull/76509 · - Network accessline 57
https://docs.pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html · - Network accessline 58
https://docs.pytorch.org/docs/2.12/notes/numerical_accuracy.html - Network accessline 74
On V100/T4 use fp16+GradScaler (P5). FP8 (H100) is opt-in via Transformer Engine / `torchao`, not plain autocast (out of scope). Record the card next to `nvidia-smi` in Phase 0. URL: https://www.e2enetworks.com/blog/nvidia-a100-vs-h100-vs-h - Network accessline 76
URL: https://www.e2enetworks.com/blog/nvidia-a100-vs-h100-vs-h200-gpu-comparison - Network accessline 98
...)` / `torch.amp.GradScaler("cuda")` API — `torch.cuda.amp.*` is **deprecated** in PyTorch 2.x. autocast state is thread-local (re-enter it inside each DDP/DataParallel worker thread). URL: https://docs.pytorch.org/docs/2.12/amp.html - Network accessline 100
URL: https://docs.pytorch.org/docs/2.12/amp.html - Network accessline 125
gradients don't underflow — carrying a GradScaler into a bf16 run is dead weight (wasted overhead, not a crash), and bf16 runs plain `loss.backward(); optimizer.step()`. URLs: https://github.com/pytorch/pytorch/blob/main/docs/source/notes/a - Network accessline 126
crash), and bf16 runs plain `loss.backward(); optimizer.step()`. URLs: https://github.com/pytorch/pytorch/blob/main/docs/source/notes/amp_examples.rst · https://docs.pytorch.org/docs/2.12/amp.html - Network accessline 127
https://github.com/pytorch/pytorch/blob/main/docs/source/notes/amp_examples.rst · - Network accessline 128
https://docs.pytorch.org/docs/2.12/amp.html - Network accessline 148
`unscale_` is idempotent-per-step (call it once). For bf16, just `clip_grad_norm_` directly — no unscale. URL: https://github.com/pytorch/pytorch/blob/main/docs/source/notes/amp_examples.rst - Network accessline 149
URL: https://github.com/pytorch/pytorch/blob/main/docs/source/notes/amp_examples.rst - Network accessline 170
URLs: https://docs.pytorch.org/docs/stable/generated/torch.log.html · - Network accessline 171
https://medium.com/better-ml/loss-spikes-in-training-causes-detection-and-mitigations-ed66e591b1a1 - Network accessline 192
The docs warn it "will slow down your program" (roughly an order of magnitude) — enable to *locate*, then turn OFF for the real run, never ship it on. URL: https://docs.pytorch.org/docs/2.12/autograd.html - Network accessline 193
turn OFF for the real run, never ship it on. URL: https://docs.pytorch.org/docs/2.12/autograd.html - Network accessline 205
scores, the loss) in **fp32** via a nested `torch.autocast("cuda", enabled=False)` region, and apply z-loss (P15) / qk-norm (P16) to stop the logits growing. URL: https://medium.com/better-ml/loss-spikes-in-training-causes-detection-and-mit - Network accessline 207
URL: https://medium.com/better-ml/loss-spikes-in-training-causes-detection-and-mitigations-ed66e591b1a1 - Network accessline 219
apart with the replay diagnostic (P14). Smoke the data first — smoke *content* is owned by **references/verifying/methodology.md** (cross-link **REQUIRED**). URL: https://arxiv.org/pdf/2311.03938 - Network accessline 221
URL: https://arxiv.org/pdf/2311.03938 - Network accessline 240
URLs: https://arxiv.org/pdf/2309.14322 · - Network accessline 241
https://apxml.com/courses/how-to-build-a-large-language-model/chapter-24-identifying-mitigating-training-instabilities/stabilization-techniques-revisited - Network accessline 254
*all* grads down, so one embedding-heavy batch can throttle everything else that step — consider per-module clipping if embeddings dominate. URL: https://medium.com/better-ml/loss-spikes-in-training-causes-detection-and-mitigations-ed66e591 - Network accessline 256
URL: https://medium.com/better-ml/loss-spikes-in-training-causes-detection-and-mitigations-ed66e591b1a1 - Network accessline 276
**Tell a *data* spike from an *optimizer-state* one by replay:** re-run the same batches from an *earlier* checkpoint — if the spike does **not** reproduce, it is a state interaction, not dirty data, so roll back (~100 steps) and skip those - Network accessline 277
checkpoint — if the spike does **not** reproduce, it is a state interaction, not dirty data, so roll back (~100 steps) and skip those batches rather than blaming the data ([PaLM §5.1](https://arxiv.org/abs/2204.02311) saw ~20 such spikes, n - Network accessline 278
(~100 steps) and skip those batches rather than blaming the data ([PaLM §5.1](https://arxiv.org/abs/2204.02311) - Network accessline 279
saw ~20 such spikes, none reproducing on replay). If a spike resists all of the above, suspect fp16 *range*: BLOOM's 104B fp16 pretraining diverged irrecoverably where the 176B **bf16** run stayed stable — prefer bf16 ([BLOOM §3.4.3](https: - Network accessline 280
BLOOM's 104B fp16 pretraining diverged irrecoverably where the 176B **bf16** run stayed stable — prefer bf16 ([BLOOM §3.4.3](https://arxiv.org/abs/2211.05100)). Adaptive spike-clipping (ZClip) and momentum-reset on spike (SPAM) automate thi - Network accessline 281
([BLOOM §3.4.3](https://arxiv.org/abs/2211.05100)). - Network accessline 283
https://arxiv.org/pdf/2504.02507 · https://arxiv.org/pdf/2501.06842 - Network accessline 300
Coefficient **1e-4** is the PaLM / ST-MoE value; too large lets z-loss dominate. Standard in LLM pretraining; also the recommended fix for MoE router instability. URLs: https://medium.com/dair-ai/papers-explained-50-palm-480e72fa3fd5 · http - Network accessline 301
also the recommended fix for MoE router instability. URLs: https://medium.com/dair-ai/papers-explained-50-palm-480e72fa3fd5 · https://arxiv.org/pdf/2202.08906 · https://arxiv.org/pdf/2309.14322 - Network accessline 302
https://medium.com/dair-ai/papers-explained-50-palm-480e72fa3fd5 · https://arxiv.org/pdf/2202.08906 · - Network accessline 303
https://arxiv.org/pdf/2309.14322 - Network accessline 313
**Fix**: apply **QK-LayerNorm** — LayerNorm query and key per-head before the dot-product. Combined with z-loss (P15) + warmup (P12), it lets small models train to similar loss across *orders of magnitude* of LR, i.e. removes most LR-sensit - Network accessline 315
i.e. removes most LR-sensitivity. URL: https://arxiv.org/pdf/2309.14322 - Network accessline 325
**Fix**: scale residual-branch init by `1/√(2·n_layers)` (GPT-2-style); prefer pre-LN over post-LN for deep transformers; init embeddings at small std (~0.02). When unsure, copy a *known-good* config's init+norm scheme rather than tuning bl - Network accessline 327
scheme rather than tuning blind. URL: https://arxiv.org/pdf/2309.14322 - Network accessline 347
A grad-norm trace is the cheapest, highest-signal stability instrument — log it from step 1. URL: https://apxml.com/courses/how-to-build-a-large-language-model/chapter-24-identifying-mitigating-training-instabilities/stabilization-technique - Network accessline 348
URL: https://apxml.com/courses/how-to-build-a-large-language-model/chapter-24-identifying-mitigating-training-instabilities/stabilization-techniques-revisited - Network accessline 368
`references/run-remote/gotchas_universal.md`. This layer only ensures the knobs are *set and logged*. Determinism costs speed — enable for the datapoint that must be clean, not every throwaway run. URL: https://docs.pytorch.org/docs/stable/ - Network accessline 370
URL: https://docs.pytorch.org/docs/stable/notes/randomness.html
references/training/throughput-profiling.md
- Network accessline 32
**Fix — classify with one cheap reading each** (heuristic: util consistently >90% ⇒ GPU-bound; low/fluctuating ⇒ elsewhere; both CPU+GPU low ⇒ I/O — https://apxml.com/courses/planning-optimizing-ai-infrastructure/chapter-5-strategies-for-pe - Network accessline 33
low/fluctuating ⇒ elsewhere; both CPU+GPU low ⇒ I/O — https://apxml.com/courses/planning-optimizing-ai-infrastructure/chapter-5-strategies-for-performance-optimization/identifying-performance-bottlenecks): - **GPU-bound** (the good case): u - Network accessline 34
https://apxml.com/courses/planning-optimizing-ai-infrastructure/chapter-5-strategies-for-performance-optimization/identifying-performance-bottlenecks): - Network accessline 80
**Root cause**: with `num_workers=0` "the data will be loaded in the main process" — no overlap between data prep and compute (https://docs.pytorch.org/docs/2.12/data.html). - Network accessline 81
data prep and compute (https://docs.pytorch.org/docs/2.12/data.html). - Network accessline 94
**Root cause**: default `persistent_workers=False` shuts down all workers after the dataset is consumed once and **re-forks them next epoch** — re-importing, re-opening files, rebuilding the dataset object each time (https://docs.pytorch.or - Network accessline 96
time (https://docs.pytorch.org/docs/2.12/data.html). - Network accessline 106
**Root cause**: a pageable-memory tensor must be staged through a pinned buffer by the driver before DMA; a synchronous `.to(device)` blocks the step. "When using a GPU it's better to set `pin_memory=True`" (https://docs.pytorch.org/tutoria - Network accessline 108
(https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). - Network accessline 117
**Symptom**: with workers on, the GPU still periodically stalls — every *Nth* step (N = `num_workers`) has a long idle gap because all workers were busy producing the next batch when the GPU asked (https://docs.pytorch.org/tutorials/interme - Network accessline 119
(https://docs.pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html). - Network accessline 121
**Root cause**: `prefetch_factor` defaults to **2** when `num_workers>0` (None when 0) — "2 means there will be a total of `2 * num_workers` batches prefetched across all workers" (https://docs.pytorch.org/docs/2.12/data.html). A shallow qu - Network accessline 122
will be a total of `2 * num_workers` batches prefetched across all workers" (https://docs.pytorch.org/docs/2.12/data.html). A shallow queue can't absorb a variance spike in per-sample fetch/decode time. - Network accessline 123
(https://docs.pytorch.org/docs/2.12/data.html). A shallow queue can't absorb a variance spike in - Network accessline 159
**Root cause**: by default cuDNN picks a generic conv algorithm; the autotuner benchmarks variants on the first batch of each new shape and caches the fastest (https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). - Network accessline 161
(https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). - Network accessline 176
`model = model.to(memory_format=torch.channels_last)` and `x = x.to(memory_format=torch.channels_last)`. Optimizes convolutional networks with Tensor Cores + AMP (https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). Marked - Network accessline 177
Optimizes convolutional networks with Tensor Cores + AMP (https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). Marked experimental and CNN-specific (no benefit for pure transformers). No numerics change — purely a layout s - Network accessline 178
(https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). Marked experimental and CNN-specific - Network accessline 183
- **`optimizer.zero_grad(set_to_none=True)`** (the **default** since PyTorch 2.0) over zero-filling — assigning `None` skips a memory-write kernel per param and lets the next backward write fresh (https://docs.pytorch.org/tutorials/reci - Network accessline 184
assigning `None` skips a memory-write kernel per param and lets the next backward write fresh (https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). Edge case: code reading `.grad` between steps must tolerate `None`. - Network accessline 185
(https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html). Edge case: code reading `.grad` - Network accessline 188
`torch.autograd.profiler.profile`, `gradcheck` add per-op bookkeeping (anomaly detection is ~10× slower, precision-stability P9). Grep `detect_anomaly` / leftover `with profile(` wrappers before a long launch (https://docs.pytorch.org/t - Network accessline 190
(https://docs.pytorch.org/tutorials/recipes/recipes/tuning_guide.html); easy to leave on after a NaN hunt. - Network accessline 216
**silently falls back to the slow `math` backend** when the fused kernel's input constraints aren't met (wrong dtype, head dim, mask shape) — "if a fused implementation is not available, a warning will be raised" (https://docs.pytorch.org/d - Network accessline 218
raised" (https://docs.pytorch.org/docs/2.12/generated/torch.nn.functional.scaled_dot_product_attention.html). - Network accessline 232
`<96 GB` RAM ninja over-parallelizes and OOMs the build — cap `MAX_JOBS=4 pip install flash-attn --no-build-isolation`. Prefer a **prebuilt wheel** matching the `cuXX/torchYY/cpZZ` triple (https://github.com/Dao-AILab/flash-attention/is - Network accessline 233
--no-build-isolation`. Prefer a **prebuilt wheel** matching the `cuXX/torchYY/cpZZ` triple (https://github.com/Dao-AILab/flash-attention/issues/1038, https://pypi.org/project/flash-attn/). A torch/CUDA mismatch is **`references/run-remo - Network accessline 234
(https://github.com/Dao-AILab/flash-attention/issues/1038, https://pypi.org/project/flash-attn/). A - Network accessline 245
**Fix**: wrap the model — `model = torch.compile(model)`. Modes (https://huggingface.co/docs/transformers/en/perf_torch_compile): - Network accessline 246
(https://huggingface.co/docs/transformers/en/perf_torch_compile): - Network accessline 253
Reported ~2.2× mean-inference speedups; training gains real but model-dependent. **First step(s) are slow** — compilation is lazy on first call (https://huggingface.co/docs/transformers/en/perf_torch_compile); exclude - Network accessline 254
— compilation is lazy on first call (https://huggingface.co/docs/transformers/en/perf_torch_compile); exclude - Network accessline 266
`cache_size_limit`) Dynamo **stops compiling that function and runs it eagerly** — paying all the compile cost and getting none of the benefit (https://docs.pytorch.org/docs/stable/compile/programming_model.recompilation.html, - Network accessline 267
cost and getting none of the benefit (https://docs.pytorch.org/docs/stable/compile/programming_model.recompilation.html, https://github.com/pytorch/pytorch/issues/93457). - Network accessline 268
(https://docs.pytorch.org/docs/stable/compile/programming_model.recompilation.html, - Network accessline 269
https://github.com/pytorch/pytorch/issues/93457). - Network accessline 272
- **See it**: `TORCH_LOGS=recompiles python train.py` logs which function recompiled and the failed guard; `TORCH_LOGS=graph_breaks` and `torch._dynamo.explain(...)` locate graph breaks (https://docs.pytorch.org/docs/stable/torch.compil - Network accessline 273
`TORCH_LOGS=graph_breaks` and `torch._dynamo.explain(...)` locate graph breaks (https://docs.pytorch.org/docs/stable/torch.compiler_troubleshooting.html). - **Tame shapes**: pad/bucket to a few fixed shapes so guards stop firing; or mark - Network accessline 274
(https://docs.pytorch.org/docs/stable/torch.compiler_troubleshooting.html). - Network accessline 277
one shape-generic graph instead of one per size. `dynamic=False` forces a fresh recompile per distinct size (use only with truly few shapes) (https://docs.pytorch.org/docs/stable/compile/programming_model.html). - Network accessline 278
size (use only with truly few shapes) (https://docs.pytorch.org/docs/stable/compile/programming_model.html). - **Last resort**: raise `torch._dynamo.config.recompile_limit` only if a handful of *stable* extra shapes - Network accessline 279
(https://docs.pytorch.org/docs/stable/compile/programming_model.html). - Network accessline 328
**Fix — scheduled profile of a few steps** (https://docs.pytorch.org/tutorials/recipes/recipes/profiler_recipe.html): - Network accessline 329
(https://docs.pytorch.org/tutorials/recipes/recipes/profiler_recipe.html): - Network accessline 343
**Read it**: large **GPU-timeline gaps** with CPU busy in `DataLoader`/transforms during the gap ⇒ **data-bound** (T4–T8); the TensorBoard "Performance Recommendation" panel names the DataLoader directly (https://docs.pytorch.org/tutorials/ - Network accessline 344
**data-bound** (T4–T8); the TensorBoard "Performance Recommendation" panel names the DataLoader directly (https://docs.pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html). Densely-packed GPU timeline ⇒ GPU-bound; sort by - Network accessline 345
(https://docs.pytorch.org/tutorials/intermediate/tensorboard_profiler_tutorial.html). Densely-packed GPU - Network accessline 357
memcpy, NVTX ranges, OS-runtime — so it exposes launch-bound stalls and CPU↔GPU sync that PyTorch can't. "Periodic gaps in the CUDA HW row are moments when the GPU is idle — a red flag" (https://docs.lxp.lu/howto/pytorch-profiling-with-nsig - Network accessline 359
(https://docs.lxp.lu/howto/pytorch-profiling-with-nsight/). - Network accessline 361
**Fix — profile a bounded window on the box, view locally** (canonical PyTorch recipe, https://gist.github.com/mcarilli/376821aa1a7182dfcf59928a7cde3223): - Network accessline 362
https://gist.github.com/mcarilli/376821aa1a7182dfcf59928a7cde3223): - Network accessline 373
`scp` the `.nsys-rep` down, open in the Nsight Systems GUI. Nsight **Systems** finds *which* kernel is slow; Nsight **Compute** (`ncu`) finds *why* (occupancy, bandwidth, warp stalls) — but `ncu` is heavy, reserve it for one hot kernel (htt - Network accessline 375
for one hot kernel (https://www.spheron.network/blog/gpu-profiling-ai-workloads-nsight-compute-pytorch-profiler-guide/). - Network accessline 385
**Fix — attach by PID, zero instrumentation** (https://github.com/benfred/py-spy): - Network accessline 399
For *what allocated the memory* (not time), the `torch.cuda.memory._record_memory_history` snapshot + https://pytorch.org/memory_viz timeline is owned by **references/training/oom-memory.md M19/M18**. It is a - Network accessline 400
https://pytorch.org/memory_viz timeline is owned by **references/training/oom-memory.md M19/M18**. It is a - Network accessline 410
**Root cause**: DDP overlaps gradient all-reduce with backward by bucketing gradients and launching each bucket's reduce on a separate CUDA stream as soon as it's ready (https://github.com/pytorch/pytorch/issues/67570). Overlap *breaks* whe - Network accessline 411
bucket's reduce on a separate CUDA stream as soon as it's ready (https://github.com/pytorch/pytorch/issues/67570). Overlap *breaks* when something forces a sync: an unused-parameter recompute, an off-by-default `find_unused_parameters=True` - Network accessline 412
(https://github.com/pytorch/pytorch/issues/67570). Overlap *breaks* when something forces a sync: an
references/verifying/methodology.md
- Network accessline 185
image as independent images. A paired analysis can detect an effect despite overlapping marginal bars. A wide interval means unresolved precision, not proof of zero effect; tiny or degenerate resamples do not create information. See [NI - Network accessline 186
bars. A wide interval means unresolved precision, not proof of zero effect; tiny or degenerate resamples do not create information. See [NIST paired observations](https://www.itl.nist.gov/div898/handbook/prc/section3/prc311.htm) and [tw - Network accessline 187
resamples do not create information. See [NIST paired observations](https://www.itl.nist.gov/div898/handbook/prc/section3/prc311.htm) - Network accessline 188
and [two-sample inference](https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm). - Network accessline 197
threshold, not MDE at a specified power. If the design cannot resolve the actionable effect, change the authorized design or report that limitation; an observed small/non-significant result is not automatically a null finding. [NIST sam - Network accessline 198
change the authorized design or report that limitation; an observed small/non-significant result is not automatically a null finding. [NIST sample-size and power derivation](https://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm - Network accessline 199
is not automatically a null finding. [NIST sample-size and power derivation](https://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm).
scripts/aggregate_to_fs.sh
- Executable scriptline 1
#!/usr/bin/env bash
scripts/build_pull_manifest.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/check_staleness.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/compare_acceptance.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/download_loop.sh
scripts/gpu_health.sh
- Executable scriptline 1
#!/usr/bin/env bash
scripts/health_patrol.sh.template
- Executable scriptline 1
#!/usr/bin/env bash
scripts/manifest_scaffold.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/mem_monitor.sh
- Executable scriptline 1
#!/usr/bin/env bash
scripts/preflight_audit.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/reap_vram_zombies.sh
- Executable scriptline 1
#!/usr/bin/env bash
scripts/reconcile.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/repro.sh.template
- Executable scriptline 1
#!/usr/bin/env bash
scripts/run_one.sh.template
scripts/run_queue.sh.template
scripts/setup-china-mirrors.sh
- Executable scriptline 1
#!/usr/bin/env bash - Network accessline 10
export HF_ENDPOINT="${HF_ENDPOINT:-https://hf-mirror.com}" - Network accessline 22
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 2>/dev/null \ - Network accessline 23
|| export PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple - Network accessline 34
echo "[setup-china-mirrors] HF_ENDPOINT=$HF_ENDPOINT HF_HOME=$HF_HOME"
scripts/test_reconcile.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/verify_artifact_bundle.py
- Executable scriptline 1
#!/usr/bin/env python3
scripts/verify_local.py
- Executable scriptline 1
#!/usr/bin/env python3
How the signals fit together
Facts from a static read of the files at the pinned commit. They describe what the code does, not why.
Some files could not be read; the facts below still hold.
Signal confidence: 500 facts
- Network access in prose of documentationREADME.md:3Low confidence
- Network access in prose of documentationREADME.md:4Low confidence
- Network access in prose of documentationREADME.md:12Low confidence
- Dangerous shell operation in prose of documentationREADME.md:17Low confidence
- Network access in code of documentationREADME.md:28Low confidence
- Network access in code of documentationREADME.md:29Low confidence
- Network access in code of documentationREADME.md:37Low confidence
- Network access in code of documentationREADME.md:44Low confidence
- Dangerous shell operation in prose of documentationREADME.md:84Low confidence
- Network access in prose of documentationREADME.md:99Low confidence
- Network access in prose of documentationREADME.md:100Low confidence
- Network access in prose of documentationREADME.md:101Low confidence
- Network access in prose of documentationREADME.md:102Low confidence
- Network access in prose of documentationREADME.md:103Low confidence
- Network access in prose of documentationREADME.md:104Low confidence
- Network access in prose of documentationREADME.md:105Low confidence
- Network access in code of documentationREADME.md:116Low confidence
- Network access in code of documentationREADME.md:117Low confidence
- Network access in code of documentationREADME.md:118Low confidence
- Network access in prose of documentationREADME.md:124Low confidence
- Network access in prose of documentationREADME.md:125Low confidence
- Network access in prose of documentationREADME.md:126Low confidence
- Network access in prose of documentationREADME.md:190Low confidence
- Network access in prose of documentationREADME.md:206Low confidence
- Network access in prose of documentationREADME.md:212Low confidence
- Network access in code of documentationREADME.md:243Low confidence
- Network access in code of documentationREADME.md:244Low confidence
- Network access in code of documentationREADME.md:245Low confidence
- Executable script in code of a file that runsevals/run_evals.py:1High confidence
- Executable script in code of a testevals/test_instruction_surface.py:1Low confidence
- Access to secrets in prose of documentation: reads a credential storeprofiles/autodl.md:43Low confidence
- Access to secrets in prose of documentation: reads a credential storeprofiles/autodl.md:48Low confidence
- Dangerous shell operation in prose of documentationprofiles/autodl.md:116Low confidence
- Network access in prose of documentationprofiles/autodl.md:256Low confidence
- Network access in prose of documentationprofiles/autodl.md:257Low confidence
- Network access in prose of documentationprofiles/autodl.md:258Low confidence
- Network access in prose of documentationprofiles/autodl.md:259Low confidence
- Network access in prose of documentationprofiles/autodl.md:291Low confidence
- Network access in prose of documentationprofiles/autodl.md:292Low confidence
- Network access in prose of documentationprofiles/autodl.md:294Low confidence
- Network access in prose of documentationprofiles/autodl.md:295Low confidence
- Network access in prose of documentationprofiles/autodl.md:296Low confidence
- Network access in code of documentationprofiles/autodl.md:391Low confidence
- Network access in code of documentationprofiles/autodl.md:392Low confidence
- Network access in code of documentationprofiles/autodl.md:393Low confidence
- Access to secrets in prose of documentationprofiles/autodl.md:402Low confidence
- Network access in prose of documentationprofiles/china.md:105Low confidence
- Network access in prose of documentationprofiles/china.md:106Low confidence
- Network access in prose of documentationprofiles/china.md:107Low confidence
- Network access in prose of documentationprofiles/china.md:111Low confidence
and 450 more
Only the first 500 facts are listed.
Works with
| Agent | Status | Evidence | Install to |
|---|---|---|---|
| Claude Code | Compatible | Standard SKILL.md SKILL.md | .claude/skills/<skill-name>/ |
| Codex | Compatible | Standard SKILL.md SKILL.md | .agents/skills/<skill-name>/ |
| Cursor | Compatible | Standard SKILL.md SKILL.md | .cursor/skills/<skill-name>/ |
| Gemini CLI | Compatible | Standard SKILL.md SKILL.md | .gemini/skills/<skill-name>/ |
| GitHub Copilot | Compatible | Standard SKILL.md SKILL.md | .github/skills/<skill-name>/ |
| OpenCode | Compatible | Standard SKILL.md SKILL.md | .opencode/skills/<skill-name>/ |
- Native The repository ships a manifest, folder or frontmatter field for this agent.
- Compatible A standard SKILL.md that this agent can read.
- Unknown No evidence either way.
Derived automatically from paths, manifests and frontmatter. Not tested on each agent.