basic-metric-domains
Use TorchMetrics classification, regression, retrieval, clustering, nominal, and aggregation metrics with the right shapes and parameters.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- basic-metric-domains
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use TorchMetrics classification, regression, retrieval, clustering, nominal, and aggregation metrics with the right shapes and parameters.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/basic-domains-api.md5.9 KB
- 参考文档references/domain-workflows.md3.5 KB
- 参考文档references/troubleshooting.md2.5 KB
- 脚本scripts/basic_domain_metric_smoke.py3.5 KB
03 SKILL.md 正文
Basic Metric Domains
Use this sub-skill when the task is about a standard tensor-based TorchMetrics family rather than a custom metric or a model-backed metric.
Route map
- Read references/basic-domains-api.md when you need constructor arguments, input shapes, return types, or family-specific parameter meanings for classification, regression, retrieval, clustering, nominal, and aggregation metrics.
- Read references/domain-workflows.md when you need copyable usage patterns for binary/multiclass/multilabel classification, regression, retrieval queries, clustering labels, or nominal association scores.
- Read references/troubleshooting.md when shapes, labels, indices, empty groups, optional clustering dependencies, or reduction settings go wrong.
- Run scripts/basic_domain_metric_smoke.py for a no-download sanity check against representative metrics from each family.
What this sub-skill covers
- Classification:
Accuracy,AUROC,F1Score,Precision,Recall,ConfusionMatrix, calibration, hinge, Jaccard, Matthews correlation, and task-specificBinary*,Multiclass*, andMultilabel*classes. - Regression:
MeanSquaredError,MeanAbsoluteError,R2Score,PearsonCorrCoef,SpearmanCorrCoef,KLDivergence,JensenShannonDivergence,ContinuousRankedProbabilityScore, and related scalar reduction metrics. - Retrieval: grouped-query metrics such as
RetrievalNormalizedDCG,RetrievalMAP,RetrievalPrecision,RetrievalRecall,RetrievalMRR, and friends. - Clustering:
ClusterAccuracyand unsupervised clustering scores. - Nominal/association:
CramersV,FleissKappa,PearsonsContingencyCoefficient,TheilsU, andTschuprowsT. - Aggregation helpers:
MeanMetric,SumMetric,RunningMean,RunningSum, and related scalar accumulation helpers.
Route elsewhere
- Read
../core-api/SKILL.mdforMetriclifecycle, device placement, distributed synchronization,MetricCollection, or custom metric states. - Read
../vision-detection-metrics/SKILL.mdfor image, segmentation, detection, or panoptic metrics. - Read
../audio-text-metrics/SKILL.mdfor waveform metrics, ASR metrics, or no-download text metrics. - Read
../model-based-metrics/SKILL.mdfor BERTScore, CLIPScore, FID, or any metric that loads pretrained assets. - Read
../collections-wrappers-plotting/SKILL.mdfor collections, wrappers, trackers, and plotting.
Quick use
- Choose the metric family by the shape and semantics of the inputs.
- Match the constructor args to the task type, class count, label encoding, query grouping, or reduction mode.
- Keep label and target shapes aligned; most families flatten additional dimensions in a documented way.
- Check whether the metric returns a scalar, class vector, dict, or list before trying to log or plot it.
- Install only the extra required by the family you actually need; avoid broad extras unless the task spans multiple families.
Fast checks
python scripts/basic_domain_metric_smoke.pypython -c "from torchmetrics.classification import Accuracy; print(Accuracy(task='multiclass', num_classes=3))"
Common signals
task=...,num_classes,num_labels,average,threshold,ignore_index,multidim_average-> classificationnum_outputs,multioutput,reduction-> regressionindexes,empty_target_action,top_k,aggregation-> retrievalClusterAccuracy,torch_linear_assignment-> clusteringnan_strategy,nan_replace_value,bias_correction,mode='counts'-> nominal
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).