training
Train Transformer translation models with train.py, safe command construction, data-mode choices, hyperparameters, scheduler behavior, logs, checkpoints, CPU/GPU flags, TensorBoard, and troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- training
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Train Transformer translation models with train.py, safe command construction, data-mode choices, hyperparameters, scheduler behavior, logs, checkpoints, CPU/GPU flags, TensorBoard, and troubleshooting.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/cli-reference.md5.7 KB
- 参考文档references/troubleshooting.md6.0 KB
- 参考文档references/workflows.md7.6 KB
- 脚本scripts/build_training_command.py12.0 KB
- 脚本scripts/training_smoke_check.py7.8 KB
03 SKILL.md 正文
Training
Use this sub-skill when the task is to plan or debug training with train.py without starting an expensive run. It covers the training CLI, data input modes, safe command construction, loss/scheduler smoke checks, logs, checkpoints, device flags, TensorBoard, and recoverable training setup failures.
Do not use this sub-skill to create training data files, translate from a checkpoint, or explain Transformer internals beyond training-facing constructor flags. Route those tasks to the data-preparation, translation, or model-architecture sub-skills.
Fast routes
- Build a command without running training: use scripts/build_training_command.py, then confirm the details in references/cli-reference.md.
- Validate training helpers and a tiny model/scheduler path before a long run: use scripts/training_smoke_check.py.
- Choose between all-in-one pickle training and BPE-prefix training: read references/workflows.md.
- Recover from missing
-output_dir, stale README flags, CUDA failures, weight-sharing assertions, or TensorBoard import problems: read references/troubleshooting.md.
Safe operating pattern
- Decide the data mode:
- all-in-one pickle:
-data_pkl DATA.pklonly; - BPE files:
-data_pkl BPE_VOCAB.pkl -train_path TRAIN_PREFIX -val_path VAL_PREFIXwhere.srcand.trgfiles exist for both prefixes.
- all-in-one pickle:
- Always include
-output_dir;train.pyraises if it is omitted. - Prefer
-no_cudafor CPU-only planning and smoke checks. Omit it only when CUDA is available and desired. - Use
scripts/build_training_command.pyto print the exact command. It is safe by default and does not execute training. - Run
scripts/training_smoke_check.py --repo-root <checkout>in an environment with the legacy training dependencies when you need to verify import, loss, model forward, andScheduledOptimbehavior. - Treat full training as a long-running user action requiring prepared data, a writable output directory, and explicit approval.
Key runtime facts
train.pyusestorchtext.data.Field,Dataset,BucketIterator, andTranslationDataset, so it expects the legacy torchtext API rather than modern torchtext datapipes.- The training loop writes
train.logandvalid.loginside-output_dir, overwriting existing files with the same names at run start. - With default
-save_mode best, the checkpoint isOUTPUT_DIR/model.chkpt. With-save_mode all, checkpoint files are written in the process working directory, not in-output_dir. ScheduledOptimwraps Adam with the Transformer warmup schedule; it updates the learning rate on everystep_and_update_lr()call.- The README examples include a historical
-logflag, but the currenttrain.pyparser does not accept it. Omit-logfrom generated commands.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).