wrappers-recording
Apply, inspect, author, and troubleshoot Gymnasium single-environment wrappers, recording helpers, and rendering helpers.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- wrappers-recording
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Apply, inspect, author, and troubleshoot Gymnasium single-environment wrappers, recording helpers, and rendering helpers.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/custom-wrappers.md5.4 KB
- 参考文档references/recording-and-rendering.md4.8 KB
- 参考文档references/troubleshooting.md5.6 KB
- 参考文档references/wrapper-catalog.md8.2 KB
- 脚本scripts/wrapper_smoke.py6.8 KB
03 SKILL.md 正文
Gymnasium Wrappers and Recording
Use this sub-skill when a task needs single-environment Gymnasium wrappers: applying wrapper chains, inspecting wrapped environments, writing custom wrappers, recording episode statistics or videos, and diagnosing wrapper or render-mode failures.
Start Here
- Build the base environment with
gymnasium.make(...); most made environments already includeTimeLimit<OrderEnforcing<PassiveEnvChecker<...>>>unless the spec/options disable parts of that stack. - Add wrappers outside-in:
env = Wrapper(env, ...); the last wrapper assigned is the first object the agent interacts with. - Inspect
envfor the full chain,env.envfor the next inner layer, andenv.unwrappedfor the original base environment. - After any wrapper that changes observations or actions, verify
env.observation_space,env.action_space,reset(), and onestep()agree. - Use
RecordEpisodeStatisticsfor lightweight metrics; addRecordVideoonly when the environment was created with image-returning rendering such asrender_mode="rgb_array"andmoviepyis installed.
Route by Task
| Task | Read |
|---|---|
| Choose or order built-in wrappers | references/wrapper-catalog.md |
| Record episode returns, lengths, videos, or render frames | references/recording-and-rendering.md |
Write Wrapper, ObservationWrapper, ActionWrapper, or RewardWrapper subclasses |
references/custom-wrappers.md |
| Diagnose wrapper order, changed spaces, render/video, image wrapper, Atari, or array conversion errors | references/troubleshooting.md |
| Prove a local wrapper chain works | scripts/wrapper_smoke.py |
Common Patterns
import gymnasium as gym
from gymnasium.wrappers import FlattenObservation, RecordEpisodeStatistics, TimeLimit
env = gym.make("CartPole-v1")
env = TimeLimit(env, max_episode_steps=200)
env = FlattenObservation(env)
env = RecordEpisodeStatistics(env)
obs, info = env.reset(seed=123)
obs, reward, terminated, truncated, info = env.step(env.action_space.sample())
import gymnasium as gym
from gymnasium.wrappers import RecordVideo
env = gym.make("CartPole-v1", render_mode="rgb_array")
env = RecordVideo(env, video_folder="videos", episode_trigger=lambda episode: True)
Boundaries
- For vector environments and
gymnasium.wrappers.vector, use../vectorization/SKILL.md. - For detailed
Spaceconstructor, flattening, dtype, andcontainsguidance, use../spaces-data/SKILL.md. - For environment registration,
check_env, and customEnvlifecycle, use../environment-api/SKILL.md. - For built-in environment family extras such as Box2D, MuJoCo, Atari/ALE IDs, or Toy Text action masks, use
../builtin-envs/SKILL.md.
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).