gymnasium
Use Gymnasium for reinforcement-learning environment loops, spaces, wrappers, vectorized envs, built-in environment families, and Gym-to-Gymnasium migration.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- gymnasium
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use Gymnasium for reinforcement-learning environment loops, spaces, wrappers, vectorized envs, built-in environment families, and Gym-to-Gymnasium migration.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/installation-and-extras.md3.0 KB
- 参考文档references/repo-provenance.md1.7 KB
- 参考文档references/repo-routing-metadata.json334 B
- 参考文档references/troubleshooting.md5.0 KB
- 脚本scripts/gymnasium_smoke.py3.4 KB
03 SKILL.md 正文
Gymnasium
Use this repo skill when a task involves Gymnasium's reinforcement-learning environment API: creating Env loops, authoring custom environments, selecting action/observation spaces, applying wrappers, recording episodes, vectorizing envs, choosing built-in environments, or migrating older Gym code.
Quick Start
import gymnasium as gym
env = gym.make("CartPole-v1")
try:
obs, info = env.reset(seed=123)
terminated = truncated = False
while not (terminated or truncated):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
finally:
env.close()
If a task only needs an install/import sanity check, run the bundled smoke helper:
python scripts/gymnasium_smoke.py --help
python scripts/gymnasium_smoke.py
Route by Task
| User task | Read |
|---|---|
Basic gym.make, reset, step, render, custom Env, registration, EnvSpec, check_env, seeding, or old Gym migration |
sub-skills/environment-api/SKILL.md |
Design action_space/observation_space, debug contains, flatten/unflatten observations, JSONable conversion, dtype/shape issues |
sub-skills/spaces-data/SKILL.md |
| Apply wrapper chains, write custom wrappers, record videos/statistics, use render helpers, troubleshoot wrapper order or media dependencies | sub-skills/wrappers-recording/SKILL.md |
Use gym.make_vec, SyncVectorEnv, AsyncVectorEnv, batched actions/infos/masks, autoreset modes, vector wrappers, multiprocessing issues |
sub-skills/vectorization/SKILL.md |
| Choose Classic Control, Toy Text, Box2D, MuJoCo, Atari/ALE, optional extras, versioned IDs, action masks, render modes | sub-skills/builtin-envs/SKILL.md |
Install and Extras
Start with the base package unless the selected environment family or wrapper explicitly needs an extra:
pip install gymnasium
Read references/installation-and-extras.md before installing optional dependencies. Prefer the smallest matching extra, such as gymnasium[classic-control], gymnasium[toy-text], gymnasium[box2d], gymnasium[mujoco], gymnasium[atari], or gymnasium[other], instead of gymnasium[all] in ordinary agent tasks.
API Rules That Prevent Most Bugs
Env.reset(seed=..., options=...)returns(observation, info); seed throughreset, notenv.seed(...).Env.step(action)returns(observation, reward, terminated, truncated, info); useterminated or truncatedto end an episode, but useterminatedalone for value bootstrapping decisions.- Pass render mode to
gym.make(..., render_mode="rgb_array")or"human"; do not call oldenv.render(mode=...)code. - Sample vector-environment actions from
envs.action_space, notenvs.single_action_space, unless you are building the full action batch yourself. - Inspect registered IDs with
gym.spec(...),gym.registry, orgym.pprint_registry()before guessing environment names.
Cross-cutting Troubleshooting
Use references/troubleshooting.md for package-level issues such as import confusion, old Gym migration, missing optional extras, invalid environment IDs, render/video failures, checker warnings, vectorization mistakes, and wrapper/space mismatches.
Provenance
This skill was generated from the Gymnasium source state recorded in references/repo-provenance.md. If the source repository changes, refresh this skill before relying on exact API, wrapper, or optional-dependency details.
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).