development-and-testing
Guide TorchRL code changes, tests, docs, CI labels, deprecations, and contributor policy for maintainer-safe edits.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- development-and-testing
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guide TorchRL code changes, tests, docs, CI labels, deprecations, and contributor policy for maintainer-safe edits.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/config-docs-and-deprecations.md5.1 KB
- 参考文档references/contributor-guidance.md4.8 KB
- 参考文档references/test-and-ci-selection.md6.1 KB
- 参考文档references/troubleshooting.md6.8 KB
- 脚本scripts/check_gpu_marker_policy.py10.6 KB
- 脚本scripts/list_relevant_tests.py12.0 KB
03 SKILL.md 正文
TorchRL Development and Testing
Use this sub-skill when the user wants to modify TorchRL code, add or change a public API, write tests, update docs or tutorials, add a benchmark, decide CI labels, handle CUDA/optional backend test markers, maintain Hydra config parity, or prepare a maintainer-quality PR.
Do not use this sub-skill as the primary source for runtime API recipes. Route API usage and debugging to the workflow sub-skills first, then return here for edit policy, testing, documentation, and CI decisions.
Immediate routing
- Environment, transform, spec, rollout, or
step_mdpimplementation details: route to the envs/transforms workflow owner, then apply this sub-skill for tests/docs. - Collector, replay buffer, storage, sampler, evaluator, distributed collection, or service-backed replay changes: route to the collector/replay workflow owner, then apply this sub-skill for backend and CI scope.
- Actor, critic, distribution, recurrent module, policy wrapper, or model component changes: route to the modules/policies workflow owner, then apply this sub-skill for TensorDict keys and coverage.
- Loss, value estimator, target updater, trainer, algorithm, SOTA script, or Hydra training config changes: route to the objectives/training workflow owner, then apply this sub-skill for parity and SOTA/docs checks.
- LLM, VLA, service registry, render/checkpoint integration, or optional serving backend changes: route to the LLM/VLA/services workflow owner, then apply this sub-skill for optional-dependency labels and isolation.
Required references
Read these in order for development tasks:
- Contributor guidance for code style, imports, TensorDict-first design, logging, timing, type hints, and compile-friendly patterns.
- Test and CI selection for focused pytest selection, GPU marker policy, optional dependency labels, SOTA smoke expectations, and helper scripts.
- Config, docs, and deprecations for Hydra config/class parity, docs reference entries, tutorials, benchmarks, and two-release deprecation policy.
- Troubleshooting when a change passes locally but fails or disappears in CI.
Safe helper scripts
scripts/list_relevant_tests.py: suggest likely test files and CI focus areas from touched paths.scripts/check_gpu_marker_policy.py: statically flag CUDA-only skip conditions that are missingpytest.mark.gpu.
Both scripts are standalone and only inspect files or paths explicitly passed to them.
Minimum maintainer checklist
Before claiming a TorchRL code change is ready:
- Confirm all new
.pyfiles start withfrom __future__ import annotations. - Keep imports module-top; no wildcard imports; use the optional-dependency exception only with a module-top
_has_<name>probe. - Use
torchrl.implement_forfor version dispatch rather than hand-rolled version checks. - Use TorchRL logging and
torchrl.timeit; do not addprint()to library code ortime.time()timing blocks. - Preserve TensorDict-first public APIs and use accurate type hints,
NestedKeyfor TensorDict keys, andLiteral[...]for fixed string modes. - Add or extend focused tests in existing test files when possible; include nested-key tests when accepting
NestedKey. - Add
pytest.mark.gputo CUDA-only tests that also use CUDA/Triton skip conditions. - Update reference docs for every new public class/function; add runnable examples in public docstrings.
- For hot paths, check compile/cudagraph friendliness and add or update a benchmark when behavior is performance-relevant.
- If a class has a Hydra
*Configcompanion, keep constructor kwargs, config fields, factory popping/forwarding, defaults, and doc cross-references in parity.
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).