jax-models
Inspect, extend, and debug DreamerV3 neural/JAX internals: Agent, RSSM, heads, optimizers, Ninjax state, sharding, and numerics.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- jax-models
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Inspect, extend, and debug DreamerV3 neural/JAX internals: Agent, RSSM, heads, optimizers, Ninjax state, sharding, and numerics.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/debugging-numerics.md11.8 KB
- 参考文档references/jax-api-reference.md16.8 KB
- 参考文档references/model-architecture.md13.4 KB
- 参考文档references/troubleshooting.md7.8 KB
- 脚本scripts/inspect_model_config.py24.1 KB
03 SKILL.md 正文
jax-models
Use this sub-skill when the task is about DreamerV3 model internals rather than command-line training recipes, environment/replay plumbing, or operations dashboards. It covers the DreamerV3 Agent, RSSM, encoder/decoder, JAX wrapper, heads/distributions, optimizer stack, Ninjax parameter/state handling, sharding setup, loss metrics, and numerical debugging.
Read This First
- For architecture, dimensions, data flow, and model-loss behavior, read references/model-architecture.md.
- For callable APIs, JAX setup/sharding, Ninjax state contracts, heads/outs/nets/optimizer utilities, and checkpoint methods, read references/jax-api-reference.md.
- For non-finite outputs, dtype/platform/JIT/preallocation choices, loss localization, checkpoint regex loading, and LayerScan pitfalls, read references/debugging-numerics.md.
- For symptom-to-action guidance, read references/troubleshooting.md.
- To inspect a DreamerV3 YAML config or built-in config combination without constructing the full Agent, run scripts/inspect_model_config.py.
Route Here When
- You need to shrink or expand the neural model (
debug,size1m,size12m, regex override blocks, RSSM dimensions, head sizes, image encoder/decoder depths). - You need to understand
dreamerv3.agent.Agentconstruction,policy(),train(),report(),save(), orload()behavior. - You need to inspect
dreamerv3.rssm.RSSM,Encoder, orDecodershapes, carries, entries, reconstruction outputs, stochastic state, or KL losses. - You are debugging
embodied.jax.Agent,internal.setup(), sharding meshes,transform.init/apply(), Ninjax parameter names, optimizer metrics, or finite-output assertions. - You see non-finite policy outputs, XLA/JAX errors, PyTree/checkpoint mismatches, action-head shape errors, or
LayerScanstate issues.
Route elsewhere:
- CLI launch commands, config-file composition recipes, and training/evaluation scripts belong to
train-configure; this sub-skill only covers model-relevant config keys. - Environment spaces, replay chunks, driver/stream contracts, and dataset flow belong to
embodied-dataflow. - Backend installation, Docker/system package repair, logdir hygiene, and plotting/metrics dashboards belong to
results-ops.
Quick Workflows
Inspect a model config safely
From this sub-skill directory or from a copied skill tree:
python scripts/inspect_model_config.py defaults debug size1m
python scripts/inspect_model_config.py defaults --set jax.platform=cpu --set agent.dyn.rssm.deter=512
python scripts/inspect_model_config.py --config-file path/to/config.yaml
Expected output sections include JAX platform/dtype, RSSM dimensions and feature size, encoder/decoder sizes, head/distribution types, loss scales, rollout settings, and warnings. This script parses configs only; it does not create environments, instantiate Agent, allocate JAX devices, or run training.
Shrink a laptop smoke model
- Use
defaults debug size1mfor a small CPU-oriented smoke, or inspect the exact override result withscripts/inspect_model_config.pybefore launching. - Verify the final
agent.dyn.rssm.deteris divisible byagent.dyn.rssm.blocksandagent.dec.simple.bspace. - Expect checkpoint incompatibility when changing RSSM/head dimensions. Use a new logdir or a carefully chosen
load(..., regex=...)subset; read references/debugging-numerics.md.
Localize non-finite outputs or XLA failures
- Read references/debugging-numerics.md.
- Reproduce in a fresh process with CPU/debug settings:
jax.platform=cpu,jax.debug=True,jax.prealloc=False, and, when needed,jax.jit=Falseorjax.debug_nans=True. - Use
policy()finite assertions and training metrics (loss/*,opt/grad_norm,dyn_ent,rep_ent,adv*,ent/*) to locate the component. - If the error only appears during checkpoint restore or model-size changes, read the checkpoint section before editing parameter names.
Core Object Contracts
dreamerv3.agent.Agent(obs_space, act_space, config)returns theembodied.jax.Agentwrapper because the base class intercepts construction. The wrapped model is available asagent.modelon the returned object.- Policy carry shape is
(enc_carry, dyn_carry, dec_carry, prevact).init_train()andinit_report()use the same carry contract asinit_policy(). - Model training data must contain observation keys, action keys, extras (
consec,stepid, and optional replay-context entries), plus a JAX seed inserted byembodied.jax.Agent.stream()beforetrain()/report(). - RSSM feature dictionaries use
deter,stoch, andlogit. The tensor feature used by heads concatenatesdeterand flattenedstoch. - Output heads return
embodied.jax.outs.Outputobjects or dictionaries of them. Use.pred(),.loss(target),.sample(seed),.logp(event),.entropy(), and.kl(other)according to references/jax-api-reference.md.
Validation Hooks Covered
- Native utility candidate:
LayerScanapply behavior from the repo test suite is distilled into references/debugging-numerics.md. - Synthetic safe candidate: parsing
defaults debug size1mwithscripts/inspect_model_config.pycovers small-model and CPU-debug config behavior without constructing the full Agent.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).