AGENT SKILL

components

Routes PyTorch Metric Learning questions about losses, miners, distances, reducers, regularizers, self-supervised wrappers, and custom component implementations.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
components
license
MIT
metadata
{ "disco-role": "operating" }
description
Routes PyTorch Metric Learning questions about losses, miners, distances, reducers, regularizers, self-supervised wrappers, and custom component implementations.
disable-model-invocation
true

02 资源文件 3

03 SKILL.md 正文

Components

Use this sub-skill when the user needs to choose, combine, or customize the metric-learning primitives that sit below training and evaluation.

Typical triggers

  • "Which loss should I use for triplets, pairs, proxies, or self-supervision?"
  • "How do I pick a miner for this batch?"
  • "How do I swap the distance, reducer, or regularizer?"
  • "Why does this loss need labels, a miner output, or indices_tuple?"
  • "How do I write a custom loss or miner?"
  • "Why am I getting no valid triplets, a distance-compatibility error, or a shape error?"

In scope

  • Distances: LpDistance, CosineSimilarity, DotProductSimilarity, SNRDistance, and BatchedDistance.
  • Reducers: MeanReducer, AvgNonZeroReducer, ThresholdReducer, DivisorReducer, PerAnchorReducer, MultipleReducers, DoNothingReducer, SumReducer, ClassWeightedReducer.
  • Regularizers: LpRegularizer, CenterInvariantRegularizer, RegularFaceRegularizer, SparseCentersRegularizer, ZeroMeanRegularizer.
  • Miners: TripletMarginMiner, MultiSimilarityMiner, BatchHardMiner, BatchEasyHardMiner, DistanceWeightedMiner, PairMarginMiner, AngularMiner, HDCMiner, UniformHistogramMiner, EmbeddingsAlreadyPackagedAsTriplets.
  • Loss families and wrappers: TripletMarginLoss, ContrastiveLoss, MultiSimilarityLoss, NTXentLoss, AngularLoss, ArcFaceLoss, CosFaceLoss, NormalizedSoftmaxLoss, ProxyAnchorLoss, ProxyNCALoss, SelfSupervisedLoss, CrossBatchMemory, MultipleLosses, SmoothAPLoss, VICRegLoss, and related metric/classification losses.
  • Custom component authoring with BaseMetricLossFunction, BaseMiner, loss_and_miner_utils, and TorchInitWrapper.

Out of scope

  • Trainer setup, hooks, logging, and checkpointing belong in training.
  • Accuracy calculators, testers, and nearest-neighbor inference belong in evaluation.
  • Dataset download and sampler configuration belong in data.

How to use this sub-skill

  1. Start with references/losses-miners-and-customization.md for the compact component catalog and compatibility rules.
  2. Run scripts/smoke_components.py on toy tensors when you need a quick sanity check for a component stack or a custom extension.
  3. Read references/troubleshooting.md when the failure mentions labels, indices_tuple, no valid tuples, or an incompatible distance/reducer/regularizer.
  4. For custom loss/miner implementations, follow the distilled extension patterns and use the bundled loss_and_miner_utils helpers instead of re-deriving tuple conversion logic.

Common routing decisions

  • If the user asks which loss or miner to use, stay here.
  • If the user asks why a component rejects labels, margins, or tuple shapes, stay here.
  • If the user asks how to wire the chosen component into a trainer or tester, route to training or evaluation after the component choice is settled.

Useful public facts

  • Most metric losses and miners accept a distance object.
  • Some losses can be called with indices_tuple instead of labels when the tuple has already been mined.
  • Classification-style losses typically need num_classes and embedding_size, and some require an optimizer for their class weights.
  • CrossBatchMemory wraps another loss and adds queue behavior; SelfSupervisedLoss adapts a pair or tuple loss to two views.
  • MultipleLosses and MultipleReducers require matching keys or parallel lists.

Read next

  • references/losses-miners-and-customization.md for the component catalog and extension notes.
  • references/troubleshooting.md for predictable component-level failures.
  • scripts/smoke_components.py for a tiny direct 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