AGENT SKILL

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

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 MPerClassSampler during 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, and gradient_clippers.
  • Optional distributed wrappers: DistributedLossWrapper and DistributedMinerWrapper.

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 data unless the question is purely about their role inside a trainer.

How to use this sub-skill

  1. Read references/training-workflows.md for the trainer map, hook sequence, and config expectations.
  2. Run scripts/smoke_training.py when you want to confirm the trainer wiring on toy data without downloads.
  3. Read references/troubleshooting.md when the failure mentions missing dictionary keys, frozen modules, checkpointing, or logging dependencies.
  4. 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 components first.
  • If the user wants retrieval metrics, validation scores, or nearest-neighbor search after training, route to evaluation after the trainer is set up.
  • If the user wants dataset download or batch construction help, route to data before wiring the trainer.

Useful public facts

  • All trainer subclasses share the BaseTrainer argument pattern.
  • MetricLossOnly needs a trunk model and a metric_loss entry.
  • TrainWithClassifier expects a trunk/classifier architecture and both metric and classification losses.
  • CascadedEmbeddings splits the embedding dimension into multiple stages.
  • DeepAdversarialMetricLearning adds generator-specific loss keys and epoch scheduling.
  • TwoStreamMetricLoss expects a dataset that yields (anchor, positive, label).
  • HookContainer is the easiest path for record-keeper, tensorboard, early stopping, and model checkpointing.

Read next

  • references/training-workflows.md for trainer and hook details.
  • references/troubleshooting.md for trainer-key, checkpoint, logging, and distributed-wrapper failures.
  • scripts/smoke_training.py for a tiny end-to-end trainer smoke check.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351