Open-source project
gwthomas/IQL-PyTorch avatar
gwthomas/IQL-PyTorch

IQL-PyTorch: A Minimal PyTorch Port of Implicit Q-Learning for Offline RL

A PyTorch implementation of Implicit Q-Learning

101 stars15 forksPythonMIT

At a glance

What is it?
gwthomas/IQL-PyTorch is a compact PyTorch implementation of Implicit Q-Learning, aimed at researchers who need a PyTorch alternative to the official JAX code. It matches the original paper's performance on most D4RL MuJoCo tasks, with a few caveats.
Who is it for?
Adopt IQL-PyTorch if you are a PyTorch user working on offline RL and need a small, readable baseline for D4RL MuJoCo tasks. Do not use it if you require the exact official algorithm details or need support for environments beyond the included MuJoCo locomotion suite.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Probably not. The repository last received commits 60 months ago, on October 23, 2021.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 4, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • gwthomas/IQL-PyTorch101 ★ · +1
Star history
Repository2026-08-182026-10-04
gwthomas/IQL-PyTorch100101

1 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What IQL-PyTorch Solves and Who It Is For

Implicit Q-Learning (IQL) is an offline reinforcement learning algorithm that learns a policy from a fixed dataset without interacting with the environment. The official implementation from the paper's authors is written in JAX, which is a barrier for researchers and engineers who standardize on PyTorch. IQL-PyTorch fills that gap with a minimal, single-script implementation. The intended audience is a PyTorch user who wants to run IQL on D4RL benchmark tasks, either to reproduce published numbers or to use as a starting point for their own offline RL research. The README is explicit about this: the author recommends the official JAX code unless you specifically need PyTorch. That honesty is useful, because it sets expectations that this is a port, not a reimplementation with new features.

How the Algorithm Works in This Codebase

The repository contains a single main script, main.py, which ties together the IQL algorithm and the D4RL environment interface. IQL works by learning a Q-function that is updated with an expectile regression, which is a way to estimate the upper expectile of the target distribution rather than the mean. This avoids the need to query actions outside the dataset, which is a common failure mode in offline RL. The policy is then extracted via advantage-weighted regression. The README notes a key simplification: this implementation uses a deterministic policy and a least-squares loss, whereas the original paper uses a Gaussian policy with negative log likelihood. That change affects how the policy is optimized and likely explains some of the performance differences. The data flow is standard for offline RL: load a D4RL dataset, iterate over batches, update the Q-network and policy network, and periodically evaluate the policy in the environment.

Getting It Running: Commands and Configuration

Installation is straightforward. The README instructs you to run `pip install -r requirements.txt`. There is no mention of specific Python versions or GPU requirements, so you will need to infer those from the dependencies. To run an experiment, you execute `python main.py --log-dir /path/where/results/will/go --env-name hopper-medium-v2 --tau 0.7 --beta 3.0`. The `--env-name` argument selects the D4RL task, while `--tau` controls the expectile parameter and `--beta` is the inverse temperature for advantage weighting. These are the only hyperparameters shown, which suggests the script has sensible defaults for the rest. The `--log-dir` argument is where results are written, so you must create that directory or ensure the script can create it. There is no mention of a config file or a YAML setup, so all tuning happens through command-line flags.

Performance Results and Where They Differ

The README includes a table of normalized returns on nine MuJoCo locomotion tasks, averaged over three seeds. On most tasks, the numbers are close to the official implementation. For example, halfcheetah-medium-v2 scores 47.7 versus 47.4, and walker2d-medium-expert-v2 scores 108.7 versus 109.6. However, there are noticeable gaps on some tasks. Hopper-medium-expert-v2 shows 76.6 with a standard deviation of 34.9, compared to 91.5 for the official code. That high variance suggests the result is not stable across seeds. Hopper-medium-replay-v2 also lags, at 86.8 versus 94.7. The author attributes these discrepancies to the deterministic policy and least-squares loss simplification. This is a real limitation: if you need to match the paper's exact numbers, this implementation may not do so on every task. The README also notes that validation is ongoing, so the table may change.

Limitations and When This Is the Wrong Tool

