training
Run and troubleshoot DreamerV2 2.2.0 training through the native module runner or public Python API, including GPU-era runtime gates, replay/checkpoint/log lifecycle, bounded debug runs, and safe resume planning.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- training
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Run and troubleshoot DreamerV2 2.2.0 training through the native module runner or public Python API, including GPU-era runtime gates, replay/checkpoint/log lifecycle, bounded debug runs, and safe resume planning.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/api-reference.md7.4 KB
- 参考文档references/troubleshooting.md10.0 KB
- 参考文档references/workflows.md8.8 KB
03 SKILL.md 正文
DreamerV2 training
Use this route when the task is to launch, bound, resume, or diagnose a
DreamerV2 training run. It covers the built-in python -m dreamerv2.train
workflow and dreamerv2.api.train(env, config, outputs=None). It does not
replace the environment schema, full configuration catalog, or plotting
routes:
- Environment construction, wrappers, observation/action keys, and external suite assets: environments.
- Presets, typed flags, dotted overrides, and complete config values: configuration.
- JSONL/TensorBoard inspection, plotting, and run comparison: evaluation.
Choose the entry point
| Need | Entry point | Important boundary |
|---|---|---|
| DMC, Atari, or Crafter training | python -m dreamerv2.train |
Requires a visible TensorFlow GPU and the selected suite/assets. |
| Custom Gym environment object | dreamerv2.api.train(env, config, outputs=None) |
Uses the caller's legacy Gym environment; it has no native GPU assert. |
| Import/config/help check | python -m dreamerv2.train --help or a small Python process |
Does not prove environment or training readiness. |
| Installed console command | Do not use dreamerv2 for this release |
Its launcher-relative configs.yaml lookup is broken. |
Read workflows before any run and
troubleshooting when a run fails. Use a
writable, disposable logdir; the YAML placeholder /dev/null is not a run
location.
Minimum safe procedure
- Confirm the package/runtime pair before allocating a long run. The native runner is from the TensorFlow 2.6-era stack and uses legacy mixed-precision APIs; pin a coherent compatible environment rather than mixing modern TensorFlow Probability with old TensorFlow.
- Validate the environment separately. For native tasks, use a valid
suite_tasksuch asdmc_walker_walk,atari_pong, orcrafter_reward. For a custom environment, pass the raw legacy Gym object to the API and let its wrappers run; route the schema check to environments. - Compose presets and overrides before training. Put
debuglast, set an explicit--precision 32when mixed precision is not verified, and use--envs_parallel nonefor the source snapshot's reliable serial path. - Create and test the log directory, then start with a bounded step target.
Watch replay counts and the first checkpoint before increasing
steps. - Stop on NaN/Inf losses, repeated empty-replay errors, OOM, or permission
errors. Preserve
config.yaml,metrics.jsonl, replay files, andvariables.pklfor diagnosis; do not call a partial run successful.
Native runner contract
python -m dreamerv2.train \
--logdir "$RUN_DIR" \
--configs atari debug \
--task atari_pong \
--steps 1200 \
--precision 32 \
--envs_parallel none
The runner loads defaults, applies --configs left to right, then parses
ordinary dotted flags. It creates the logdir and writes the effective
config.yaml before TensorFlow's GPU assertion. It then creates
train_episodes/ and eval_episodes/, fills replay, constructs datasets and
an Agent, pretrains or loads it, alternates evaluation and collection, and
saves variables.pkl after each collection block. steps is the environment
counter; logged steps are multiplied by action_repeat.
The command above is a bounded shape of a native run, not a promise that Atari
ROMs or a GPU are installed. Do not run it until the native prerequisites pass.
The source snapshot also has a typo in the asynchronous branch that references
eval_envs while constructing evaluation workers. Keep --envs_parallel none
unless that branch has been patched and independently checked.
Public API contract
import dreamerv2.api as dv2
config = dv2.defaults.update({
'logdir': 'runs/custom/1',
'prefill': 12,
'pretrain': 1,
'replay.minlen': 5,
'replay.maxlen': 5,
'dataset.length': 5,
'dataset.batch': 2,
'steps': 15,
'eval_every': 5,
'train_every': 1,
'log_every': 5,
'time_limit': 5,
'precision': 32,
})
dv2.train(env, config) # returns None; persists run artifacts in logdir
env must be the raw legacy Gym object. The API applies
GymWrapper -> ResizeImage -> OneHotAction for discrete actions or
NormalizeAction for continuous actions -> TimeLimit. Do not pre-wrap it;
use the sibling environment skill for lifecycle keys and action bounds.
outputs=None installs terminal, JSONL, and TensorBoard outputs. A truthy
custom list must contain logger callables that accept the buffered metric list;
for example, a JSONL-only output can avoid video encoder dependencies.
The API path creates config.yaml, train_episodes/, metrics/events as they
are flushed, and variables.pkl after each eval_every collection block. It
has no evaluation environment or eval_episodes/ directory, does not set the
TensorFlow GPU policy, and does not apply the CLI's precision or jit global
setup. A CPU API call may be useful for a carefully bounded compatibility
experiment, but it is not equivalent native-training verification.
Lifecycle and resume rules
A replay episode is accepted only when its effective length is at least
replay.minlen; eplen is the number of actions minus one. The dataset also
needs a valid sequence of dataset.length. Prefill is a target based on
existing replay steps, not a guarantee that usable sequences exist. A short or
never-ending custom episode can therefore leave replay empty and fail at the
first next(dataset).
variables.pkl contains pickled model/module variables, not replay, config, or
an authoritative step counter. The runner reconstructs the counter from
train_episodes/*.npz and loads the checkpoint only after a dataset batch has
built the variables. Resume only when the restored config.yaml, model shapes,
precision/runtime, and replay schema agree. If a checkpoint exists but replay
has too few valid sequences, lower compatible sequence thresholds only after
checking the saved config or collect enough new complete episodes by setting a
larger prefill target; never fabricate replay or treat a checkpoint-only copy
as a complete resume.
For exact artifact fields, command recipes, API details, and failure recovery, open the three bundled references. Stop before a long run if any required backend or external environment is unresolved.
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).