About jax-training-recipe
jax-training-recipe is a practical skill for planning JAX training experiments, aimed at researchers and engineers. It emphasizes explicit state and randomness, pure training steps, and a staged path from single-device debugging to scaled training.
Key features
- 01Experiment and device planning
- 02PRNG key strategy
- 03Explicit model and state design
- 04Pure train-step workflow
- 05Staged transformation and scale-up checks
Use cases
- 01Planning a JAX training experiment
- 02Debugging PRNG or tracer errors
- 03Adding jit, vmap, or pmap incrementally
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ jurgendn/ agent-skills --skill jax-training-recipeAfter installing, type/jax-training-recipein Claude Code to confirm it loaded.
Bundled filesreferences/training-recipe-details.md
Details
From the project READMEJAX Training Recipe
JAX is not PyTorch with different syntax. Functions are pure, state is explicit,
and transformations (jit, vmap, grad, pmap) compose only when the function
boundaries are clean.
For concrete config/checklist details, read references/training-recipe-details.md.
Intake
Specify:
- task, dataset, loss, and metric;
- target device: CPU, single GPU, multi-GPU, TPU;
- model framework: Flax/Linen, Equinox, or raw JAX;
- randomness needs: dropout, sampling, augmentation;
- state needs: batch norm, optimizer state, EMA, checkpointing.
Workflow
- Define the experiment and minimal data batch.
- Plan PRNG key ownership and splitting.
- Define model/state boundaries.
- Initialize model and optimizer.
- Write a pure
train_step. - Add
jitonly after the un-jitted step works. - Add
vmap/pmaponly after single-device behavior is correct. - Add checkpointing and restore tests.
- Run first-run safety checks.
- Stage rollout from tiny batch to full training.
JAX-Specific Rules
- Never reuse a PRNG key.
- Keep state explicit; do not hide mutable state in closures.
- Avoid Python side effects inside
jit. - Treat shape changes under
jitas design decisions. - Debug without
jitfirst, then re-enable transformations one at a time. - Replicate state deliberately for multi-device training.
Common Failure Modes
- Reused PRNG keys causing repeated dropout/sampling.
- Tracer errors from Python control flow or side effects.
- Batch norm/dropout state not separated from params.
- Shape mismatch under
vmaporpmap. - NaNs hidden by compiled loops.
- Checkpoints missing optimizer or batch-stat state.
Output
Return:
- experiment summary;
- PRNG strategy;
- model/state design;
- train/eval step plan;
- minimal config;
- first-run checks;
- JAX-specific failure modes;
- scale-up plan.
Comments
Markdown supported