agentleFS
strikersamstrikersam/autonomous-ai-agency/.agents/skills/checkpoint-strategy/SKILL.md

checkpoint-strategy

Skill9 starsChanged 3 months agoMITView on GitHub

"Checkpointing feels like overhead until you need it. Then it's the only thing that matters. Save more often than you think you need to, in at least two formats." Key lessons: 1. Step-based checkpointing > epoch-based — LLM epochs are often thousands of hours 2. Save optimizer state — resuming without optimizer state restarts Adam's momentum from zero 3. Rolling window — keep last N checkpoints, not just the best; spikes happen after "best" 4. Two formats — full checkpoint…

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After a loss spike — determine best checkpoint to resume from

    line 9

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: checkpoint-strategy

Purpose

Design and validate checkpointing strategies for LLM training runs. One of the most painful lessons from building LLMs from scratch: losing 12 hours of compute to a spike you can't roll back from.

Trigger

Use when:

  • Starting a new training run (set checkpointing policy upfront)
  • After a loss spike — determine best checkpoint to resume from
  • Evaluating storage vs safety tradeoffs for checkpoint frequency
  • Migrating training across hardware or cloud providers

Background

From practitioners:

"Checkpointing feels like overhead until you need it. Then it's the only thing that matters. Save more often than you think you need to, in at least two formats."

Key lessons:

  1. Step-based checkpointing > epoch-based — LLM epochs are often thousands of hours
  2. Save optimizer state — resuming without optimizer state restarts Adam's momentum from zero
  3. Rolling window — keep last N checkpoints, not just the best; spikes happen after "best"
  4. Two formats — full checkpoint for resuming, sharded for fast loading at inference
  5. Validate before deleting — always verify a checkpoint loads before removing older ones

Usage

/checkpoint-strategy [total_steps] [step_duration_seconds] [storage_budget_gb] [--model_size_gb N]

Checkpoint Policy Templates

Conservative (Recommended for First Runs)

checkpoint_policy:
  frequency: every_500_steps
  keep_last: 10
  keep_milestone: [1000, 5000, 10000, 25000, ...]  # powers of 2 * 1000
  save_optimizer: true
  save_formats:
    - full_state_dict    # for resuming
    - safetensors        # for inference/sharing
  validate_on_save: true
  async_save: true       # don't block training

Aggressive (Long Runs with Stable Training)

checkpoint_policy:
  frequency: every_2000_steps  
  keep_last: 5
  keep_milestone: [10000, 50000, 100000]
  save_optimizer: true
  emergency_save_on: 
    - loss_spike_detected    # triggers immediate save before rollback
    - gradient_norm_exceeded

Storage Estimation

checkpoint_size ≈ model_params * 4 bytes (fp32) * 3  # weights + optimizer (2x for Adam)
Example: 1B param model ≈ 1B * 4 * 3 = 12GB per checkpoint

With keep_last=10:  120GB
With milestones:    add ~60GB
Total budget:       ~180GB for 1B model

Recovery Playbook

After a Loss Spike

1. DO NOT stop training immediately — wait 50-100 steps to see if it self-recovers
2. If not recovering:
   a. Identify last stable checkpoint (loss < spike_value * 1.1)
   b. Load that checkpoint (weights + optimizer state)
   c. Reduce LR by 50% for next 500 steps
   d. Skip or reshuffle the data batch that caused the spike
   e. Resume with gradient clipping set tighter (0.5 instead of 1.0)

Resuming Across Hardware

1. Save as full state dict (not FSDP shards — these are hardware-specific)
2. Re-shard on new hardware after loading
3. Verify optimizer state loaded: check that loss continues smoothly from where it left off
   (sudden drop suggests optimizer reset)

Output Format

=== Checkpoint Strategy Report ===
Total Steps:        [N]
Step Duration:      [seconds]
Total Training Time:[hours]
Storage Budget:     [GB]
Model Size:         [GB]

Recommended Policy:
  Frequency:        every [N] steps ([hours] apart)
  Keep Last:        [N] checkpoints ([GB] rolling)
  Milestone Steps:  [list]
  Total Storage:    [GB] estimated

Risk Assessment:
  Max Data Loss on Failure: [hours] of training
  Recovery Options:         [N] rollback points

Warnings:
  - [any issues with proposed strategy]

Integration Points

  • Pairs with training-stability-monitor — spike detection can trigger emergency checkpoint
  • Pairs with session-handoff — checkpoint metadata should be included in handoffs
  • Pairs with release-readiness — checkpoint validation before model release

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.