Skip to main content

cuju

cuju is a bit-exact, batched reimplementation of Google Research Football for CUDA and the CPU. It runs thousands of Google Research Football matches at once, on one NVIDIA GPU or on the cores of a CPU, and keeps them the same matches. For the same seed and actions, every state, observation, reward and done flag equals that of Google Research Football, bit for bit, so results compare directly with work done on the original, and a policy trained on cuju plays the same way there.

Google Research Football, or GRF, is one of the richest benchmarks of multi-agent reinforcement learning, introduced by Kurach et al. in 2020. It plays full football matches with its physics, animations, referee and built-in AI, from five-a-side to eleven-a-side, and drills that teach one skill at a time. It is also slow. GRF runs one match per process at a few hundred steps per second, so on-policy training, which consumes fresh experience by the billion, spends most of its time waiting for the simulator.

cuju suits the cases where the simulator is the bottleneck, in on-policy and multi-agent training, self-play, large evaluations and hyperparameter sweeps, and every result that has to stand next to published GRF numbers. Matches are watched in a browser with cuju's renderer, cuju-render, saved or live, as Rendering describes, and GRF's own tools replay the dumps that cuju writes.

cuju is an independent project, neither affiliated with nor endorsed by Google. Google Research Football is a project of Google Research, and Google is a trademark of Google LLC.

Developer André Koraleski
Initial release 0.1.0, 2026-10
Written in C++, CUDA, Python
Platforms Linux on x86-64 and Arm, Windows, macOS, WSL2
Backends NVIDIA GPUs of compute capability 7.5 or higher, x86-64 CPUs with AVX2, BMI2 and FMA, 64-bit Arm CPUs
License Apache-2.0
Reference Google Research Football 2.10.3, commit 3d9e754
Repository github.com/AndreKoraleski/cuju

PyPI License Open In Colab

Quick start

cuju installs from PyPI and brings PyTorch along when it is missing. PyPI's default PyTorch is a CUDA build on Linux and a CPU-only build on Windows and macOS. A specific build, such as another CUDA version or a CUDA build for Windows, comes first from the index of pytorch.org, and cuju then keeps it.

pip install cuju
cuju check            # ends with PASSED when the machine plays GRF's matches
import cuju
import torch

batch = cuju.BatchEnvironment('5_vs_5_l4_r0', environment_count=64, device='auto')
device, count = batch.torch_device, batch.environment_count
observation = batch.reset()  # [count, 4, 115]
goals = torch.zeros((), dtype=torch.int64, device=device)

for _ in range(1000):
    actions = torch.randint(0, 19, (count, 4), dtype=torch.int32, device=device)
    observation, reward, done, information = batch.step(actions)
    # reward [count, 4], done [count], and ended episodes restart inside the step
    goals += information['score_reward'].abs().sum()

print(int(goals), 'goals in the first third of', count, 'matches')

It prints a line such as 54 goals in the first third of 64 matches. On a GPU, environment_count rises to thousands. Every call returns the same tensors and overwrites them, so whatever is kept must be cloned. The documentation starts from here, and the quickstart notebook runs on Colab's free GPU.

Features

  • One source, two backends. The same C++ runs on the GPU, one warp per match, and on the CPU, a thread pool that spreads matches over the cores. They give the same bits.
  • The whole game inside the batch. The built-in AI, the referee, the animations and the observations all run on the device, and nothing crosses back to Python during a step.
  • All 19 GRF scenarios, 11-a-side and the academies included, with any number of agents on either side, mixed in one batch, and GRF's own scenario files without GRF.
  • PyTorch tensors without copies. Outputs share the batch's buffers, and a CUDA graph or torch.compile can capture a step together with the policy that drives it.
  • Resets under the caller's control. A mask resets some environments, and each can take the seed of its next episode.
  • GRF's states in both directions, stacked or not, in GRF's own format.
  • GRF's interfaces too, from its import paths to its dumps and scripted players, so GRF code runs unchanged.

Performance

Engine Machine Configuration Environment steps per second
GRF AMD EPYC 7763 one process 207
GRF AMD EPYC 7763 31 processes, one per processor 5,819
cuju, CPU AMD EPYC 7763 one environment on one thread 2,018
cuju, CPU AMD EPYC 7763 31 threads 38,497
cuju, GPU NVIDIA RTX 4090 16,384 environments 32,582

All numbers are for 5_vs_5 with four agents on each side and simple115v2, medians of interleaved runs of the release wheel on one cloud machine, which gives the process 31 processors. GRF runs on the CPU, so the GPU row compares with the CPU rows of the same machine. It is the throughput of a batch that keeps its observations, actions and policy on the device, which leaves the processors free for other work. Performance has the method, more scenarios and batch sizes, and the commands that reproduce every row.

Exactness

The reference is GRF 2.10.3 at commit 3d9e754, without rendering, as built by GCC for x86-64 Linux with glibc 2.39 on a processor with FMA. Both backends give the same bits, whatever the number of threads.

