Skip to main content

Inference runtime for Causal-GPT-RL policy bundles

Project description

Causal GPT-RL

GPT-style transformers (GPT-2, Llama) running as RL policies in continuous-control environments.

The autoregressive structure is the same on both sides:

action → next state → next action      (RL rollouts)
token  → next token  → next token      (LLM generation)

Causal GPT-RL policies act stably under their own rollouts — long-horizon control without the drift that has historically kept transformers from being usable as RL agents.

A single autoregressive model drives full-episode rollouts via KV cache — no critic, no auxiliary networks at inference.

This repository is the public inference runtime. It loads policy bundles, runs Gymnasium/MuJoCo rollouts, and provides small evaluation helpers.

Released under PolyForm Noncommercial 1.0.0. For commercial licensing, contact the maintainers via ccnets.org.

Install

For Hub loading and MuJoCo environments:

pip install "causal-gpt-rl[hub,mujoco]"

For local development:

git clone https://github.com/ccnets-team/causal-gpt-rl.git
cd causal-gpt-rl
python -m pip install -e ".[hub,mujoco]"

For private bundles, authenticate first:

hf auth login

Quick Start

import gymnasium as gym

from causal_gpt_rl.inference import load_runner_from_hub, run_episodes

env = gym.make("Ant-v5")
runner = load_runner_from_hub(
    repo_id="ccnets/causal-gpt-rl",
    subfolder="ant-v5",
)

stats = run_episodes(env, runner, num_episodes=5, seed=0)
env.close()
print(stats["return_mean"], stats["return_std"])

Notebook version: examples/hub_quickstart.ipynb

Supported Environments

Environment Gymnasium ID Hub subfolder Return (mean ± std)
Ant Ant-v5 ant-v5 2614 ± 1515
HalfCheetah HalfCheetah-v5 halfcheetah-v5 2680 ± 2059
Walker2d Walker2d-v5 walker2d-v5 2345 ± 879
Humanoid Humanoid-v5 humanoid-v5 2371 ± 2850

Returns are over 5 episodes with seed=0 (HalfCheetah-v5: 50 episodes), run on CPU via run_episodes.

Bundle Format

All public bundles include:

bundle/
  model.safetensors
  config.json
  state_normalizer.safetensors
  • model.safetensors — model state dict for inference.
  • config.json — model config, observation specs, action specs, context length, and optional env_id.
  • state_normalizer.safetensors — state normalization statistics used by the policy.

Hugging Face Layout

Recommended layout:

ccnets/causal-gpt-rl/
  ant-v5/
    model.safetensors
    config.json
    state_normalizer.safetensors
    README.md

Root-level bundles are supported by omitting subfolder:

load_runner_from_hub(repo_id="ccnets/causal-gpt-rl-ant")

For local bundles, use load_runner("path/to/bundle").

API

from causal_gpt_rl.inference import (
    PolicyRunner,                          # step-wise rollout policy with KV cache
    load_runner,                           # load runner from a local bundle directory
    load_runner_from_hub,                  # load runner from a Hugging Face Hub repo
    run_episodes,                          # evaluate over N episodes; returns stats dict
    export_bundle,                         # write a bundle directory from a runner
    convert_legacy_bundle_to_safetensors,  # migrate legacy bundles to the safetensors format
)

Development Checks

python -m compileall -q causal_gpt_rl
python -m unittest discover -s tests
python -m build
python -m twine check dist/*

License

PolyForm Noncommercial License 1.0.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causal_gpt_rl-0.2.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

causal_gpt_rl-0.2.0-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file causal_gpt_rl-0.2.0.tar.gz.

File metadata

  • Download URL: causal_gpt_rl-0.2.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for causal_gpt_rl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bb00e75a960fdf0da17952dc64c76237b99e137e01772002a129cdfdccc63919
MD5 8737fd6c11c2dabfe5d6be0c14dec833
BLAKE2b-256 8e9190d72ac0eef84d21329f40e3903f6980ae423ad1a2e6f35a5ec144372cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for causal_gpt_rl-0.2.0.tar.gz:

Publisher: publish.yml on ccnets-team/causal-gpt-rl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file causal_gpt_rl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: causal_gpt_rl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for causal_gpt_rl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5d65bcad1c4e13a68b141e604101e7811a229d610e53ce4e5e9fa7dc700dee7
MD5 b46d87aa4a98949d41f67f9feec0018d
BLAKE2b-256 ae5da71bbdf20f7d713244533649c50940c079bbde0aa13cda0a6fabeef693ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for causal_gpt_rl-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ccnets-team/causal-gpt-rl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page