AGENT SKILL

optimizers-training

Choose and use bitsandbytes optimizers in PyTorch training loops, including 8-bit, 32-bit, paged variants, StableEmbedding, GlobalOptimManager overrides, and optimizer-state checks.

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

01 前言 Front Matter

name
optimizers-training
license
MIT
metadata
{ "disco-role": "operating" }
description
Choose and use bitsandbytes optimizers in PyTorch training loops, including 8-bit, 32-bit, paged variants, StableEmbedding, GlobalOptimManager overrides, and optimizer-state checks.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Optimizers Training

Use this sub-skill when a user asks how to train with bitsandbytes.optim, replace a PyTorch optimizer with an 8-bit or paged optimizer, keep specific parameters in 32-bit, use StableEmbedding, or validate optimizer state after a training step.

Route First

  • For direct quantized layers, bitsandbytes.nn.Linear8bitLt, Linear4bit, quantization functions, or low-level matmul APIs, use ../quantized-modules-functions/.
  • For Hugging Face BitsAndBytesConfig, QLoRA model loading, PEFT, Accelerate, Diffusers, or FSDP-QLoRA, use ../transformers-integrations/.
  • For install/import failures, backend library loading, python -m bitsandbytes, CUDA/ROCm/XPU compatibility, or native-kernel diagnostics, use ../installation-diagnostics/.

References

  • Read references/optimizer-api.md for optimizer families, verified signatures, defaults, and state knobs.
  • Read references/optimizer-workflows.md for drop-in replacement patterns, min_8bit_size, StableEmbedding, GlobalOptimManager, paged optimizers, and validation steps.
  • Read references/troubleshooting.md when memory savings are missing, overrides do not apply, state dicts fail, CPU/GPU expectations mismatch, or paged optimizers do not behave as expected.

Bundled Script

  • Run python sub-skills/optimizers-training/scripts/cpu-optimizer-smoke.py --optimizer adam8bit --steps 3 for a tiny deterministic CPU smoke that imports bitsandbytes, trains a toy model without downloads, and reports optimizer state dtypes/devices.
  • Use --optimizer adam32bit to compare the same toy loop with a 32-bit bitsandbytes Adam optimizer.
  • Use --force-8bit-small-tensors only as a diagnostic to lower min_8bit_size for the toy model; real training should usually keep the default unless memory analysis justifies changing it.

Quick Decision Rules

  • Start with bnb.optim.Adam8bit or bnb.optim.AdamW8bit as a drop-in replacement when optimizer-state memory is a bottleneck and parameters dominate memory use.
  • Keep the default min_8bit_size=4096 unless the user understands that smaller tensors are intentionally left in 32-bit for stability and minimal savings.
  • Use bnb.nn.StableEmbedding for NLP embedding layers when training with 8-bit optimizer states.
  • Use GlobalOptimManager when embeddings, layer norm, biases, or other unstable parameters should stay 32-bit while the rest of the model uses 8-bit states.
  • Use paged optimizers only for supported accelerators and memory-pressure workflows; do not promise gains on CPU-only runs or when activations dominate memory.

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