envs-and-transforms
Build, validate, transform, vectorize, and debug TorchRL environments and TensorDict transition layouts.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- envs-and-transforms
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build, validate, transform, vectorize, and debug TorchRL environments and TensorDict transition layouts.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/env-workflows.md10.0 KB
- 参考文档references/optional-env-backends.md5.8 KB
- 参考文档references/transform-reference.md7.2 KB
- 参考文档references/troubleshooting.md6.9 KB
- 脚本scripts/smoke_env_rollout.py2.8 KB
03 SKILL.md 正文
TorchRL envs-and-transforms
Load this sub-skill when the task involves TorchRL environments, transformed environments, vectorized environments, environment specs, optional simulator wrappers, or the TensorDict transition layout produced by EnvBase.step and consumed by step_mdp.
Use this skill for
- Building CPU-safe native environments such as
PendulumEnvand customEnvBasesubclasses. - Wrapping Gym/Gymnasium and other simulator backends with TorchRL environment wrappers.
- Adding
TransformedEnv,Compose,ObservationNorm,StepCounter,ActionScaling, image transforms, reward transforms, action transforms, and key transforms. - Checking and debugging
observation_spec,action_spec,reward_spec,done_spec,input_spec, andoutput_specwithcheck_env_specs. - Moving a transition from root +
"next"layout to the next-step root layout withstep_mdp. - Choosing
SerialEnvversusParallelEnv, debugging vectorized worker issues, and validating specs before multiprocessing. - Reasoning about multi-agent environment grouping and nested per-agent specs.
- Routing optional simulator, rendering, and pixel dependencies without claiming they are verified in a base CPU environment.
Route away
- Policy, actor, critic, distribution, recurrent module, or network construction: use
modules-and-policies. - Collectors, replay buffers, samplers, writers, or data-collection topology: use
collectors-and-replay. - PPO/SAC/DQN/objective wiring, value estimators, target updates, trainers, Hydra configs, or SOTA recipes: use
objectives-and-training. - VLA-specific action chunk training targets and service-backed robot/LLM workflows: use
llm-vla-and-services. GenericActionChunkTransformkey semantics are summarized here only to route safely.
Fast operating path
- Pick the smallest environment surface: native
PendulumEnvor a customEnvBasefor core TorchRL behavior; wrapper classes only when the simulator dependency is installed. - Inspect specs before writing policy or collector code. Validate with
check_env_specs(env, ...)offline because it runs a short rollout and may reset seeding state. - Add transforms with explicit
in_keys,out_keys,in_keys_inv, andout_keys_inv; verify transformed specs and useclone()before reusing a transform already attached to another env. - Run a tiny rollout, inspect root keys and
("next", ...)keys, then usestep_mdpwith the env'sreward_keys,done_keys, andaction_keyswhen keys are nested or multi-agent. - Debug in one process with
SerialEnv; move toParallelEnvonly after the same factory passescheck_env_specs. - For optional Gym/Gymnasium, MuJoCo, DM Control, IsaacLab, VMAS, PettingZoo, OpenSpiel, Brax, Jumanji, rendering, or pixel stacks, follow the optional-backend checklist before treating failures as TorchRL bugs.
References
- Environment workflows: construction, specs, rollout,
step_mdp, vectorization, multi-agent layouts. - Transform reference:
TransformedEnv,Compose, key routing, normalization, action scaling, and action chunk routing. - Optional environment backends: Gym/Gymnasium and simulator extras, rendering, and backend-specific cautions.
- Troubleshooting: common failure signatures and fixes.
Safe smoke helper
Run scripts/smoke_env_rollout.py in an environment where torchrl, torch, and tensordict import. From this sub-skill directory:
python scripts/smoke_env_rollout.py --steps 3 --check-specs
From another working directory, pass the actual local path of this sub-skill's scripts/smoke_env_rollout.py copy to Python.
Expected signal: concise success text showing the TorchRL version, rollout batch size, and step_mdp keys. The helper uses only native PendulumEnv, TransformedEnv, StepCounter, check_env_specs, and step_mdp; it does not require Gym, rendering, multiprocessing, or GPUs.
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).