Skip to content

Guide · Agent skill

How to use the Mixed Precision Training agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The mixed-precision skill is a short best-practice guide that teaches an AI agent how to run parts of a neural network's training in lower-precision numbers (FP16 or BF16). It is aimed at machine learning engineers training PyTorch models on NVIDIA GPUs who want faster or lighter training. After this guide you will know what the skill changes about the agent's behaviour, how to install it, how to phrase a request that triggers it, and what to check before relying on its output.

Mixed Precision Trainingaiming-lab/AutoResearchClaw · MIT

Quick start

  1. 1Download the ZIP. Download the mixed-precision skill ZIP from this page.
  2. 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for all projects, or into a project's .claude/skills/ folder for one project.
  3. 3Or upload in the Claude apps. In the Claude apps, go to Settings → Capabilities → Skills and upload the ZIP.
  4. 4Confirm your setup. Make sure Python with PyTorch is installed and you have an NVIDIA GPU.
  5. 5Ask a training question. Describe your model, GPU and symptom using words like training, memory, speed or fp16.
  6. 6Review the suggested changes. Check the autocast and GradScaler edits, then test them against a baseline run.

What the mixed-precision skill makes the agent do

Mixed precision training runs some of a neural network's math in lower-precision numbers so training can be faster and use less GPU memory. This skill gives the agent a checklist of standard practice for doing that with torch.cuda.amp, PyTorch's automatic mixed precision tools.

When you are optimizing training on a GPU, the agent follows the guide: it wraps the forward pass in autocast, uses a gradient scaler to prevent numerical underflow, prefers BF16 on newer NVIDIA cards, and watches for NaN gradients. The skill contains only instructions and an example code template. It does not run anything on its own.

  • Wrap the forward pass in torch.cuda.amp.autocast()
  • Use GradScaler for loss scaling
  • Prefer BF16 over FP16 on Ampere or newer GPUs (the source lists RTX 3xxx, A100 and RTX 4xxx)
  • Watch for NaN gradients and reduce the learning rate if needed
  • Do not combine amp with custom CUDA kernels unless they have been tested

Install the mixed-precision skill

Download the skill ZIP from this page and unzip it. Place the resulting mixed-precision folder in ~/.claude/skills/ to make it available across your projects, or in a project's .claude/skills/ folder to limit it to that project.

You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills. The skill's only file is SKILL.md, so there is nothing else to configure.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside your project
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP

Check what you need before you start

The guidance assumes Python with PyTorch installed, because the template uses torch.cuda.amp. It is written for an NVIDIA GPU. BF16 is recommended on Ampere or newer cards.

The skill does not help directly if you lack an NVIDIA GPU or PyTorch, so check both before you rely on it.

  • Python with PyTorch installed
  • An NVIDIA GPU for the intended use
  • BF16 recommended on Ampere or newer cards

Trigger the skill with natural requests

The skill's description says to use it when optimizing GPU performance. Its metadata also lists trigger keywords: training, gpu, memory, speed, precision, fp16 and bf16. Plain requests that use these words should bring it in.

Name the training setup you have. Mention the model, the GPU and the symptom, such as running out of memory or a NaN loss.

  • "My PyTorch training runs out of GPU memory on my RTX 4090. How can I use less memory with fp16?"
  • "Speed up this training loop on an A100 using mixed precision."
  • "My loss turns to NaN after a few hundred steps when I train with autocast. What should I check?"
  • "Should I use BF16 or FP16 for training on my Ampere GPU?"

Apply the example training loop

The skill includes a code template showing the standard autocast and GradScaler pattern. Ask the agent to adapt it to your model, dataloader, loss function and optimizer. The template as written expects those names to exist in your code.

Each step matters: zero the gradients, run the forward pass and loss inside autocast, scale the loss before backward, then step the optimizer through the scaler and update the scaler.

scaler = torch.cuda.amp.GradScaler() for batch in dataloader: optimizer.zero_grad() with torch.cuda.amp.autocast(): output = model(batch) loss = criterion(output, target) scaler.scale(loss).backward() scaler.step(optimizer) scaler.update()

Safety notes and limits

The skill runs no scripts and makes no network calls, according to its listing. It is only text instructions the agent reads. The changes it suggests to your training code are still yours to review and test.

The skill warns against combining amp with custom CUDA kernels unless they have been tested, because results can break silently. Treat any change to numerics as something to validate against a known-good baseline.

  • Runs scripts: no
  • Uses network: no
  • Test custom CUDA kernel code before combining it with amp

Tips for better results

Give the agent your actual training code, the GPU model and the exact error or symptom. Specific context gives more useful advice than a general request for speed.

If losses go NaN, the skill suggests reducing the learning rate. Change one thing at a time and compare the loss curve before and after.

  • Share the GPU model so the agent can choose between BF16 and FP16
  • Compare loss curves with and without autocast to confirm the change is safe
  • The skill cites Micikevicius et al., Mixed Precision Training, ICLR 2018, as its reference

What people use it for

  • Reducing GPU memory use so a larger batch or model fits on an NVIDIA card
  • Speeding up a PyTorch training loop on an Ampere or newer GPU
  • Diagnosing a NaN loss that appears after enabling autocast
  • Choosing between BF16 and FP16 for a training run
  • Providing the training stage of the AutoResearchClaw pipeline with a memory-efficient setup

Frequently asked questions

How do I install the mixed-precision agent skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder. You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.

What do I need to use the mixed-precision skill?

You need Python with PyTorch installed, because the template uses torch.cuda.amp, and an NVIDIA GPU for the intended use. BF16 is recommended on Ampere or newer cards.

Is the mixed-precision skill free?

The skill is licensed under MIT, as listed on this page. Check the license file in the source repository for the full terms.

Does the mixed-precision skill run code or access the internet?

No. According to its listing, the skill runs no scripts and uses no network. It contains only SKILL.md with instructions and an example code template.

Will it work without an NVIDIA GPU or with TensorFlow?

Not directly. The guidance assumes torch.cuda.amp and NVIDIA hardware, so users without an NVIDIA GPU or without PyTorch will not get direct help from it.

What should I do if my loss becomes NaN with autocast?

The skill says to watch for NaN gradients and reduce the learning rate if needed. Compare your loss curve with and without autocast to confirm the change is safe.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you train PyTorch models on NVIDIA GPUs and want a concise checklist for autocast, GradScaler, BF16 choice and NaN troubleshooting. Pick something else if you need a general-purpose tool, use non-NVIDIA hardware, or rely on custom CUDA kernels you have not tested.

Download the skill