Skip to main content

plasmax logo

Plasmax: differentiable & parallelizable environments for transport control in Tokamaks

plasmax provides JAX-native fusion-control environments built on TORAX. The environments are inspired by real tokamak devices; ITER, SPARC, STEP, and KSTAR. Each tokamak contains different tasks for different scenarios and phases.

Environment design is inspired by recommendations from Challenges of Real World Reinforcement Learning, where missing, noisy observations are explicitly implemented.

Install

pip install plasmax

We did not package the training and agent stack to make the dependencies lighter. If you want to try training agents using our stack:

git clone https://github.com/TheodoreWolf/plasmax
cd plasmax
pip install -e . --group research

Quick start

import jax
import jax.numpy as jnp

import plasmax

env = plasmax.make(
    "iter/hybrid/flattop",
    backend="bohm_gyrobohm",
)

state, info = env.init(jax.random.key(0))
action = jnp.zeros(env.action_space.shape, dtype=env.action_space.dtype)
state, info = env.step(state, action)

print(info.obs, info.reward)
print(info.terminated, info.truncated)

Environments are loaded through the make function, the environment name is structured as such {tokamak}/{scenario}/{phase}.

By default, it applies the modifications recommended by Challenges of Real World Reinforcement Learning, use variant="oracle", to remove these.

The environments use the Envelope API and contracts, this includes e.g. explicit truncation versus termination.

Tasks and backends

Task aliases Compatible backend aliases
iter/{baseline,hybrid,advanced}/{rampup,flattop,rampdown} cgm, qlknn, bohm_gyrobohm, tglfnn, tglfnn_nr
sparc/{prd,reduced_field}/{rampup,flattop,rampdown} cgm, qlknn, bohm_gyrobohm, tglfnn, tglfnn_nr
step bohm_gyrobohm, tglfnn_spherical
kstar fusion_lstm

Unsupported environment/backend pairs are rejected before construction.

NB: the tglfnn_spherical backend requires a repository clone for now. TGLFNN-UKAEA is still an eager transitive TORAX dependency. TORAX 1.4.3 pins fusion-surrogates 0.4.6, whose TGLFNN extra pins the older 0.1.0 weights. Repository clones use a uv-only override to the final PyPI 0.2.0 weights until TORAX adopts fusion-surrogates 0.4.7. Published installs still follow TORAX's dependency metadata.

Equilibria generated with FreeGSNKE are committed artifacts, so FreeGSNKE is not a runtime dependency.

Every leaf task YAML owns its reward and terminal-penalty defaults:

task:
  reward: lh_transition
  terminal_penalty: -100

By default, reward and disruption_penalty; uses the task metadata. Explicit overrides are supported, including disruption_penalty=0.0. Ramp-up tasks use lh_transition, flat-top and STEP tasks use P_diff, and ramp-down tasks use rampdown. KSTAR uses its native learned-model reward and has no terminal penalty.

env = plasmax.make("iter/advanced/rampup", backend="qlknn")

oracle_ablation = plasmax.make(
    "iter/advanced/rampup",
    backend="qlknn",
    variant="oracle",
    reward="Q_fusion",
    disruption_penalty=0.0,
)

Environment boundary

init, step, and reset return (state, info). A transition exposes:

  • info.obs: the post-transition flat observation;
  • info.reward: a scalar float32 RL-boundary reward;
  • info.terminated: a physical or solver termination;
  • info.truncated: the configured time-limit cutoff;
  • info.termination_code: the environment's termination reason.

If termination and the time limit coincide, termination wins.

Fixed-shape rollout collection is part of the installed library:

from plasmax import collect_episode


def act(obs, key):
    del obs, key
    return jnp.zeros(env.action_space.shape, dtype=env.action_space.dtype)


trajectory = collect_episode(
    act,
    env,
    jax.random.key(1),
    num_steps=env.max_steps,
)

The collector retains the first terminal transition, stops stepping the environment, and pads the remaining fixed-size output with valid=False.

Contribution and Development

We welcome contributions! To contribute, first fork the repository, then:

git clone {your_gh_username}/plasmax
cd plasmax
# We highly encourage uv for developement
uv sync --group dev
git checkout {name}/{what_you_are_changing}

Then you can open a PR in this repository. Make sure to run tests, CI will do this for you as well. Please have respect for the developer's time and do not submit PRs that can not be reasonably reviewed (even with the help of agents).

Repository layout

src/plasmax/        installed environments, tooling, configs, and data
agents/             clone-only baseline agents
training/           clone-only training adapters
scripts/            generic baseline and rollout launchers
tools/              artifact and equilibrium generation
benchmarks/         backend agreement and throughput benchmarks
experiments/        research studies and plotting
tests/              library and release tests

License and attribution

The library is licensed under the Apache License 2.0. TORAX and packaged third-party data/model assets retain their own attribution and license terms; the relevant notices are shipped adjacent to those assets.

Agents

An AGENTS.md file is included, which has my own personal code preferences. We recommend users who want to use agents to obtain an explicit JAX skill (I've written my own, that I will open-source, when I'm happy with it), as current agents are still not great at this. Agents were utilized throughout this work, while I did my best to check the code, mistakes remain. In my experience, the most dangerous are comments that state mistakes or bad assumption as facts, this then further reinforce the agents in their bad ideas.

Citation

Coming soon, once I get the paper out...

Metadata

Release files for plasmax 0.1.0

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

Source distribution (sdist)

Source distribution for plasmax 0.1.0
File Size Uploaded Provenance Actions
plasmax-0.1.0.tar.gz 26.1 MB With provenance Details for plasmax-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for plasmax 0.1.0
File Interpreter ABI Platform Actions
plasmax-0.1.0-py3-none-any.whl Python 3 none any Details for plasmax-0.1.0-py3-none-any.whl

Total release size: 52.3 MB

Release files / plasmax-0.1.0.tar.gz

Download URL plasmax-0.1.0.tar.gz
Size 26.1 MB
Tags Source
SHA-256 checksum
How to use checksums
43f98346686010189d1acab35a2792f5ebd86391a734750cdc5820eb504ace34
BLAKE2b-256 checksum
How to use checksums
c913960216f7a7e2cadc00d505398431dc7650129c7c3f18a54c9debde11ae8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Release files / plasmax-0.1.0-py3-none-any.whl

Download URL plasmax-0.1.0-py3-none-any.whl
Size 26.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
77b75091e9d7bd9d45c1cc0e18310a80e85ba0d1557d3a501da72dcce560944b
BLAKE2b-256 checksum
How to use checksums
256c085384b5b2c29300cf450f1a6f2c0551dd034192f35b3538c31eae18f8ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 11, 2026.

Transparency log

Security for plasmax 0.1.0

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 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for plasmax-0.1.0.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 Aug 11, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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