Kernels:
Trusted publisher
AMD CAE-FastWAM kernels
AMD-optimised Triton kernels and runtime path for AMD CAE-FastWAM
(amd/CAE-FastWAM, the Compact Action Expert LIBERO policy) on AMD Instinct
MI355X, packaged for the kernels library.
Built with Hugging Face kernel-builder (huggingface/kernels commit 21bdf69); see VALIDATION.md for build provenance.
Policy latency on AMD Instinct MI355X (one decision = one action chunk; 10 denoising steps, batch 1):
| CAE-FastWAM path | latency per decision | with this package |
|---|---|---|
| with this package | 13.6 ms | - |
model's own torch.compile path |
48.5 ms | 3.6x faster |
plain torch.compile(model.infer_action) |
82-90 ms | ~6x faster |
| eager PyTorch | 204 ms | ~15x faster |
The package keeps CAE-FastWAM's outputs equivalent (fp64-referenced parity); full method, per-session numbers and accuracy checks are in VALIDATION.md.
What this package is
This is a model-bound package, not a set of generic drop-in operators. It ships the four AMD-optimised CAE-FastWAM
model modules (mot, action_dit, wan_video_dit, wan_video_vae) from
AMD-AGI/faster-action-models src/cae-fastwam (commit a5fa731).
Algorithms and configuration are unchanged. The only code change is where the custom ops are registered: in this
build's own op namespace instead of the fixed fastwam / fastwam_vae namespaces (see Guidance); some comments and
docstrings are reworded (wording only).
install() routes the stock modules of the same names to them. The modules contain:
- Triton kernels for the action expert: fused QKV post-processing (RMSNorm + RoPE + cache store), short-sequence attention, fused FFN and AdaLN-modulation programs, o-projection and cross-layer fusions, attention-mask bias tiles;
- the video prefill: a native-layout Triton FMHA, fused QKV post-processing and fp8 weight-streaming GEMMs;
- fused Wan-VAE encode kernels;
- runtime levers: in-place K/V buffers, fused projection weights, step-invariant hoists, graph-input staging and the VAE
encode graph. These run inside CAE-FastWAM's own compiled regions (
compile_action_infer=True).
The package pins:
- the host code it plugs into: faster-action-models
FastWAM/srcat a5fa731 (16 inference-path files, sha256);install()refuses any other tree; - the checkpoint layout of
amd/CAE-FastWAM(policy.pt,action_vae.pt); seeverify_checkpoint.
Nine kernel families showed no in-situ win over their fallback in validation. They are switched off by install(), and
users cannot re-enable them. Their source stays in the files, as in the faster-action-models release.
Requirements: AMD Instinct MI355X (gfx950); torch 2.11.0+rocm7.14.0 and triton 3.7.1 (ROCm 7.14 user-space from the torch wheel; validated); kernels >= 0.14 (0.14.1 validated), which needs huggingface_hub >= 1, so pair it with transformers 5.24.1 + tokenizers 0.23.3 (GPU-validated with huggingface_hub 2.4.0 and kernels 0.14.1); the older transformers 4.49 / tokenizers 0.21 pair needs huggingface_hub < 1 and therefore works only with kernels 0.12.x.
Usage
A complete example: it downloads the checkpoint from the Hub, gets the faster-action-models source tree this package is pinned to, installs the kernels and runs one policy decision on a dummy observation.
It needs an AMD Instinct MI355X with torch 2.11.0+rocm7.14.0 and triton 3.7.1 (see Requirements) and the FastWAM runtime
dependencies of faster-action-models (hydra-core, omegaconf, einops, safetensors, accelerate; its
docker/Dockerfile.eval installs them). The downloads are about 24 GB: the 10 GB policy.pt and the Wan2.2 VAE, umT5
text encoder and tokenizer that FastWAM's loader reads.
pip install kernels==0.14.1 huggingface_hub==2.4.0 transformers==5.24.1 tokenizers==0.23.3
git clone https://github.com/AMD-AGI/faster-action-models.git
git -C faster-action-models checkout a5fa73101988870e51f04fe1e7be5da56dda3841
Save this script as cae_fastwam_example.py in the same directory and run python cae_fastwam_example.py:
import os
import sys
import torch
from huggingface_hub import snapshot_download
from kernels import get_kernel
# 1. The checkpoint, and the Wan2.2 assets FastWAM's loader reads from DIFFSYNTH_MODEL_BASE_PATH (pinned revisions).
cae_dir = snapshot_download("amd/CAE-FastWAM", revision="00e05b3f7b7601c648e7c2fce380abe553db41bf",
allow_patterns=["policy.pt", "action_vae.pt", "config.json", "stats/*"])
wan_root = os.path.abspath("checkpoints")
snapshot_download("Wan-AI/Wan2.2-TI2V-5B", revision="921dbaf3f1674a56f47e83fb80a34bac8a8f203e",
allow_patterns=["Wan2.2_VAE.pth", "models_t5_umt5-xxl-enc-bf16.pth"],
local_dir=f"{wan_root}/Wan-AI/Wan2.2-TI2V-5B")
snapshot_download("Wan-AI/Wan2.1-T2V-1.3B", revision="37ec512624d61f7aa208f7ea8140a131f93afc9a",
allow_patterns=["google/umt5-xxl/*"], local_dir=f"{wan_root}/Wan-AI/Wan2.1-T2V-1.3B")
os.environ.update(DIFFSYNTH_MODEL_BASE_PATH=wan_root, DIFFSYNTH_SKIP_DOWNLOAD="true",
ACTION_VAE_CKPT=f"{cae_dir}/action_vae.pt") # read by the per-suite task config
# 2. The kernels: install() BEFORE FastWAM's model modules are imported.
sys.path.insert(0, os.path.abspath("faster-action-models/FastWAM/src"))
cae = get_kernel("amd/cae-fastwam-kernels", version=1)
cae.install()
cae.verify_checkpoint(f"{cae_dir}/policy.pt", f"{cae_dir}/action_vae.pt") # raises on another checkpoint layout
# 3. Build CAE-FastWAM as faster-action-models' LIBERO evaluator does
# (FastWAM/experiments/libero/eval_libero_single.py, launched by eval/native/run_fastwam_libero.sh --arm cae).
from hydra import compose, initialize_config_dir
from hydra.utils import instantiate
from omegaconf import OmegaConf
from fastwam.datasets.lerobot.utils.normalizer import load_dataset_stats_from_json
OmegaConf.register_new_resolver("eval", eval)
OmegaConf.register_new_resolver("max", lambda x: max(x))
OmegaConf.register_new_resolver("split", lambda s, idx: s.split("/")[int(idx)])
suite, suite_id = "libero_spatial", 0 # action-VAE suite ids: libero_spatial 0, libero_object 1, libero_goal 2, libero_10 3
with initialize_config_dir(version_base="1.3", config_dir=os.path.abspath("faster-action-models/FastWAM/configs")):
cfg = compose(config_name="sim_libero", overrides=[
f"task=libero_uncond_2cam224_1e-4_32hdim_latent_K8d16_freebits_pernorm_joint_{suite}",
f"ckpt={cae_dir}/policy.pt",
"model.redirect_common_files=false",
])
model = instantiate(cfg.model, model_dtype=torch.bfloat16, device="cuda")
model.action_vae_suite_id = suite_id
model.load_checkpoint(str(cfg.ckpt))
model = model.to("cuda").eval()
processor = instantiate(cfg.data.train.processor).eval()
processor.set_normalizer_from_stats(load_dataset_stats_from_json(f"{cae_dir}/stats/{suite}.json"))
# 4. One policy decision on a dummy observation: agent-view and wrist RGB images, 224x224 each, side by side, scaled
# to [-1, 1], and the 8-dim LIBERO state (eef position 3, axis-angle 3, gripper qpos 2), normalised as the evaluator does.
image = torch.zeros(1, 3, 224, 448, device="cuda", dtype=model.torch_dtype)
state = processor.action_state_transform({"state": {"default": torch.zeros(1, 8)}})
proprio = processor.normalizer.forward(state)["state"]["default"]
prompt = ("A video recorded from a robot's point of view executing the following instruction: "
"pick up the black bowl between the plate and the ramekin and place it on the plate")
context, context_mask = model.encode_prompt(prompt) # once per instruction; reuse it for every decision
with torch.no_grad():
out = model.infer_action(prompt=None, context=context, context_mask=context_mask, input_image=image,
action_horizon=32, proprio=proprio, negative_prompt="", text_cfg_scale=1.0,
num_inference_steps=10, sigma_shift=None, seed=42, rand_device="cpu", tiled=False,
compile_action_infer=True)
print("action chunk:", tuple(out["action"].shape)) # 32 steps x 7 (normalised; eef delta 6 + gripper 1)
Note: the text context depends only on the instruction, so encode it once and reuse it; passing prompt= to infer_action instead re-runs the umT5 text encoder in every call (measured warm on MI355X: 27.7 ms per decision instead of 14.1 ms).
The first calls compile, autotune and capture graphs, so the first decision is slow; measure only after warm-up (see
Guidance). The evaluator turns the normalised chunk into robot actions (_denormalize_action, then its gripper
post-processing) before it steps the environment.
This package is pinned to the faster-action-models runtime above: the LeRobot-format checkpoint
amd/CAE-FastWAM-lerobot runs on LeRobot's own cae_fastwam policy
code, which this package does not patch (LeRobot users: see that model card).
Guidance:
- Call
install()before the model modules are imported. It raises if FastWAM was imported first. - Use
compile_action_infer=True. That is the path that was measured. Do not wrap the model intorch.compileyourself: the package already runs inside CAE-FastWAM's own compiled regions. - The first ~25 calls include compilation, autotuning and graph capture. Measure after warm-up, and give each
configuration its own
TORCHINDUCTOR_CACHE_DIR. - The custom ops register in this build's own
torch.librarynamespace (cae.OPS_NAMESPACE, e.g._cae_fastwam_kernels_rocm_<build id>, from the generated_ops.py), not in a fixedfastwamnamespace. The package can therefore share a process with the faster-action-models source tree or another build without op-name collisions.install()still replaces the FastWAM model modules of the one FastWAM tree onsys.path, so install one build per FastWAM tree.
Support matrix
| status | |
|---|---|
| AMD Instinct MI355X (gfx950) | validated |
| AMD Instinct MI300X (gfx942) | not validated; not in rocm-archs |
| torch / triton | 2.11.0+rocm7.14.0 / 3.7.1 (validated) |
| transformers / tokenizers / huggingface_hub | 5.24.1 / 0.23.3 / 2.4.0 with kernels 0.14.1 (GPU-validated); 4.49.0 / 0.21.4 / 0.36.2 with kernels 0.12.1 (GPU-validated) |
| model / checkpoint | CAE-FastWAM / amd/CAE-FastWAM only |
| host code | faster-action-models FastWAM/src @ a5fa731 only |
| batch, steps | B=1, 10 steps (validated) |
| VAE encode batch size | one per process on the encode graph; other batch sizes run the eager encode (see below) |
kernels |
0.12.1 and 0.14.1 (GPU-validated); 0.19.0 (load / install check). kernels >= 0.14 needs huggingface_hub >= 1: see Requirements and VALIDATION.md section 8 |
Limitation: one VAE encode batch size per process. The VAE encode runs as a captured graph (FASTWAM_VAEGRAPH=1,
the default). The graph serves one input shape per process: the first one encoded (B=1 in infer_action, the validated
configuration). A call with any other input shape in the same process (for example another batch size) runs the eager
encode instead: one output row per input row, no graph speed-up. Builds before 93316e3 did not have this guard: a process
that encoded more than one batch size could get the rows recorded for another batch size (for example 128 rows for a
32-row input). VALIDATION.md section 11 has the tests and results. FASTWAM_VAEGRAPH=0 turns
the encode graph off.
Validation (summary; details in VALIDATION.md)
| path (MI355X, B=1, 10 steps, blog latency harness, median of 5 interleaved rounds) | ms |
|---|---|
| stock eager | 203.7 |
stock torch.compile(model.infer_action) |
89.7 |
stock CAE-FastWAM compiled path (compile_action_infer=True) |
49.0 |
| this package, every family on | 12.83 |
| this package, shipped configuration (confirm session, 3 rounds) | 13.63 |
| release build before the package rename (commit 485e6e2; release confirm, 3 rounds; stock compiled path 48.26, naive compile 88.60 in the same session) | 13.62 |
| renamed, op-namespaced build (commit 4df202e; same session: build above 13.62, stock compiled path 48.50, naive compile 81.67) | 13.63 |
| build 47c28dc (text-only rewording of 4df202e; spot check, 3 rounds; same session: stock compiled path 48.12, naive compile 89.97) | 13.58 |
The shipped build (commit 93316e3) differs from 47c28dc in how the package finds its own files when it is
loaded from the Hub cache (VALIDATION.md section 9) and in an input-shape guard on the VAE encode graph (section 11);
kernels and configuration are unchanged.
- Op level. 20 of 29 kernel families beat their fallback in situ, by 1.1 % to 91 % end to end. The other 9 are switched off.
- Parity vs an fp64 reference. RMS error is 1.32e-2, against 2.02e-2 for eager bf16.
- For task accuracy (LIBERO success rates), see the amd/CAE-FastWAM model card: https://huggingface.co/amd/CAE-FastWAM
Licence
Apache-2.0, the licence of AMD-AGI/faster-action-models. The shipped model modules keep their upstream headers:
FastWAM-derived (MIT, (c) 2026 The FastWAM Authors), with Wan2.x / DiffSynth-Studio portions (Apache-2.0). See
LICENSE, NOTICE and licenses/. The model weights are not part of this package.
- Downloads last month
- -
- Kernel Builder
- 21bdf69