cuju is tested against GRF internally. Anyone can run its self-check. cuju check, in the wheel, and pytest tests/, in the repository, need no GRF and tell whether a build reproduces the release bit for bit, and examples/compare_with_grf.py plays cuju next to a separately installed GRF. Issues are welcome, and a difference from GRF is the most valued report. Exactness explains the claim, its scope and how to check it.

Coming from GRF

There are three ways in. Switching the imports to cuju.gfootball runs GRF code unchanged, cuju.env.create_environment is GRF's function with a choice of device, and cuju.BatchEnvironment is the batch, where the speed is. The first two build GRF's spaces with Gymnasium, which pip install 'cuju[spaces]' adds. A port usually switches the imports first, confirms what it already knows, and then moves only the training loop to a batch. The table maps the batch.

GRF cuju
gfootball.env.create_environment('5_vs_5', number_of_left_players_agent_controls=4) cuju.BatchEnvironment('5_vs_5_l4_r0', environment_count=...)
env.step(action) with [4] actions batch.step(actions) with [environment_count, 4] actions
if done: env.reset() the step that ends an episode starts the next by itself
the last observation of an episode information['final_observation'][done.bool()], per array for raw
env.get_state(), env.set_state(state) batch.get_state(index), batch.set_state(index, state), in GRF's format
representation, rewards, stacked, channel_dimensions, action_set the same names
code written for GRF's environment cuju.env.create_environment(...), GRF's arguments and interface

done is uint8, and PyTorch deprecates indexing with a uint8 mask, so indexing goes through done.bool(). With representation='raw' the observations are dictionaries of tensors, each indexed on its own. Migrating from GRF discusses the three ways in and maps every option, method and wrapper.

Platforms

PyPI holds a wheel for each platform, and every platform passes the same self-check against the same digests, so each plays GRF's matches bit for bit.

Platform Backends
Linux on x86-64, WSL2 included CPU and CUDA
Linux on Arm, aarch64 CPU
Windows on x86-64 CPU and CUDA
macOS on Apple silicon CPU
macOS on Intel processors CPU, with PyTorch 2.2

The CPU backend needs AVX2, BMI2 and FMA on x86-64 and runs on every 64-bit Arm processor. The CUDA backend needs an NVIDIA GPU of compute capability 7.5 or higher, and the wheels carry its machine code for the architectures checked for exactness, 7.5, 8.0, 8.6 and 8.9, and other architectures build from source. On macOS on Intel processors, PyTorch ends with 2.2, and torch.compile traces a step from PyTorch 2.4 on. Installation gives the requirements of each platform.

The renderer, the package cuju-render, installs with pip install 'cuju[render]'. Run cuju render demo for a first look, a live match between the built in AIs in the browser within seconds, and cuju render serve --open to watch saved matches and live training. Its Home page leads to recordings, requested matches between teams, team and field editors and Play a game for keyboard or controller input. Teams can control one or several players, and Ability sets the strength of the built in AI. Watching preserves the match, as Rendering describes. cuju render video exports a range of a recording as an MP4 video, GRF's tools replay cuju's dumps and make videos of their own, and the representation pixels remains GRF's. Differences from GRF describes every known difference.

Documentation

Page Covers
Concepts environments, batches, bundles, agents, and why the API looks this way
Installation requirements, PyPI, source builds, Docker, WSL2, troubleshooting
Migrating from GRF every GRF name and its counterpart
Scenarios and Custom scenarios the scenarios that play, and custom scenario files
Observations, Rewards and actions what agents see, receive and do
Episodes and seeds, States resets, reproducibility, saving and moving matches
Backends, Performance, Recipes getting the most out of each device
Exactness, Differences from GRF what equals GRF, how to check it, and where cuju differs
Common topics, API reference quick answers and every public name

Name

Cuju, written 蹴鞠 and pronounced cùjū, literally kick ball, is the football of ancient China, and the oldest form of the game that FIFA recognises. Records place it in the city of Linzi in the Warring States period, more than two thousand years ago. Under the Han dynasty it served as military training, and a work in twenty-five chapters on its rules appears among the books of the imperial library. It reached its height under the Song, when clubs of players kept its craft, and it later travelled to Japan, where it became kemari. The project takes the name because cuju is the earliest football whose rules people wrote down, and the project is, at heart, an exercise in keeping a game's rules exactly. The name is a tribute, and cuju, the project, is unconnected with any institution that preserves the game. The name also shares its first syllable with CUDA.

Citing

Research that uses cuju is asked to cite both cuju and GRF.

