Complete reference for installation, API parameters, mechanisms, and usage patterns.
TL;DR — see README.md § Build & install for the full walkthrough (Docker and non-Docker paths). The short version:
git clone https://github.com/LiangSu8899/FlashRT.git
cd FlashRT
git clone --depth 1 --branch v4.4.2 \
https://github.com/NVIDIA/cutlass.git third_party/cutlass
pip install -e ".[torch]" # or "[jax]" / "[all]"
# Build — produces flash_rt_kernels.so AND (on RTX) flash_rt_fa2.so.
# Thor builds produce only the former (FA2 skipped, Thor uses fvk
# cuBLAS-decomposed attention).
mkdir build && cd build
cmake .. # auto-detects GPU arch from nvidia-smi
make -j$(nproc)
cp flash_rt_kernels*.so flash_rt_fa2*.so ../flash_rt/ 2>/dev/null || \
cp flash_rt_kernels*.so ../flash_rt/ # Thor path
cd ..Crucially — no pip install flash-attn required. FlashRT
vendors FA2 v2.7.4.post1 (fp16 + bf16) at source level and builds
it into flash_rt/flash_rt_fa2.so. Zero pip flash-attn wheel
dependency at runtime.
After installation, import flash_rt works from any directory.
TL;DR — required one-time download for Pi0 / Pi0.5 only. Qwen3-8B and other text-only models do NOT need this.
Pi0 and Pi0.5 prefix prompts via the PaliGemma SentencePiece
tokenizer (paligemma_tokenizer.model, ~4.1 MiB). This file is
not bundled inside the openpi pi0 / pi05 checkpoints — it lives
in Google's public big_vision storage bucket, and you have to
fetch it once before running any Pi0 / Pi0.5 inference.
bash scripts/download_paligemma_tokenizer.sh
# → ~/.cache/flash_rt/paligemma_tokenizer.modelThe script downloads from the public GCS HTTP endpoint
(https://storage.googleapis.com/big_vision/paligemma_tokenizer.model),
verifies the MD5, and is idempotent (re-runs are no-ops if the file
is already valid).
# Set this env var to point at any local copy:
export FLASH_RT_PALIGEMMA_TOKENIZER=/data/checkpoints/paligemma_tokenizer.modelThe frontend's resolution order is:
$FLASH_RT_PALIGEMMA_TOKENIZER(explicit override)~/.cache/flash_rt/paligemma_tokenizer.model~/.cache/openpi/big_vision/paligemma_tokenizer.model(compatible withopenpi.shared.download.maybe_download)/workspace/paligemma_tokenizer.model(legacy container path)- openpi auto-download via
gs://big_vision/...(only ifgcsfsis installed)
If none resolves, the loader raises a FileNotFoundError whose
message contains the exact curl command above — no silent
failure modes, no segfaults.
Q: I downloaded the openpi Pi0 / Pi0.5 checkpoint. Don't I already have this?
A: No. openpi ships only model.safetensors + assets/ + configs;
the tokenizer is a separate fetch by design (one tokenizer file,
many checkpoints).
Q: Can I use the HuggingFace google/paligemma-3b-pt-224 mirror instead?
A: That repo contains the same tokenizer.model file, but PaliGemma
is a gated HF model (you must accept the license + supply an HF
token). The GCS public bucket is auth-free and a one-line curl —
strictly easier for fresh setups. The frontend accepts a tokenizer
loaded from either source as long as you point
$FLASH_RT_PALIGEMMA_TOKENIZER at it.
Q: I'm getting FileNotFoundError: paligemma_tokenizer.model not found.
A: Run the download script above (or curl directly into one of
the search paths). The error message is itself the fix — it spells
out the exact command.
Q: Old setups had /workspace/paligemma_tokenizer.model —
do I need to migrate?
A: No. The legacy path is still in the search list.
import flash_rt
model = flash_rt.load_model(
checkpoint="/path/to/checkpoint",
framework="torch",
)
actions = model.predict(
images=[base_img, wrist_img],
prompt="pick up the red block",
)
# actions: numpy (10, 7) — 10 future steps, 7 DOFmodel = flash_rt.load_model(
checkpoint, # str: path to checkpoint directory
framework="torch", # "torch" or "jax"
num_views=2, # number of camera views (2 or 3)
autotune=3, # CUDA Graph autotune trials
recalibrate=False, # force fresh FP8 calibration
config="pi05", # model config
)| Parameter | Type | Default | Description |
|---|---|---|---|
checkpoint |
str |
required | Path to checkpoint directory. Safetensors for torch, Orbax for jax. |
framework |
str |
"torch" |
"torch" (safetensors) or "jax" (Orbax). Both use the same C++/CUDA kernels. |
num_views |
int |
2 |
Number of camera views. LIBERO uses 2 (base + wrist). |
autotune |
int|bool |
3 |
CUDA Graph autotune intensity. See Autotune. |
recalibrate |
bool |
False |
Force fresh FP8 calibration (and weight cache for JAX), ignoring cache. See Calibration. |
weight_cache |
bool |
True |
Cache FP8-quantized weights to disk. JAX only — reduces cold start from ~42s to ~6s. Torch loads in ~3s and ignores this. See Weight Cache. |
config |
str |
"pi05" |
Model architecture config: "pi05", "pi0", "groot", "pi0fast". |
decode_cuda_graph |
bool |
False |
Pi0-FAST only. Capture action-phase decode as CUDA Graph. Trades startup time for per-token speed. See Pi0-FAST. |
decode_graph_steps |
int |
80 |
Pi0-FAST only. Number of action tokens to capture in the decode graph. Should cover your longest expected action sequence. |
use_fp4 |
bool |
False |
Pi0.5 torch + jax on Thor. Enable NVFP4 quantization on the encoder FFN stack. When True, resolves to the production preset (fp4_layers=tuple(range(18)) + use_awq=True + use_p1_split_gu=True). Requires SM100+ GPU. Other configs emit a warning and fall back to FP8. See NVFP4. |
fp4_layers |
tuple[int] | None |
None |
Encoder layer indices to FP4-quantize. None → resolved by the use_fp4 preset. Passing an explicit tuple overrides the preset. Only (7,8,9) and range(18)+AWQ are task-level validated. |
use_awq |
bool | None |
None |
Activation-aware weight quant. Required for 18-layer FP4 scope (without it, cos collapses to ~0.33). None → resolved by the use_fp4 preset. |
awq_alpha |
float |
0.5 |
AWQ scaling exponent s[k] = (a[k]/a.mean())^alpha. |
use_p1_split_gu |
bool | None |
None |
P1 split-GU 2-GEMM path (parity on Pi0.5, kernel reusable for Pi0.6). None → resolved by the use_fp4 preset. |
actions = model.predict(
images=[base_img, wrist_img], # list of (224,224,3) uint8/float16 numpy
prompt="pick up the red block", # text prompt (required on first call)
)| Parameter | Type | Default | Description |
|---|---|---|---|
images |
list or dict |
required | Camera images. List: [base, wrist] or [base, wrist, wrist_right]. Dict: {"image": ..., "wrist_image": ...}. |
prompt |
str|None |
None |
Task prompt. Required on first call. Omit to reuse previous prompt (no recalibration, no graph recapture). |
Returns: np.ndarray shape (10, 7) — 10 future action steps, 7 DOF.
Prompt reuse: When prompt is the same as the previous call, predict() skips set_prompt() entirely — only graph replay happens (~44ms). Changing the prompt triggers recalibration + graph recapture (~4s).
model.recalibrate()
# Next predict() will force fresh calibration
actions = model.predict(images=..., prompt="...")Clears the calibration cache for this checkpoint and forces recalibration on the next predict() call. Use after:
- Fine-tuning the model (activation distributions changed)
- Switching deployment domains (different image statistics)
- Debugging precision issues
Pi0-FAST is an autoregressive model — actions are generated as discrete
FAST tokens (Gemma 2B, 18 layers), not via diffusion. Total latency =
prefill + N × per_token_decode where N is typically 30–80 tokens.
| Mode | set_prompt (cold) |
set_prompt (cached) |
Per-token | 50-tok E2E |
|---|---|---|---|---|
| Default | ~2.5 s | ~0.1 s | 9.5 ms | ~480 ms |
Max-perf (decode_cuda_graph=True) |
~4.0 s | ~1.5 s | 8.3 ms | ~447 ms |
# Default: good for interactive / multi-prompt scenarios
model = flash_rt.load_model(
checkpoint="/path/to/pi0_fast_base",
config="pi0fast",
)
actions = model.predict(
images=[base_img, wrist_img],
prompt="pick up the red block",
state=robot_state,
)
# Max-performance: best for fixed-prompt 24h continuous control
model = flash_rt.load_model(
checkpoint="/path/to/pi0_fast_base",
config="pi0fast",
decode_cuda_graph=True, # capture decode loop as CUDA Graph
decode_graph_steps=80, # covers sequences up to 80 action tokens
)Default mode: Each decode token runs through a Python loop with per-step
kernel launches. Lowest startup cost — set_prompt loads calibration from
cache in ~0.1s on subsequent runs.
Max-performance mode: The action-phase decode loop is captured as a single CUDA Graph (same technique as Pi0's diffusion loop). All autoregressive token dependencies (argmax → embedding lookup → next step) run entirely on GPU with zero host-device synchronization per step.
- Adds ~1.5s to
set_promptfor decode graph capture (on top of the cached calibration load) - Saves ~1.2 ms/token (–13% per-token latency)
- Break-even at ~40 inferences per prompt
- For long sequences (80 tokens), saves ~96 ms per inference
| Component | Cold (first ever) | Cached (same ckpt + Se) |
|---|---|---|
| SigLIP graph capture | ~0.2 s | ~0.2 s |
| FP8 calibration (16 samples) | ~2.4 s | 0 s (loaded from cache) |
| Prefill graph capture | ~0.1 s | ~0.1 s |
Decode graph capture (decode_cuda_graph=True) |
~1.5 s | ~1.5 s |
| Total (default) | ~2.5 s | ~0.1 s |
| Total (max-perf) | ~4.0 s | ~1.5 s |
The 2.4s calibration is the largest cold-start cost. It runs 16 forward
passes with noise perturbations to find robust FP8 activation scales, then
saves to ~/.flash_rt/calibration/. On subsequent runs with the same
checkpoint and sequence length, calibration loads from cache instantly.
Pi0-FAST follows the same calibration cache mechanism as Pi0/Pi0.5:
set_prompt(): Check cache → hit: load scales (0s) / miss: run 16-sample calibration (~2.4s) and save to cache- First
predict(): Always recalibrates with real image data (regardless of cache) for optimal FP8 scales matching actual deployment images. The result is saved back to cache. - Subsequent
predict(): Pure inference, no recalibration
Same-scene optimization: When running the same scene repeatedly (same prompt, same checkpoint), the cached calibration from step 2 above is reused. No need to force recalibration — the system handles it automatically.
Force recalibration:
rm -rf ~/.flash_rt/calibration/ # clear all cached scalesThe Torch frontend requires safetensors format. Convert from Orbax:
python examples/convert_pi0fast_orbax_to_safetensors.py \
--orbax_dir /path/to/pi0_fast_base \
--output_dir /path/to/pi0_fast_base_convertedThe JAX frontend reads Orbax directly.
CUDA Graph instantiation on Thor is non-deterministic — the same kernels can produce different execution schedules with ~2ms latency variance. Autotune recaptures the graph multiple times and keeps the fastest schedule.
- Capture CUDA Graph (SigLIP + Encoder + Decoder)
- Benchmark the graph with CUDA events
- If latency is within the fast regime (< 38.5ms for Enc+AE), accept
- Otherwise, recapture and retry
- After
autotunetrials, use whatever was captured last
autotune= |
Behavior | Extra startup time | When to use |
|---|---|---|---|
0 or False |
Single capture, no retry | 0 | Debugging, fastest startup |
3 (default) |
Up to 3 retries | ~1s | Production (Torch almost always finds fast graph on trial 0) |
5 |
Up to 5 retries | ~2.5s | JAX or when you need guaranteed best latency |
True |
Same as 3 |
~1s | Shorthand |
- Torch: Almost always gets the fast graph on trial 0 (43-44ms total)
- JAX: XLA GPU memory state sometimes prevents fast graph.
jax.clear_caches()is called before capture to help, but 5+ trials may be needed
Autotune is part of set_prompt(). If you call predict() with the same prompt, the cached graph is replayed — no autotune overhead.
FP8 inference requires calibrated activation scales — per-layer maximum values that determine the FP8 quantization range. Incorrect scales cause precision loss.
Phase 1: Initial calibration (during set_prompt()):
- Check disk cache:
~/.flash_rt/calibration/{ckpt_hash}_Se{N}.json - Cache hit: Load scales from JSON (instant)
- Cache miss: Run
encoder_forward_calibrate()+decoder_forward_calibrate()with warmup data (~3-4s), save to cache
Phase 2: Real-data recalibration (on first predict() call):
- After SigLIP processes the first real image, the encoder input (
enc_x) contains realistic activation distributions - Rerun calibration with this real data for more accurate scales
- Recapture CUDA Graph with updated scales
- This happens only once — subsequent
predict()calls skip this step
| Property | Value |
|---|---|
| Location | ~/.flash_rt/calibration/ |
| Key | SHA256(checkpoint_first_64KB + file_size)[:16] + _Se{sequence_length} |
| Format | JSON with enc_scales, ae_scales, enc_alpha, enc_w_scales |
| Invalidation | Automatic per-checkpoint hash. Different checkpoints or finetunes get different caches. |
- Multi-model safe: Each checkpoint produces a unique hash → separate cache files
- Multi-framework safe: Torch (safetensors) and JAX (Orbax) hash different files → separate caches
- Multi-prompt safe: Different prompt lengths produce different
Se→ separate caches - Fine-tune safe: Modified checkpoint → different first 64KB → different hash → fresh calibration
Three ways to force fresh calibration:
# Method 1: At load time
model = flash_rt.load_model(checkpoint, recalibrate=True)
# Method 2: At runtime
model.recalibrate()
model.predict(images=..., prompt="...")
# Method 3: CLI
python examples/quickstart.py --checkpoint /path/to/ckpt --recalibrateOr manually delete the cache:
rm -rf ~/.flash_rt/calibration/model.calibrate() lets you seed the FP8 activation scales with a list
of real observations instead of the default single-frame / zero-input
path. Use it when runtime images cover a wider distribution (different
lighting, object poses, camera angles) than any one calibration frame
could represent.
The API is the same everywhere — one call, any number of observations:
model.calibrate(observations)Everything else has a sensible default. You do not need to change
any other setting: the cache, graph capture, prompt, and predict()
all continue to behave as before.
The common case: you have a robot-rollout dataset, and you want to calibrate on N representative frames before deployment. Three lines:
from flash_rt.datasets.libero import load_calibration_obs
# Pick 8 stratified frames (episode × frame-position) from a LIBERO-
# format dataset. Returns list[dict] — each dict has 'image',
# 'wrist_image', 'state' ready to hand straight to calibrate().
obs_list = load_calibration_obs("/path/to/libero_dataset", n=8)
model.calibrate(obs_list)load_calibration_obs expects the LeRobot-v2 LIBERO layout
(meta/info.json + data/chunk-NNN/episode_NNNNNN.parquet). If your
dataset has a different layout, either:
- Load your observations yourself and pass the list:
obs_list = [
{"image": ..., "wrist_image": ..., "state": ...},
{"image": ..., "wrist_image": ..., "state": ...},
# ... any N >= 1
]
model.calibrate(obs_list)- Or build a pandas DataFrame with
(task_index, episode_index, frame_index, index)columns and use the lower-level helper:
from flash_rt.core.calibration import stratified_sample
obs_list = stratified_sample(my_dataframe, my_load_fn, n=8)
model.calibrate(obs_list)If you pass a single observation (or skip calibrate() entirely — the
first predict() call triggers the same path), FlashRT uses the
legacy calibration pipeline:
model.calibrate([obs]) # explicit N=1
# or simply:
model.predict(obs) # first call auto-calibratesThe first run computes scales from one forward pass and writes them
to ~/.flash_rt/calibration/{ckpt_hash}_Se{N}.json. Every subsequent
process with the same checkpoint reads the cache — no forward pass
required.
Same API, just pass more observations:
model.calibrate(obs_list) # default percentile
model.calibrate(obs_list, percentile=99.9) # explicit (same default)Under the hood: each observation runs one calibration forward pass, per-layer activation maxima are reduced by taking the 99.9 th percentile across samples (so one outlier frame cannot inflate every scale), and the reduced scales are written to the device before the graph is recaptured.
Cache is still used: N >= 2 writes the same JSON format as N = 1, so a second process run with the same checkpoint picks up the reduced scales for free.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
observations |
list[dict] |
required | Obs dicts matching the predict() contract (image, wrist_image, optional state). N = 1 → single-frame path; N >= 2 → multi-sample percentile path. |
percentile |
float |
99.9 |
Percentile applied to per-sample per-tensor amax. 100.0 == traditional max. Lower (e.g. 95) clips more aggressively — useful when your dataset has known outliers. |
max_samples |
int | None |
None |
Upper bound, lets you pass an iterator without materializing the whole list. |
verbose |
bool |
False |
Log a one-line dispersion summary (median amax, outlier cutback, etc.). |
| Frontend | N = 1 | N >= 2 (dataset) |
|---|---|---|
pi05_thor (torch) |
✅ | ✅ |
pi0_thor (torch) |
✅ | ✅ |
pi0fast (torch) |
✅ | ✅ |
pi05_thor_fp4 (torch, FP4 encoder active) |
✅ | ✅ (two-phase: FP8 + AWQ refit) |
pi05_thor_fp4 (jax, FP4 encoder active) |
✅ | ✅ (two-phase: FP8 + AWQ refit) |
pi0_rtx, pi05_rtx (torch + jax) |
✅ | ✅ |
groot_rtx (torch) |
✅ | ✅ |
groot_thor (torch) |
✅ | ❌ (see note) |
pi05_thor / pi0_thor / pi0fast (jax, non-FP4) |
✅ | ❌ (see note) |
Frontends marked ❌ raise NotImplementedError on N >= 2 — pass N = 1
there today. Reasons:
groot_thor: the Thor port of the multi-sample path is staged for the next rollout; the N=1 calibrate path remains the default there. RTX (groot_rtx) ships the full N>=2 path today.- Non-FP4 JAX Thor frontends (
pi05_thor,pi0_thor,pi0fast): the FP8-only JAX path still uses the N=1 implicit-recalibrate shim; the JAX Pi0.5 FP4 frontend (pi05_thor_fp4withframework="jax") does support N>=2, using the same two-phase flow as torch.
pi05_thor_fp4 uses a two-phase multi-sample flow: Phase 1 reduces
FP8 activation scales across N samples (same loop the base class
uses), then Phase 2 collects AWQ per-channel activation amax with
the new FP8 scales active, percentile-reduces across samples, and
refits the NVFP4 packed weights + AWQ inv_s buffers in place — no
second graph capture. Roughly 2× the wall-clock of non-FP4 N samples
because both phases walk the dataset.
| Scenario | Recommended |
|---|---|
| Fixed environment, fine-tuned model | N = 8, percentile = 99.9 |
| Fixed environment, base / non-fine-tuned model | N = 1 at a representative frame |
| Runtime drifts (lighting / outdoor / scene switches) | N = 64–256, percentile = 99.9 |
| Input contains sensor outliers | N >= 256, percentile <= 99.0 |
Measured cosine and calibration-time numbers, plus the precision-vs-coverage trade-off, live in docs/calibration.md §10. The short version: a LIBERO-fine-tuned Pi0.5 gains cos ≈ +0.0003 and halves max per-channel deviation going from N = 1 to N = 8, at the cost of a few seconds of one-off calibration.
If your dataset cannot go through load_calibration_obs, the
lower-level helper takes a pandas DataFrame + a per-index loader:
flash_rt.core.calibration.stratified_sample(
metadata, # pandas.DataFrame with {index, task_index,
# episode_index, frame_index} columns
load_fn, # callable: index -> obs dict
n=8,
*,
task_filter=None, # narrow to one task_index
exclude=None, # skip specific global indices
) -> list[dict]It picks N global frame indices stratified across episode × frame
position (not uniform-random, which would over-sample steady-state
frames) and applies load_fn to each.
After calibration, FlashRT scans the produced per-layer FP8 scales
and logs a WARNING via
flash_rt.core.calibration.check_scale_ceiling if any scale is more
than 20 × the median of the same calibration. This catches the
case where a single outlier frame in the calibration set stretched the
FP8 scale on one layer far beyond its peers — the typical sign that
the dataset contains a glitched / overexposed / occluded sample.
import flash_rt
# === Production deployment (recommended) ===
model = flash_rt.load_model(
checkpoint="/path/to/pi05_libero_pytorch",
framework="torch",
autotune=3, # stable 44ms
)
actions = model.predict(images=[img, wrist], prompt="pick up the red block")
# === JAX with Orbax checkpoint ===
model = flash_rt.load_model(
checkpoint="/path/to/orbax_checkpoint",
framework="jax",
autotune=5, # JAX may need more trials
)
# === After fine-tuning: force recalibration ===
model = flash_rt.load_model(
checkpoint="/path/to/finetuned_checkpoint",
framework="torch",
recalibrate=True, # ignore old cache
)
# === Fast iteration during development ===
model = flash_rt.load_model(
checkpoint="/path/to/checkpoint",
framework="torch",
autotune=0, # skip autotune for fastest startup
)
# === 3-camera setup ===
model = flash_rt.load_model(
checkpoint="/path/to/checkpoint",
framework="torch",
num_views=3,
)
actions = model.predict(
images=[base_img, wrist_left, wrist_right],
prompt="pick up the cup",
)
# === Runtime recalibration (domain shift) ===
model = flash_rt.load_model(checkpoint="/path/to/checkpoint")
actions = model.predict(images=[img1, img2], prompt="task A")
# ... deployment domain changed ...
model.recalibrate()
actions = model.predict(images=[img3, img4], prompt="task B") # fresh calibrationJAX (Orbax) checkpoint loading takes ~42s due to OCDBT deserialization + weight transform + FP8 quantization. The weight cache saves the final FP8-quantized engine weights to disk after first load, so subsequent loads skip all three steps.
| Framework | Cold start | Bottleneck |
|---|---|---|
| Torch (safetensors) | ~3s | mmap load — already fast |
| JAX (Orbax) | ~42s → ~6s with cache | OCDBT deserialize + transform + FP8 quant |
Torch uses safetensors which is essentially a flat binary mmap — there's nothing to cache. JAX's Orbax format requires complex deserialization that the weight cache eliminates.
- First load: Orbax → transform → FP8 quantize → upload to GPU → save binary cache (
~/.flash_rt/weights/{hash}_nv{N}.bin, ~4 GB) - Subsequent loads: Read binary cache → upload to GPU directly (~6s)
# Default: cache enabled (recommended)
model = flash_rt.load_model(checkpoint, framework="jax")
# Disable cache (always re-quantize from Orbax)
model = flash_rt.load_model(checkpoint, framework="jax", weight_cache=False)
# Force re-quantize (clears both weight cache and calibration cache)
model = flash_rt.load_model(checkpoint, framework="jax", recalibrate=True)| Situation | Action |
|---|---|
| First deploy | Automatic — cache miss triggers full load + save |
| Normal restart | Automatic — cache hit, ~6s load |
| After fine-tuning | recalibrate=True or weight_cache=False |
| Checkpoint updated | Automatic — different hash → new cache |
| Debugging precision | weight_cache=False to rule out cache issues |
Each cache file is keyed by SHA256(checkpoint_manifest)[:16] + num_views. Different checkpoints, different fine-tunes, different num_views all produce separate cache files. No cross-contamination.
FlashRT includes a FastAPI server for production deployment. The model loads once at startup; all subsequent requests are pure graph replay (~44ms).
pip install fastapi uvicorn
# Torch
python examples/server.py --checkpoint /path/to/ckpt
# JAX
python examples/server.py --checkpoint /path/to/ckpt --framework jax
# Custom port + thorough autotune
python examples/server.py --checkpoint /path/to/ckpt --port 9000 --autotune 5GET /health — Health check
{"status": "ok", "framework": "torch", "version": "2.2.0", "prompt": "pick up the red block"}POST /predict — Run inference
{
"prompt": "pick up the red block",
"images": ["<base64_raw_uint8>", "<base64_raw_uint8>"],
"image_shape": [224, 224, 3]
}Response:
{
"actions": [[0.1, -0.2, ...], ...],
"latency_ms": 44.3,
"shape": [10, 7]
}If images is omitted, dummy random images are used (for testing).
# Simple test (dummy images)
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"prompt": "pick up the red block"}'
# With real images (Python)
python -c "
import requests, base64, numpy as np
img = np.random.randint(0, 255, (224, 224, 3), dtype=np.uint8)
b64 = base64.b64encode(img.tobytes()).decode()
resp = requests.post('http://localhost:8000/predict', json={
'prompt': 'pick up the red block',
'images': [b64, b64],
})
print(resp.json()['shape'], resp.json()['latency_ms'], 'ms')
"The server uses an asyncio lock to ensure only one inference runs at a time (single GPU). Concurrent requests are queued automatically.
# Basic inference
python examples/quickstart.py --checkpoint /path/to/ckpt
# JAX framework
python examples/quickstart.py --checkpoint /path/to/ckpt --framework jax
# Benchmark 20 iterations
python examples/quickstart.py --checkpoint /path/to/ckpt --benchmark 20
# Thorough autotune
python examples/quickstart.py --checkpoint /path/to/ckpt --autotune 5
# Force recalibration
python examples/quickstart.py --checkpoint /path/to/ckpt --recalibrate
# LIBERO evaluation
python examples/thor/eval_libero.py \
--checkpoint /path/to/ckpt \
--task_suite libero_spatial \
--framework torch
# Quick LIBERO test (3 tasks × 3 episodes)
python examples/thor/eval_libero.py \
--checkpoint /path/to/ckpt \
--task_suite libero_spatial --quick
# HTTP server
python examples/server.py --checkpoint /path/to/ckpt --port 8000Typical load_model() + first predict() timing on Jetson AGX Thor:
| Phase | Torch | JAX (no cache) | JAX (cached) |
|---|---|---|---|
| Load checkpoint + FP8 quantize | ~3s | ~42s | ~6s |
set_prompt(): tokenize + RoPE + time conditioning |
~0.1s | ~0.1s | ~0.1s |
set_prompt(): SigLIP graph capture |
~0.5s | ~0.5s | ~0.5s |
set_prompt(): calibration (cache miss) |
~3s | ~3s | ~3s |
set_prompt(): calibration (cache hit) |
0s | 0s | 0s |
set_prompt(): autotune=3 |
~1s | ~1.5s | ~1.5s |
First predict(): real-data recalibration |
~1.5s | ~1.5s | ~1.5s |
Subsequent predict(): graph replay |
~44ms | ~44ms | ~44ms |
After the first predict(), all subsequent calls are pure CUDA Graph replay at ~44ms.
With weight cache + calibration cache, JAX warm start is ~6s (vs ~42s cold start).
| Phase | Default | Max-perf (decode_cuda_graph=True) |
|---|---|---|
| Load checkpoint + FP8 quantize | ~5s | ~5s |
set_prompt(): calibration (cache miss) |
~2.4s | ~2.4s |
set_prompt(): calibration (cache hit) |
0s | 0s |
set_prompt(): SigLIP + prefill graph |
~0.3s | ~0.3s |
set_prompt(): decode graph capture |
— | ~1.5s |
First predict(): real-data recalibration |
~2.8s | ~2.8s |
Subsequent predict() (50 tokens) |
~480ms | ~447ms |
With calibration cache, default-mode set_prompt() drops from ~2.5s to ~0.1s.
Max-perf mode is ~1.5s (decode graph capture dominates after cache hit).
Optional NVFP4 (Blackwell block-scaled FP4) quantization on the Pi0.5
encoder FFN stack, enabled via a single flag use_fp4=True. Currently
only supported on Pi0.5 torch. The gate applies in two directions:
- Other configs (
pi0/groot/pi0fast) log a warning and fall back to FP8. framework="jax"withuse_fp4=Truealso logs a warning and falls back to FP8, even withconfig="pi05"— JAX FP4 is not yet wired up (planned, see handoff prompt Task A).
# Production-recommended — single flag, best-known config:
model = flash_rt.load_model(
checkpoint,
config="pi05",
use_fp4=True,
)
# Equivalent to passing:
# fp4_layers=tuple(range(18)) # full encoder FFN (18 layers)
# use_awq=True # required for 18-layer scope
# use_p1_split_gu=True # production P1 path
# Advanced: override sub-flags for A/B or debug:
model = flash_rt.load_model(
checkpoint, config="pi05",
use_fp4=True,
fp4_layers=(7, 8, 9), # conservative subset
use_awq=False,
use_p1_split_gu=False,
)When use_fp4=True and a sub-flag (fp4_layers, use_awq,
use_p1_split_gu) is left as None, it resolves to the production preset:
| Sub-flag | Preset value | Reason |
|---|---|---|
fp4_layers |
tuple(range(18)) |
Full encoder FFN coverage |
use_awq |
True |
Required for 18-layer scope (without AWQ, full-scope FP4 cos collapses to ~0.33) |
use_p1_split_gu |
True |
Split Gate+Up → 2× fp4out GEMM + combiner (Pi0.5 parity, Pi0.6 reusable) |
- GEMMs: all Gate+Up / Down proj GEMMs across the 18 FFN layers run in NVFP4 (block-size 16, UE4M3 scales, Sm1xxBlockScaledConfig tile layout) instead of FP8. Attention (QKV, O) stays FP8 fp16-output.
- P1 split-GU: gate_proj and up_proj run as two separate
cutlass_fp4_gemm_fp4outGEMMs (FP4-packed output + SFA via theLinCombBlockScaleFactorepilogue — proven CUTLASS pattern). A fusedgeglu_two_mul_fp4_to_fp4combiner reads both FP4 inputs, applies GELU + Down-AWQ inv_s + per-block FP4 quant, and writes the packed FP4 + SFA directly for the Down GEMM. Eliminates ~31 MB/layer of fp16 DRAM round-trip vs the merged-GU path. - AWQ (activation-aware weight quant): per-input-channel pre-scale
s[k] = (a[k]/mean(a))^awq_alphaon each NVFP4 weight, with the matching inverse scale fused into the pre-GEMM kernels (residual_add_rms_norm_mul_fp4_sfafor Gate+Up input,geglu_two_mul_fp4_to_fp4for Down input). Calibrated on firstpredict()with real images, requantized in-place so the captured CUDA Graph remains valid. - Residual stream: stays fp16 through the FP4 region (NVIDIA
enable_llm_nvfp4design —output_quantizerdisabled). - Non-FP4 paths: attention, decoder, SigLIP are unchanged (bit-identical to the FP8 baseline).
When use_fp4=True, the FP4 layer weights are loaded directly as fp16 from
safetensors and NVFP4-quantized offline (no FP8 intermediate). This matches
the NVIDIA modelopt design and avoids a double-lossy FP8 → fp16 → FP4
round-trip. A fp8-dequant fallback path exists if direct fp16 load fails.
- SM100+ GPU with Blackwell Tensor Cores (validated on Thor SM110). Hardware without NVFP4 support silently falls back to FP8.
flash_rt_fp4.soextension built alongsideflash_rt_kernels.so(automatic in standard install).
Pi0.5 on Jetson AGX Thor, LIBERO Spatial 10 tasks × 50 trials = 500 episodes:
| Config | Success | E2E P50 (normal regime) |
|---|---|---|
| FP8 baseline | 491 / 500 (98.2%) | ~43.5 ms |
NVFP4 full-18 + AWQ + P1 (--use_fp4) |
491 / 500 (98.2%) | ~43.5 ms |
Task-level parity with the FP8 baseline. In-graph kernel-sum profile shows -2.1 ms/infer theoretical saving, but CUDA Graph per-node scheduling overhead on the full ~60-kernel pipeline absorbs most of it — net wall-clock P50 is at parity in the production regime. The kernels are designed to scale linearly on Pi0.6 (~2× compute) where per-node overhead stays constant while per-kernel savings grow.
Multi-model precision regression (tests/test_all_models_precision.py):
| Model | Config | cos vs reference | P50 |
|---|---|---|---|
| Pi0.5 | FP8 baseline | vs_prod=0.9984, vs_old_torch=0.9999 | 44.5 ms |
| Pi0.5 | use_fp4=True preset |
vs_pytorch_ref=0.9989, vs_prod=0.9974 | 43.3 ms |
| Pi0 | (unchanged) | vs_pytorch_ref=0.9972 | 46.7 ms |
| Pi0 JAX | (unchanged) | vs_pytorch_ref=0.9983 | 45.1 ms |
| GROOT N1.6 | (unchanged) | vs_pytorch_ref=0.9986 | 46.2 ms |
fp4_layers accepts any subset of encoder layer indices 0-17. Two
configurations are task-level LIBERO-validated:
tuple(range(18))+ AWQ (production preset —--use_fp4default)(7, 8, 9)without AWQ (the conservative subset, from the first FP4 drop)
Other subsets are simulation-only (see the internal precision report).
- Decoder FP4 — precision simulation (S2: decoder all-proj) has cos 0.9985 and passed LIBERO quick 9/9. Full kernel integration planned (est. -6 ms E2E).
- SigLIP FFN FP4 — precision simulation favorable, integration requires fp16-native SigLIP weight loader.
- FP4 on Pi0 / GROOT / Pi0-FAST — architecture supports it; frontend subclasses not yet written. Kernels are reusable without change.
- Full fp16 fallback (
use_fp8=False) — requires a complete fp16 GEMM / RMSNorm pipeline, not yet implemented.
Opt-in CFG inference path for advantage-conditioned VLA policies
trained with the RECAP recipe (π*0.6,
arXiv:2511.14759). The default
infer() path is unchanged; RL mode is activated explicitly.
rt = Pi05TorchFrontendRtx("/path/to/pi05_libero_pytorch", num_views=2)
# Opt-in to advantage-conditioned CFG (rebuilds pipeline as Pi05CFGPipeline)
rt.set_rl_mode(cfg_enable=True, cfg_beta=1.5)
rt.set_prompt("fold the t-shirt") # cond/uncond prompt pair embedded internally
rt.calibrate([obs])
actions = rt.infer(obs)["actions"] # runs encoder x2 + decoder x2 per step
# Revert to the standard path any time
rt.set_rl_mode(cfg_enable=False)Support matrix (v0.1.0):
| Frontend | CFG inference |
|---|---|
pi05_rtx (torch) |
✅ |
pi0_rtx, pi0fast, groot_rtx, all Thor / JAX frontends |
❌ (pi0-RTX pattern ports planned) |
Measured latency (RTX 5090, pi05_libero_pytorch, FP8):
| path | median (ms) | note |
|---|---|---|
| Baseline (no CFG) | 19.0 | single forward, graph replay |
| CFG β=1.5 serial (Phase 2) | 37.1 | 2× sequential forward, graph replay |
| CFG β=1.5 fused batched (Phase 3b) | 25.9 | cond+uncond in one B=2 forward |
For sustained 50 Hz real-robot control, combine RL mode with batched mode to get the fused CFG path:
rt.set_batched_mode(enable=True)
rt.set_rl_mode(cfg_enable=True, cfg_beta=1.5)
rt.set_prompt("fold the t-shirt")
rt.calibrate([obs])
actions = rt.infer(obs)["actions"] # 25.9 ms / callFull latency table, numerical contract, and generic batched (RL rollout) roadmap are in docs/rl_inference.md.