A Native C++ Engine for Fast Training and Bitwise-Consistent RL Replay
FlashRT-Train is a native C++/CUDA execution engine for training and on-policy RL. Your algorithm runs in its usual host. FlashRT serves the rollout, and FlashRT-Train can replay it bit for bit before updating the policy. The native training library links to no tensor framework.
- Develop in the host. Keep your data, loss, schedule and checkpoints. For a supported model, call a complete training step through the C ABI, or supply the gradient of your own loss at the model output.
- Optimize in the sandbox. Record a reference step in the host. Tune kernels and launch settings for one model and GPU target, check the numerics, then run the same algorithm with the new build. PyTorch and JAX precision profiles describe the host’s arithmetic separately from hardware settings.
The first training pipeline is π0.5. Its measured hosts are LeRobot and openpi (PyTorch and JAX). The language-model policy has its own support matrix. π0.5 · Language models · Host integration
Across A100, A800, H100 and H200, π0.5 training steps are 1.4–7.5× faster than the measured host baselines at batch sizes 1, 4 and 8. More hardware coverage is coming. Timings by GPU, host and batch
On A800, one LIBERO-10 PPO iteration took 114.7 s with FlashRT-Train and 701.0 s with RLinf + PhyAI. At unchanged weights, FlashRT rollout and trainer replay match bit for bit, so the update reuses the rollout log-probabilities without an extra alignment pass. Timings and replay checks
Keep your dataloader, augmentations and batch preprocessor. For a single-GPU, full-policy run, initialize the native engine once, then replace the update in your existing loop. Build the engine and import the example helper
import os
from lerobot_pi05_step import export_policy, learning_rate_at, native_step, open_trainer
host_policy = accelerator.unwrap_model(policy)
engine = open_trainer(host_policy, os.environ["CKPT"], optimizer, cfg.optimizer.grad_clip_norm) # Inside the LeRobot loop, immediately after batch preprocessing
- train_tracker, _ = update_policy(train_tracker, policy, batch, optimizer, ...)
+ lr = learning_rate_at(optimizer, lr_scheduler, step)
+ result = native_step(engine, host_policy, batch, lr)
+ train_tracker.loss, train_tracker.grad_norm, train_tracker.lr = result.loss_mean, result.grad_total_norm, lrThe engine owns the updated weights and AdamW state. Before LeRobot evaluates or exports a policy, copy the weights back with export_policy(engine, host_policy). Full integration, precision settings and checkpoint/resume · Example source
openpi PyTorch · check the host adapter
In an openpi PyTorch environment with its transformer patches installed, install this checkout with python -m pip install -e .. With CKPT set to the π0.5 safetensors file and FRT_TRAIN_LIB set to the built library, check the adapter’s input tensors and weight export, then time the original host step.
python tools/hosts/openpi/adapter_check.py --checkpoint "$CKPT" --batch 1
python tools/hosts/openpi/bench_host_openpi.py --checkpoint "$CKPT" --batch 1 4 8 --steps 6 --warmup 2Inside the openpi launcher, use the existing model, training configuration and device batch.
from flashrt_train.hosts.openpi.adapter import Step
step = Step(model, checkpoint=checkpoint_file, config=train_config)
result = step(observation, actions)Adapter and supported configurations · openpi PyTorch environment
openpi JAX · compare the native and jitted training steps
In the openpi JAX environment, set CKPT to the same safetensors file and use the same weights for both processes. The engine’s JAX form uses FP32 master weights and attention scores. The second command times openpi’s own jitted training step. JAX environment and reference export
FRT_TRAIN_OBJECTIVE=flow_matching FRT_TRAIN_TEXT_TOKENS=200 FRT_TRAIN_MAX_GRAD_NORM=1 \
FRT_TRAIN_PROFILE=openpi_jax FRT_TRAIN_ADAMW=fused_fp32_master FRT_TRAIN_ATTENTION_LOGITS=fp32 \
build/tests/bench_step "$CKPT" 1 6 2 --activation-budget-gib auto
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 python tools/hosts/openpi/bench_host_openpi_jax.py \
--checkpoint "$CKPT" --batch 1For isomorphic RL, use a π0.5 LIBERO checkpoint with its action statistics and tokenizer, a compatible FlashRT inference build and the LIBERO simulator. The example selects the inference backend explicitly with --sampler flashrt. Run the replay check and PPO example
- Record one host step. Save a representative batch, its random draws, the loss and gradients. Time the step on your target GPU.
- Connect your loop. Keep the dataloader and schedule in your host. Call the native training step, or compute your own loss in the host and pass its output gradient to the engine. Run the saved batch through both paths and compare. Choose a host API
- Tune in the sandbox. Give your agent the reference batch and GPU target. Try one kernel or launch setting, run the numerical checks, then measure the full step back in your training loop. Run your first agent experiment
- Models — expand training and rollout coverage across the Qwen family, integrate GR00T, and add more language models (LMs), vision-language-action models (VLAs) and world-action models (WAMs).
- Hardware — expand GPU coverage and bring up an AMD backend.
- RL — test more algorithms and environments and publish comparable rollout, replay and update measurements.
Contributions are welcome. A reference batch for a new host, a replay test for a new model, or a kernel improvement with same-GPU timings are all good places to start. Contributing guide
Thanks to the teams behind FlashRT, openpi and LeRobot for the inference kernels, models and training code this project builds on.
Our PPO example follows πRL and its RLinf reference implementation, and runs on LIBERO. Thanks also to verl for the language-model rollout interface and FlashAttention-2 for the attention backward design.


