tianshou
Use Tianshou 2.0.1 for PyTorch/Gymnasium deep reinforcement learning experiments, custom procedural training, data collection, vectorized environments, offline RL, multi-agent RL, and evaluation workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- tianshou
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use Tianshou 2.0.1 for PyTorch/Gymnasium deep reinforcement learning experiments, custom procedural training, data collection, vectorized environments, offline RL, multi-agent RL, and evaluation workflows.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/evaluation-and-benchmarks.md2.6 KB
- 参考文档references/installation-and-routing.md3.1 KB
- 参考文档references/repo-provenance.md1.8 KB
- 参考文档references/repo-routing-metadata.json514 B
- 参考文档references/troubleshooting.md4.3 KB
- 脚本scripts/check_tianshou_install.py3.6 KB
03 SKILL.md 正文
Tianshou
Use this repo skill when a user asks for Tianshou, tianshou, PyTorch + Gymnasium reinforcement learning, high-level ExperimentBuilder workflows, procedural policy/algorithm/trainer wiring, replay buffers and collectors, vectorized environments, offline RL, imitation learning, model-based/curiosity wrappers, multi-agent RL, or Tianshou evaluation helpers.
Start Here
- Confirm
tianshouimports and the requested environment/backend extras are installed. - Choose the narrowest sub-skill route below before writing code.
- Keep first runs bounded: CPU,
DummyVectorEnv, tiny step counts, no rendering, no downloads, and no benchmark-scale training unless the user explicitly asks. - Use the bundled scripts for safe import/construction smokes before long training or optional backend work.
- If a task spans routes, use the primary workflow sub-skill first and cross-link for buffers, envs, or evaluation details.
Route Map
- Use
sub-skills/highlevel-experiments/SKILL.mdfor declarative builder workflows:ExperimentBuilder,DQNExperimentBuilder,PPOExperimentBuilder,ExperimentConfig, training configs, algorithm params dataclasses, persistence/watch/logging, and quick applied-RL skeletons. - Use
sub-skills/procedural-training/SKILL.mdfor manual low-level wiring: Gymnasium envs, networks, policies, algorithms, optimizer factories, collectors, replay buffers,OffPolicyTrainerParams,OnPolicyTrainerParams, and custom algorithm or policy research. - Use
sub-skills/data-collection/SKILL.mdforBatch,ReplayBuffer,VectorReplayBuffer, prioritized/HER buffers,Collector,AsyncCollector, hooks, n-step/return data, stats, shape issues, and malformed buffer debugging. - Use
sub-skills/envs-and-vectorization/SKILL.mdfor Gymnasium/PettingZoo wrappers,DummyVectorEnv,SubprocVectorEnv,RayVectorEnv, EnvPool-style integration, action masks, seeding/reset/close behavior, and optional engines such as Atari, Box2D, MuJoCo, VizDoom, robotics, or Ray. - Use
sub-skills/offline-and-specialized-rl/SKILL.mdfor CQL/BCQ/TD3+BC, imitation/GAIL, PSRL, ICM wrappers, multi-agent algorithm wrappers,JoblibExpLauncher, rliable evaluation, and benchmark planning.
Common Route Signals
| User asks about | Route |
|---|---|
| "quick DQN CartPole with Tianshou", "builder", "high-level API" | sub-skills/highlevel-experiments/SKILL.md |
| "custom policy", "manual PPO/SAC", "trainer params", "network wiring" | sub-skills/procedural-training/SKILL.md |
| "Batch slicing", "ReplayBuffer sample", "Collector.collect", "n-step returns" | sub-skills/data-collection/SKILL.md |
| "SubprocVectorEnv", "PettingZooEnv", "action mask", "MuJoCo install", "EnvPool" | sub-skills/envs-and-vectorization/SKILL.md |
| "offline dataset", "CQL", "GAIL", "PSRL", "multi-agent", "rliable" | sub-skills/offline-and-specialized-rl/SKILL.md |
Cross-Cutting References
references/installation-and-routing.mdsummarizes package setup, optional extras, API-level choice, and smoke commands.references/troubleshooting.mdcovers install/import, optional dependency, data/config, CLI/API misuse, and workflow failure patterns shared across sub-skills.references/evaluation-and-benchmarks.mdexplains safe evaluation, multi-seed launchers, rliable outputs, and benchmark-scale guardrails.references/repo-provenance.mdrecords the source commit, version, dirty state, and evidence paths used to generate this skill.references/repo-routing-metadata.jsonis structured metadata consumed by DisCo'srepo-skills-routerimport.scripts/check_tianshou_install.pyperforms a safe import/API smoke for installed Tianshou without training, downloads, or source checkout reads.
Safe Smoke Commands
python skills/tianshou/scripts/check_tianshou_install.py
python skills/tianshou/sub-skills/highlevel-experiments/scripts/check_highlevel_cartpole.py
python skills/tianshou/sub-skills/procedural-training/scripts/check_procedural_dqn_components.py
python skills/tianshou/sub-skills/data-collection/scripts/check_batch_buffer_collector.py
python skills/tianshou/sub-skills/envs-and-vectorization/scripts/check_vector_env.py --num-envs 2 --steps 4
python skills/tianshou/sub-skills/offline-and-specialized-rl/scripts/check_offline_api_imports.py --strict --no-include-optional
Guardrails
- Do not run Atari, MuJoCo, Box2D, VizDoom, robotics, EnvPool, Ray, D4RL, benchmark, or multi-seed workflows until their optional dependencies and data/assets are explicitly available.
- Do not treat benchmark examples as smoke tests; reduce to imports, constructors, tiny envs, tiny buffers, or one-seed dry checks first.
- Do not use high-level builders when the user needs custom collector hooks, replay-buffer internals, custom training loops, or algorithm research; route to the procedural and data sub-skills.
- Keep generated code version-aware: Tianshou v2 separates
AlgorithmandPolicy, uses builder/config dataclasses in the high-level API, and is not backwards-compatible with v1 parameter names.
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).