losses-and-schedules
Select Optax losses, schedules, microbatching helpers, and perturbation wrappers.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- losses-and-schedules
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Select Optax losses, schedules, microbatching helpers, and perturbation wrappers.
- disable-model-invocation
- true
03 SKILL.md 正文
Losses and Schedules
Use this sub-skill when the user is deciding which objective, learning-rate schedule, or training helper to use. This route is about the scalar behavior of training, not about the optimizer pipeline itself.
Include here
- Loss families in
optax.losses: classification, regression, ranking, segmentation, KL/divergence, Fenchel-Young, contrastive, and related helpers. - Schedule families in
optax.schedules: constant, warmup, decay, one-cycle, SGDR, piecewise, joined schedules, and schedule injection. optax.contrib.reduce_on_plateauwhen the user wants a metric-driven learning-rate adjustment.- Microbatching helpers:
microbatch,micro_vmap,micro_grad,reshape_batch_axis, and accumulation helpers. - Perturbation wrappers:
make_perturbed_funand the bundled noise models.
Exclude or route elsewhere
- Ordinary optimizer selection, chaining, masking, or wrapper composition: use
core-optimization. - Projections, tree utilities, assignment, linear algebra, second order, and contrib algorithms that are not really schedule-like: use
advanced-topics.
Good questions for this route
- “Which loss fits logits vs integer labels?”
- “How do I schedule the learning rate with warmup and cosine decay?”
- “How do I accumulate gradients with microbatches?”
- “How do I add perturbations or smoothing to an objective?”
Read first
../../references/losses-and-schedules.mdfor the loss families, schedule families, and helper patterns.../../references/examples-index.mdfor notebooks that demonstrate loss/schedule and microbatching workflows.../../references/troubleshooting.mdfor label-shape, step-convention, and microbatch-accumulator issues.
Core workflow
- Identify the target family: classification, regression, ranking, segmentation, schedule, or accumulation helper.
- Verify the tensor/label convention before writing code. Many loss functions distinguish logits, probabilities, one-hot labels, and integer labels.
- Decide whether the schedule belongs directly in the optimizer, in the training loop, or in a wrapper such as
inject_hyperparams. - If the batch is too large, choose a microbatch helper before changing the objective math.
- If the user is asking for robustness or smoothing, consider whether
make_perturbed_funis the right wrapper.
Signals that this route is correct
- The user is comparing losses or asks for the “right” loss for a task.
- The user is tuning a learning-rate curve or wants warmup/decay behavior.
- The user is dealing with gradient accumulation, microbatching, or perturbation-based objective wrappers.
Common mistakes
- Feeding probabilities to a loss that expects logits.
- Mixing integer-label and one-hot conventions.
- Advancing the schedule with the wrong step index or wrong units.
- Treating microbatching as a trivial
vmapwithout checking the accumulator semantics.
Useful examples
../../references/examples-index.mdpoints togradient_accumulation.ipynb,gradient_accumulation_and_microbatching.ipynb,perturbations.ipynb,cifar10_resnet.ipynb, andcontrib/reduce_on_plateau.ipynb.
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).