jax-agent-training
Build and debug public single-agent skrl 2.1.0 reinforcement-learning workflows with JAX, Flax, Optax, JAX models, memories, resources, agents, trainers, checkpoints, and evaluation.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- jax-agent-training
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build and debug public single-agent skrl 2.1.0 reinforcement-learning workflows with JAX, Flax, Optax, JAX models, memories, resources, agents, trainers, checkpoints, and evaluation.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/algorithm-and-component-selection.md9.3 KB
- 参考文档references/troubleshooting.md10.9 KB
- 参考文档references/workflow-and-api.md12.0 KB
03 SKILL.md 正文
JAX single-agent training
Use this branch when the requested workflow is a single-agent skrl 2.1.0 workflow backed by JAX/Flax/Optax: A2C, CEM, DDPG, DDQN, DQN, PPO, RPO, SAC, or TD3. It covers model definition, parameter/state initialization, JAX resources and trainer composition, device and PRNG choices, and the boundary between training, checkpointing, and evaluation.
Route before building
- Select JAX installation and backend policy in
framework selection; do not infer
CUDA support from a CPU import. JAX's
jaxlibbuild and the availablejax.devices()determine the usable accelerator. - For Gymnasium/Gym, vectorization, simulator loaders, or
wrap_env, use environment integration. This skill assumes the environment is already wrapped and exposes the relevant spaces and device. - For IPPO/MAPPO, simultaneous scopes, or Runner/YAML component mapping, use multi-agent and Runner.
- Read algorithm and component selection to select model keys, mixins, memory type, and the algorithm configuration.
- Follow the workflow/API contract, then use JAX troubleshooting when a construction, initialization, device, or checkpoint check fails.
Minimal construction order
For a normal single-agent build, keep this order:
- Install the desired JAX/JAXLIB variant first, then install
skrl[jax]. The package extra supplies JAX, JAXLIB, Flax, and Optax requirements, but the public installation guidance warns that installing JAX first avoids accidentally retaining its CPU build. - Wrap the environment and take
observation_space, optionalstate_space,action_space,num_envs, anddevicefrom that wrapper. - Define Flax models as
Mixin, Modelclasses. CallModel.__init__before the mixin constructor; give every custom constructor argument a default. Implement Flax__call__(inputs, role)and return(output, {})or(output, extra_outputs). - Call
model.init_state_dict(role=<agent-model-key>)for every model before constructing or using the agent. If needed, pass explicit sampledinputsand a JAX PRNGkey; otherwise initialization samples each declared space using the model device andconfig.jax.key. - Create
RandomMemoryfor rollouts or replay data when the algorithm needs memory. Instantiate the algorithm's*_CFG, set experiment/resource fields, and construct the JAX agent with the exact model dictionary keys. - Construct
SequentialTrainerfor the ordinary loop orStepTrainerwhen the caller owns one-step train/eval iteration. Call the trainer only after the component/init smoke passes; this branch's bundled script deliberately does not train. - During evaluation, use the agent checkpoint rather than only a raw model when optimizers or preprocessors matter. Set logging/checkpoint intervals to zero for a no-output evaluation smoke.
Bundled safe check
From the generated skill root, run:
python sub-skills/jax-agent-training/scripts/jax_ppo_components.py --help
python sub-skills/jax-agent-training/scripts/jax_ppo_components.py
The helper constructs a small CPU Pendulum PPO stack, initializes Flax state,
creates the JAX memory and PPO agent, initializes a sequential trainer, and
performs one model action/value-shape check. It does not call train() or
eval(), download anything, import a source checkout, create checkpoints, or
write persistent output.
Scope boundary
This branch does not own generic framework routing, environment installation or wrapping, Torch/Warp APIs, IPPO/MAPPO, Runner YAML, or external simulator execution. Keep those decisions in the linked sibling/root skills. See the root troubleshooting guide for cross-framework failures and the sibling skills for their own framework or multi-agent contracts.
Evidence basis
Claims in this branch are distilled from the public skrl 2.1.0 JAX package APIs, JAX model/agent/resource documentation, the maintained Gymnasium Pendulum PPO construction example, JAX configuration tests, JAX model-instantiator tests, and the installed public signatures. The exact evidence map and unresolved backend limits are recorded in the branch handoff outside this runtime tree.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.