@software{cuju2026,
    author  = {Koraleski, Andr{\'e}},
    title   = {cuju: a bit-exact, batched reimplementation of {Google Research Football}, for {CUDA}
             and {CPU}},
    year    = {2026},
    version = {0.2.1},
    url     = {https://github.com/AndreKoraleski/cuju}
}

@inproceedings{kurach2020google,
    title     = {{Google Research Football}: A Novel Reinforcement Learning Environment},
    author    = {Kurach, Karol and Raichuk, Anton and Sta{\'n}czyk, Piotr and Zaj{\k{a}}c, Micha{\l}
               and Bachem, Olivier and Espeholt, Lasse and Riquelme, Carlos and Vincent, Damien
               and Michalski, Marcin and Bousquet, Olivier and Gelly, Sylvain},
    booktitle = {Proceedings of the AAAI Conference on Artificial Intelligence},
    volume    = {34},
    number    = {04},
    pages     = {4501--4510},
    year      = {2020},
    doi       = {10.1609/aaai.v34i04.5878}
}

CITATION.cff holds the same entry for GitHub's citation button.

Acknowledgments

cuju exists because of the authors of Google Research Football, who built and opened a remarkable environment, because of Gameplay Football by Bastiaan Konings Schuiling, from which GRF's engine descends, and because of the GNU C Library, whose math functions it ports.

License

cuju is licensed under Apache-2.0. It reimplements GRF, licensed under Apache-2.0 by Google LLC, whose engine descends from Gameplay Football by Bastiaan Konings Schuiling, and NOTICE lists every credit. Four math functions in include/cuju/libm/, namely sin, cos, acos and asinf, are ports of the GNU C Library under the LGPL 2.1 or later, and both libraries compile them in.

  • Using cuju, from open or proprietary code, carries no obligation. Obligations start with distribution.
  • Redistributing cuju's libraries, as a wheel or an image, means keeping LICENSE, NOTICE and LICENSES/ with them and offering the matching source, which every PyPI release carries as its sdist.
  • Compiling the C++ headers into another program brings the LGPL into that program.
  • The logo in docs/assets/ is licensed under CC BY 4.0, so it may be reused with credit, without any right to the name or the logo as a mark of endorsement.

Metadata

Release files for cuju 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cuju 0.2.1
File Size Uploaded Provenance Actions
cuju-0.2.1.tar.gz 2.1 MB With provenance Details for cuju-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cuju 0.2.1
File Actions
cuju-0.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for cuju-0.2.1-py3-none-win_amd64.whl
cuju-0.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for cuju-0.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
cuju-0.2.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details for cuju-0.2.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
cuju-0.2.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for cuju-0.2.1-py3-none-macosx_11_0_arm64.whl
cuju-0.2.1-py3-none-macosx_10_15_x86_64.whl Python 3 none macOS 10.15+ x86-64 Details for cuju-0.2.1-py3-none-macosx_10_15_x86_64.whl

Total release size: 23.6 MB

Release files / cuju-0.2.1.tar.gz

Download URL cuju-0.2.1.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
2069d1d611388d94b5f6558f3b49e22096e303ecd04b1642b8f6e965a13cf80c
BLAKE2b-256 checksum
How to use checksums
e916f5f94e88d94db65c20623841c1aa8f2361b9644f51ec9ff0f1f46d455ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cuju-0.2.1-py3-none-win_amd64.whl

Download URL cuju-0.2.1-py3-none-win_amd64.whl
Size 7.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
df1a9818559b3c522afec833217e79313cf2c5dae2dc10de51f5c6052b63b543
BLAKE2b-256 checksum
How to use checksums
bb9c082f5dabb151fd66236736df1f70a7e703f558e95de0df400c96a9357066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cuju-0.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cuju-0.2.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 7.7 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
e0723295b0c9fde334a63674457e3d0605664a114b949df390be077959a96726
BLAKE2b-256 checksum
How to use checksums
b01a23405323fcb810a418ae32789e7416275af2bb7f3bfde13cbcb8871a0241
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cuju-0.2.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cuju-0.2.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
dff44ec3d2789f3027e5d355edffa9b04c6f9a5aa211f2a4df3ea804678a5cc5
BLAKE2b-256 checksum
How to use checksums
13b196d99705f97abfe36389498dabef7675f94131d99e5dd25006d8b45fe7a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cuju-0.2.1-py3-none-macosx_11_0_arm64.whl

Download URL cuju-0.2.1-py3-none-macosx_11_0_arm64.whl
Size 2.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0cd09a422219133ee20280a8af56947d7f7f84981492be722913c0da2c4a0e3f
BLAKE2b-256 checksum
How to use checksums
283a5d62b0f7bfb74408db3e4b88d70a49cfbfd5ffb2cdb3989b86804b83da65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / cuju-0.2.1-py3-none-macosx_10_15_x86_64.whl

Download URL cuju-0.2.1-py3-none-macosx_10_15_x86_64.whl
Size 2.1 MB
Tags Python 3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
1f26736ea5d689e74939d1ed93d961a808ed248fcb8e1867dba5e4e18c7ecad4
BLAKE2b-256 checksum
How to use checksums
e57863eb66b5ece9ca83f7243a3c4b4f47e48d89f506173eb544b525a96413aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for cuju 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for cuju-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page