training
Routes PyTorch Metric Learning questions about trainers, hooks, logging, checkpointing, and optional distributed wrappers.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- training
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Routes PyTorch Metric Learning questions about trainers, hooks, logging, checkpointing, and optional distributed wrappers.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/training-workflows.md4.6 KB
- 参考文档references/troubleshooting.md2.2 KB
- 脚本scripts/smoke_training.py3.2 KB
03 SKILL.md 正文
Training
Use this sub-skill when the user wants to wire PyTorch Metric Learning into an actual training loop, validation hook, or checkpoint/logging workflow.
Typical triggers
- "How do I use MetricLossOnly / TrainWithClassifier / CascadedEmbeddings / DeepAdversarialMetricLearning / TwoStreamMetricLoss?"
- "How do I configure the trainer dictionary keys?"
- "How do I add logging, early stopping, or checkpoint saving?"
- "How do I freeze part of the model or use
MPerClassSamplerduring training?" - "How do I wrap a loss or miner for distributed training?"
In scope
- Trainers:
BaseTrainer,MetricLossOnly,TrainWithClassifier,CascadedEmbeddings,DeepAdversarialMetricLearning,TwoStreamMetricLoss. - Hooking and logging:
logging_presets.HookContainer, record-keeper integration, model saving/loading, early stopping, validation hooks, and metric history access. - Trainer configuration:
models,optimizers,loss_funcs,mining_funcs,sampler,batch_size,iterations_per_epoch,freeze_these,freeze_trunk_batchnorm,label_hierarchy_level,data_and_label_getter,dataset_labels,set_min_label_to_zero,lr_schedulers, andgradient_clippers. - Optional distributed wrappers:
DistributedLossWrapperandDistributedMinerWrapper.
Out of scope
- Choosing the loss/miner/distance/reducer/regularizer stack belongs in
components. - Accuracy calculators, testers, and nearest-neighbor search belong in
evaluation. - Downloading datasets or building samplers belongs in
dataunless the question is purely about their role inside a trainer.
How to use this sub-skill
- Read
references/training-workflows.mdfor the trainer map, hook sequence, and config expectations. - Run
scripts/smoke_training.pywhen you want to confirm the trainer wiring on toy data without downloads. - Read
references/troubleshooting.mdwhen the failure mentions missing dictionary keys, frozen modules, checkpointing, or logging dependencies. - If the request mentions distributed loss/miner wrappers, read the optional distributed note in the workflow reference and treat GPU execution as optional unless the user specifically asks for it.
Common routing decisions
- If the user only needs the right loss or miner, route to
componentsfirst. - If the user wants retrieval metrics, validation scores, or nearest-neighbor search after training, route to
evaluationafter the trainer is set up. - If the user wants dataset download or batch construction help, route to
databefore wiring the trainer.
Useful public facts
- All trainer subclasses share the
BaseTrainerargument pattern. MetricLossOnlyneeds a trunk model and ametric_lossentry.TrainWithClassifierexpects a trunk/classifier architecture and both metric and classification losses.CascadedEmbeddingssplits the embedding dimension into multiple stages.DeepAdversarialMetricLearningadds generator-specific loss keys and epoch scheduling.TwoStreamMetricLossexpects a dataset that yields(anchor, positive, label).HookContaineris the easiest path for record-keeper, tensorboard, early stopping, and model checkpointing.
Read next
references/training-workflows.mdfor trainer and hook details.references/troubleshooting.mdfor trainer-key, checkpoint, logging, and distributed-wrapper failures.scripts/smoke_training.pyfor a tiny end-to-end trainer smoke check.
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).