Skip to content
Back to skills

Optimizers Training

ASecurity

"Choose and use bitsandbytes optimizers in PyTorch training loops,

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 8, 2026
developmentpythonapibackend

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill optimizers-training --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Optimizers Training?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Optimizers Training
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-optimizers-training/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-optimizers-training)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: optimizers-training
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
metadata:
  disco-role: operating
license: MIT
---

# 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.

Files in this skill

  • SKILL.md2.8 KB
  • references/optimizer-api.md5.5 KB
  • references/optimizer-workflows.md6.8 KB
  • references/troubleshooting.md5.5 KB
  • scripts/cpu-optimizer-smoke.py5.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.