← all repositories
thu-ml/tianshou

Tianshou v2 splits algorithms from policies and breaks backward compatibility

A PyTorch reinforcement learning library that separates learning algorithms from policies so researchers and practitioners can stay out of each other’s way.

10.9k stars Python ML FrameworksAgents
tianshou
Not currently ranked — collecting fresh signals.
star history

What it does

Tianshou is a PyTorch reinforcement learning framework built on Gymnasium that bundles dozens of algorithms—from DQN variants and PPO to offline methods like CQL and BCQ—into a single training stack. It offers a high-level API for training agents out of the box and a lower-level procedural API for researchers who prefer to dissect and reassemble algorithm internals.

The interesting bit

Version 2 is a ground-up rewrite that draws hard lines between Algorithm and Policy abstractions, and it uses the type hierarchy to separate on-policy, off-policy, and offline methods at the class level. In a field where RL frameworks often collapse these distinctions into tangled inheritance, that kind of taxonomy-first design feels almost botanical.

Key highlights

  • Targets state-of-the-art MuJoCo performance for REINFORCE, A2C, TRPO, PPO, DDPG, TD3, and SAC.
  • Supports vectorized environments (including EnvPool integration), multi-GPU training, and RNN-style actors for partially observable tasks.
  • Accepts arbitrary state and action types—dicts, custom classes—without flattening everything into plain tensors.
  • Experimental support for multi-agent RL and model-based RL.
  • Extensive documentation, type checking, and test coverage, though the PyPI release lags significantly behind the master branch.

Caveats

  • Version 2 is explicitly not backwards compatible with earlier Tianshou releases.
  • Multi-agent and model-based RL support is flagged as experimental.
  • The PyPI build is described as “far behind” master, so source installs are effectively required for current work.

Verdict

RL researchers who want a hackable, type-safe PyTorch base for prototyping will appreciate the low-level API. If you need a stable, drop-in trainer and prefer installing from PyPI without migration headaches, the v2 breaking changes and release lag may frustrate you.

Frequently asked

What is thu-ml/tianshou?
A PyTorch reinforcement learning library that separates learning algorithms from policies so researchers and practitioners can stay out of each other’s way.
Is tianshou open source?
Yes — thu-ml/tianshou is open source, released under the MIT license.
What language is tianshou written in?
thu-ml/tianshou is primarily written in Python.
How popular is tianshou?
thu-ml/tianshou has 10.9k stars on GitHub.
Where can I find tianshou?
thu-ml/tianshou is on GitHub at https://github.com/thu-ml/tianshou.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.