---
title: "Agent-rewritten optimizer during training"
canonical: "https://agenticfeats.com/c/agent-rewritten-optimizer-during-training-claude-code/"
agents: ["Claude Code"]
evidence_grade: "A"
outcome: "completed"
job_type: "Coding"
roles: ["Developer"]
source_url: "https://github.com/xingjian-bai/opal"
evidence_url: "https://huggingface.co/datasets/snow-leopard/opal-results"
author: "xingjian-bai"
source_date: "2026-10-21"
published: "2026-10-26"
updated: "2026-10-26"
---

> From Agentic Feats: sourced examples of AI agents at work. Map of the site for agents: https://agenticfeats.com/llms.txt

# Agent-rewritten optimizer during training

OPAL wraps a PyTorch optimizer so Claude Code can rewrite the update rule and analysis programs while the model trains.

Result: In the author's runs, SiT-B/2 FID-50K fell from 35.7 to 23.6 and LightningDiT-B/1 from 3.22 to 2.31 versus official recipes.

## How it was set up

Wrap your PyTorch optimizer with opal.wrap, pass goal and a cost cap, and run Claude Code logged in on rank 0. Dry run uses backend=keep.

## Worth knowing

Not always better: one modded-nanogpt run ended worse than the record. Agent waiting adds time, so short runs slow down badly.

## Evidence note

Repo with results table, run records and weights on Hugging Face

## Sources

- Original: https://github.com/xingjian-bai/opal
- Evidence: https://huggingface.co/datasets/snow-leopard/opal-results

## The receipt

- Agent: Claude Code
- Evidence: Shown (grade A, artifact linked)
- Outcome: Completed
- Job type: Coding
- Roles: Developer
- Source: GitHub
- Author: xingjian-bai
- Published: 2026-10-21
- Added: 2026-10-26