The most obvious limitation is the simplification of the policy loss. The original IQL uses a Gaussian policy and negative log likelihood, which allows for stochastic action sampling. This implementation uses a deterministic policy, which can be less robust in tasks that require exploration or where the optimal policy is inherently stochastic. The high variance on hopper-medium-expert-v2 is a symptom of that. Another limitation is scope: the README only mentions MuJoCo locomotion tasks from D4RL. There is no mention of support for other D4RL domains like AntMaze or Kitchen, which are common in offline RL research. If you need those, this repository is the wrong tool. Additionally, the README does not describe any logging or checkpointing beyond the log directory, so you may have to dig into the code to understand how results are saved. For a production system or a large-scale experiment, this minimalism could be a bottleneck.

Alternatives and How They Differ

The primary alternative is the official JAX implementation from ikostrikov/implicit_q_learning. The README explicitly recommends it for anyone not tied to PyTorch. The difference is not just the framework. The official code follows the paper's exact algorithm, including the Gaussian policy and negative log likelihood loss. That means you get the published performance numbers, but you must work with JAX, which has a different programming model and ecosystem. Another alternative is to use a different offline RL algorithm entirely, such as Conservative Q-Learning (CQL) or Decision Transformer, but those are not mentioned in the README. If you are comparing IQL to other methods, this repository gives you a PyTorch baseline, but you should verify that the simplifications do not skew your comparisons.

Maintenance, License, and Upgrade Cost

The repository is licensed under MIT, which permits commercial and academic use with attribution. There are no recent releases listed, and the last push date is unknown, so the maintenance status is unclear. The README says validation is ongoing, but there is no indication of how actively the code is updated. This matters for upgrade cost: if you adopt this as a dependency, you may need to fork it to fix bugs or add features. The code is minimal, which reduces the learning curve, but it also means you will likely need to modify it for anything beyond the default use case. The lack of a release history suggests that the project is more of a research artifact than a maintained library. Before adopting it, check the commit history and open issues in the repository to gauge responsiveness.

Editorial conclusion

Adopt IQL-PyTorch if you are a PyTorch user working on offline RL and need a small, readable baseline for D4RL MuJoCo tasks. Do not use it if you require the exact official algorithm details or need support for environments beyond the included MuJoCo locomotion suite. Before relying on it, verify that the reported normalized returns hold on your hardware and seed setup, and inspect the code for the deterministic policy and least-squares loss simplifications, which may cause discrepancies on tasks like hopper-medium-expert-v2.

Frequently asked questions

What is Q-learning reinforcement learning in this repository?

The repository implements one offline reinforcement learning algorithm, Implicit Q-Learning, in PyTorch, and it is run on tasks from the D4RL benchmark through a single main script. It does not explain Q-learning itself; the algorithm's paper is the reference it points to.

How do the IQL-PyTorch results compare with the official implementation?

Close on most of the nine tasks and measurably lower on hopper. The widest gap is hopper medium-expert at 76.6 against 91.5 with a standard deviation of 34.9, followed by hopper medium-replay at 86.8 against 94.7. The author attributes this to using a deterministic policy and a least-squares loss instead of a Gaussian distribution with negative log likelihood.

Should I use IQL-PyTorch or the authors' JAX implementation?

The README says use the authors' code unless you specifically need PyTorch, because theirs is the official implementation and this one is offered as a framework alternative. Both are described as minimal, and this repository describes its own results as mostly similar to the paper and slightly worse on a few tasks.

What does the D4RL dependency look like in requirements.txt?

It is installed directly from the master branch of the benchmark's GitHub repository rather than from a release, alongside unpinned NumPy, SciPy, pandas and tqdm, and floors of 0.18.0 for the environment package with the MuJoCo extra and 1.7.0 for PyTorch.

Official sources

  1. Official README
  2. Project repository
  3. README
  4. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/gwthomas-iql-pytorch.svg)](https://hysenlabs.com/projects/gwthomas-iql-pytorch)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/gwthomas-iql-pytorch.svg)](https://hysenlabs.com/projects/gwthomas-iql-pytorch)