AGENT SKILL

losses-and-metrics

Operate MedicalZooPytorch loss and metric APIs for segmentation criteria, shape contracts, tuple returns, and safe smoke checks.

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

01 前言 Front Matter

name
losses-and-metrics
license
MIT
metadata
{ "disco-role": "operating" }
description
Operate MedicalZooPytorch loss and metric APIs for segmentation criteria, shape contracts, tuple returns, and safe smoke checks.
disable-model-invocation
true

02 资源文件 3

03 SKILL.md 正文

losses-and-metrics

Use this sub-skill when the task is to select, instantiate, debug, or smoke-test MedicalZooPytorch loss objects exposed through lib.losses3D.

Route first

  • For exact constructor names, accepted shapes, return types, one-hot expansion, and criterion-selection rules, open references/api-reference.md.
  • For assertion failures, unsupported loss names, singleton-batch 2D Dice quirks, device mismatches, or pixel-weight issues, open references/troubleshooting.md.
  • For model creation, trainer wiring, writer updates, checkpoints, full training loops, and inference, hand off to the sibling route segmentation-workflows. Bring only the selected criterion and its return contract from this sub-skill.
  • For how dataset loaders produce target tensors and labels, hand off to data-loading-preprocessing.

Fast operating rules

  1. Standard 3D semantic segmentation criteria expect logits shaped [N, C, D, H, W] and integer label targets shaped [N, D, H, W] unless the API reference says a raw PyTorch loss requires same-shaped targets.
  2. Dice-family MedicalZoo losses expand class-index targets to one-hot internally and normalize logits internally. Match the loss classes argument to the model output channel count.
  3. The built-in 3D trainer route expects criterion(output, target) to return (loss_tensor, per_channel_dice_like). DiceLoss, GeneralizedDiceLoss, BCEDiceLoss, and DiceLoss2D satisfy that shape of contract; scalar-only losses require a trainer adaptation owned by segmentation-workflows.
  4. create_loss(name, ...) is case-sensitive and does not expose every constructor option. Instantiate classes directly when class count, skip_index_after, tag coefficients, contrastive embeddings, or 2D Dice behavior matters.
  5. Keep targets integer-valued and on the same device as logits. Move criterion modules that carry weight buffers to the target device before CUDA checks.

Bundled smoke check

Run the bundled deterministic smoke check after making the MedicalZooPytorch package importable:

python sub-skills/losses-and-metrics/scripts/smoke_losses.py
python sub-skills/losses-and-metrics/scripts/smoke_losses.py --cuda

The script uses tiny synthetic tensors, validates tuple versus scalar return contracts, exercises representative factory/manual loss paths, and confirms unsupported factory names fail with guidance.

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