embodied-dataflow
Build and troubleshoot DreamerV3 Embodied Env, Agent, Driver, Replay, Stream, wrapper, and custom environment dataflow contracts.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- embodied-dataflow
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build and troubleshoot DreamerV3 Embodied Env, Agent, Driver, Replay, Stream, wrapper, and custom environment dataflow contracts.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-contracts.md12.2 KB
- 参考文档references/env-integration.md10.8 KB
- 参考文档references/replay-and-streams.md12.3 KB
- 参考文档references/troubleshooting.md10.6 KB
- 脚本scripts/check_embodied_contracts.py13.5 KB
03 SKILL.md 正文
Embodied Dataflow for DreamerV3
Use this sub-skill when a task is about the Embodied runtime layer that feeds
DreamerV3: environment adapters, custom Env contracts, Agent.policy() data
shapes, Driver stepping/callbacks, replay insertion/sampling, streams, and
wrappers. It is intentionally safe: it documents and checks data contracts, not
training quality.
Route here for
- Building or validating a custom
embodied.Envadapter. - Explaining why
act_spacemust includereset, why observations needreward,is_first,is_last, andis_terminal, or whylog/keys do not reach the policy. - Wiring
Driver(...).on_step(...)callbacks into replay with stable worker ids. - Debugging replay samples, selectors, chunk save/load, stream composition, and sequence contiguity.
- Choosing and ordering wrappers such as
NormalizeAction,ClipAction,UnifyDtypes,CheckSpaces,DiscretizeAction,ResizeImage,TimeLimit, andRestartOnException. - Using the safe dummy environment as a contract example before attempting optional Atari, Crafter, DMC, DMLab, Gym, Minecraft, ProcGen, PinPad, or BSuite integrations.
Route elsewhere
- CLI flags,
configs.yaml, run-loop selection, logging/checkpoints, and train smoke commands belong to sibling sub-skilltrain-configure. - JAX, Ninjax, DreamerV3 model internals, optimizer state, sharding, and neural
module debugging belong to sibling sub-skill
jax-models. - Installation, CUDA/system packages, optional environment dependency setup,
Docker, plotting, score files, and metrics operations belong to sibling
sub-skill
results-ops.
Fast operating path
-
Read references/api-contracts.md before implementing or reviewing any
Env,Agent,Driver,Replay, orStreamcode. It contains the exact key, shape, callback, and sample/update contracts. -
Read references/env-integration.md when adding a built-in or custom environment adapter, selecting wrappers, or deciding which optional dependency boundary applies.
-
Read references/replay-and-streams.md when replay sampling is empty, samples appear non-contiguous, priorities are updated, chunks are saved/loaded, or stream combinators are used.
-
Read references/troubleshooting.md when an error mentions
reset,CheckSpaces, dtype/shape bounds, parallel workers, replay waiting, optional environment imports, or stream assertions. -
Run scripts/check_embodied_contracts.py as a local contract smoke before training. It supports:
python scripts/check_embodied_contracts.py --help python scripts/check_embodied_contracts.py --all python scripts/check_embodied_contracts.py --mode env python scripts/check_embodied_contracts.py --mode replay python scripts/check_embodied_contracts.py --mode driver python scripts/check_embodied_contracts.py --mode env --factory my_pkg.envs:make_envThe checker uses a tiny dummy-like environment by default and can validate a user-provided zero-argument environment factory. It does not train.
Common recipes
Custom environment preflight
- Implement
obs_space,act_space,step(action), andclose(). - Include
act_space['reset'] = elements.Space(bool)even if the wrapped backend resets internally. - Return
reward,is_first,is_last, andis_terminalon every step. - Make
step({'reset': True, ...})return the first observation of a new episode withis_first=True,is_last=False, and reward normally0.0. - Wrap with
UnifyDtypesand thenCheckSpacesduring debugging. - Run the bundled checker in
envmode before connecting a policy or replay.
Driver to replay wiring
import embodied
from embodied.envs import dummy
def make_env():
return dummy.Dummy('disc', length=100)
env0 = make_env()
agent = embodied.RandomAgent(env0.obs_space, env0.act_space)
env0.close()
replay = embodied.Replay(length=16, capacity=1000)
driver = embodied.Driver([make_env, make_env], parallel=False)
driver.reset(agent.init_policy)
driver.on_step(lambda tran, worker: replay.add(tran, worker=worker))
driver(agent.policy, steps=64)
batch = replay.sample(batch=4, mode='train')
assert batch['is_first'].shape[:2] == (4, 16)
Keep the callback worker id when adding to replay. Worker ids keep sequences
from separate environment streams from crossing.
Native verification candidates owned by this sub-skill
Use these as final native candidates after the whole DreamerV3 skill is integrated and its verification plan allows native tests:
embodied/tests/test_driver.py::TestDriver::test_episode_length: driver reset/episode-length semantics on the dummy environment.embodied/tests/test_replay.py::TestReplay::test_sample_single: replay single-worker contiguous sequence sampling.- Optional if resources allow:
embodied/tests/test_parallel.py, because it exercises parallel run-loop dataflow and save/load behavior but is longer and depends on additional runtime services.
Do not run those native tests while merely using this runtime sub-skill; use the bundled checker for quick contract preflight.
Known limits
- Optional environment adapters can require external packages, ROMs, system
libraries, display/Mujoco setup, or Java/MineRL resources. This sub-skill only
defines the dataflow contract and adapter boundaries; setup belongs to
results-ops. - The checker validates contract shape and safe replay/driver mechanics. It does not prove training performance, JAX model correctness, or distributed run-loop behavior.
- For environments with unusual constructor arguments, expose a small
zero-argument factory and pass it via
--factory module:callableto the checker.
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).