Kernels:
Trusted publisher
AMD FastWAM kernels
AMD-optimised Triton kernels and runtime path for FastWAM (the LIBERO policy libero_uncond_2cam224 from
yuanty/fastwam) on AMD Instinct MI355X, packaged for the
kernels library.
Policy latency on AMD Instinct MI355X (one decision = one action chunk; 10 denoising steps, batch 1):
| FastWAM path | latency per decision | with this package |
|---|---|---|
| with this package | 23.57 ms | - |
model's own torch.compile path |
75.3 ms | 3.2x faster |
plain torch.compile(model.infer_action) |
86.9 ms | 3.7x faster |
| eager PyTorch | 232.3 ms | 9.9x faster |
Medians of fresh-process runs in one interleaved session on one MI355X (the package: 23.5-24.3 ms across sessions); outputs equivalent to the fp64-referenced eager model, see VALIDATION.md.
Built with Hugging Face kernel-builder (huggingface/kernels commit 21bdf69); see VALIDATION.md for build provenance.
What this package is
This is a model-bound package, not a set of generic drop-in operators. It ships the four AMD-optimised FastWAM model
modules (mot, action_dit, wan_video_dit, wan_video_vae) of the optimised FastWAM source tree in
AMD-AGI/faster-action-models (commit a5fa731). Algorithms are
unchanged. The differences: the custom ops are registered in this build's own op namespace instead of the fixed
fastwam / fastwam_vae namespaces (see Guidance); one kernel family without a measured in-situ win is removed (see
Validation); mot.py sets a 256 MiB hipBLASLt workspace by default (HIPBLASLT_WORKSPACE_SIZE, unless already set);
wan_video_vae.py runs its compiled encode region for batch 1 only (see the limitation below); some comments are
reworded. install() routes the stock modules of the same names to them. The modules contain:
- Triton kernels: split-K GEMMs with fused residual / LayerNorm / modulation epilogues, fused QKV post-processing (RMSNorm + RoPE + KV-cache store), short-sequence and QK-RMS attention, time-embedding GEMVs;
- the runtime path: HIP-graph capture of the video prefill and of the action-denoise step, per-episode context
memoisation, fused projection weights, and the regional
torch.compilethe modules apply themselves.
The package pins:
- the host code it plugs into: faster-action-models
src/fastwam-baselineat a5fa731 (the stock FastWAM tree; the 9 files the modules import are sha256-pinned);install()refuses any other tree; - the checkpoint layout of
libero_uncond_2cam224.pt; seeverify_checkpoint.
The model weights are not part of this package; they come from yuanty/fastwam under their own terms.
Requirements: AMD Instinct MI355X (gfx950); torch 2.11.0+rocm7.14.0 and triton 3.7.1 (validated); kernels >= 0.14
(0.14.1 validated) with huggingface_hub 2.4.0, transformers 5.24.1 and tokenizers 0.23.3; the FastWAM runtime
dependencies of faster-action-models (hydra-core, omegaconf, einops, safetensors, accelerate; its
docker/Dockerfile.eval installs them).
Usage
A complete example: it downloads the checkpoint libero_uncond_2cam224.pt from yuanty/fastwam and the Wan2.2 assets
FastWAM's loader reads, gets the faster-action-models source tree this package is pinned to, installs the kernels, runs
one policy decision on a dummy observation and then times 40 decisions after warm-up. The instruction is encoded into
the prompt context once, as a policy server does per task, and every decision reuses it. The downloads are about 26 GB:
the 12 GB checkpoint and the Wan2.2 VAE, umT5 text encoder and tokenizer.
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 fastwam_example.py in the same directory and run python fastwam_example.py:
import os
import statistics
import sys
import time
import torch
from huggingface_hub import hf_hub_download, snapshot_download
from kernels import get_kernel
# 1. The checkpoint (yuanty/fastwam, pinned revision), and the Wan2.2 assets FastWAM's loader reads from
# DIFFSYNTH_MODEL_BASE_PATH (pinned revisions).
rev = "8eaceeb24c3cc92ff2a9c9a9d266a4941b836705"
ckpt = hf_hub_download("yuanty/fastwam", "libero_uncond_2cam224.pt", revision=rev)
stats = hf_hub_download("yuanty/fastwam", "libero_uncond_2cam224_dataset_stats.json", revision=rev)
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")
# 2. The kernels: install() BEFORE FastWAM's model modules are imported.
sys.path.insert(0, os.path.abspath("faster-action-models/src/fastwam-baseline"))
fwk = get_kernel("amd/fastwam-kernels", version=1)
fwk.install()
fwk.verify_checkpoint(ckpt) # raises on another checkpoint layout
# 3. Build FastWAM as faster-action-models' LIBERO evaluator does for this tree
# (FastWAM/experiments/libero/eval_libero_single.py with the FastWAM/configs_baseline config tree).
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)])
with initialize_config_dir(version_base="1.3",
config_dir=os.path.abspath("faster-action-models/FastWAM/configs_baseline")):
cfg = compose(config_name="sim_libero", overrides=["task=libero_uncond_2cam224_1e-4", f"ckpt={ckpt}"])
model = instantiate(cfg.model, model_dtype=torch.bfloat16, device="cuda")
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(stats))
# 4. 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; reused by every decision
def decide():
with torch.no_grad():
return 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)
out = decide()
print("action chunk:", tuple(out["action"].shape)) # 32 steps x 7 (normalised; eef delta 6 + gripper 1)
# 5. Latency: 25 warm-up decisions (compilation, autotuning, graph capture), then 40 timed decisions.
for _ in range(25):
decide()
torch.cuda.synchronize()
times = []
for _ in range(40):
t0 = time.perf_counter()
decide()
torch.cuda.synchronize()
times.append((time.perf_counter() - t0) * 1000.0)
print(f"latency per decision: {statistics.median(times):.1f} ms (median of 40)")
The first decisions include compilation, autotuning and graph capture, so the script times only after 25 warm-up
decisions. In the validated run of this example (fresh environment, one MI355X) it printed action chunk: (32, 7) and
latency per decision: 24.7 ms (median of 40). The evaluator turns the normalised chunk into robot actions
(_denormalize_action, then its gripper post-processing) before it steps the environment.
Guidance:
- Call
install()before the model modules are imported. It raises if FastWAM was imported first. - Do not wrap the model in
torch.compileyourself: the package compiles its own regions and replays captured HIP graphs; an outer compile only adds guards and dispatch. FASTWAM_KVSLABmust be 0;install()enforces it (KVSLAB=1hits a known inductor aliasing bug).- 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 (fwk.OPS_NAMESPACE, e.g._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 (tests/test_op_namespace.py).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) |
kernels / huggingface_hub / transformers / tokenizers |
0.14.1 / 2.4.0 / 5.24.1 / 0.23.3 (validated) |
| model / checkpoint | FastWAM libero_uncond_2cam224.pt (yuanty/fastwam) only |
| host code | faster-action-models src/fastwam-baseline @ a5fa731 only |
| batch, steps | B=1 (one observation per infer_action call, as upstream), 10 steps (validated) |
Limitation: batch size and input shapes. infer_action takes one observation per call (batch 1), as upstream
FastWAM, and only batch 1 with the deployed shape (2 x 224x224 cameras, 32-step action horizon) was validated. The VAE
encode's compiled region serves batch 1 only: in validation that compiled region returned wrong values at batch 16
(errors of the order of the output, NaN in one row), so a direct encode call with any other batch size runs the same
region eagerly - correct values, no compile speed-up (tests/test_vae_encode_batch_shapes.py, VALIDATION.md section 2).
The two captured HIP graphs (video prefill, action-denoise step) are keyed on the shapes, strides and dtypes of their
inputs: a call with other shapes re-captures them (at most 4 times per region per process; after that the region runs
uncaptured).
Validation (summary; details in VALIDATION.md)
- End to end. 23.57 ms per decision against 75.3 ms for FastWAM's own
torch.compilepath (3.2x), 86.9 ms for plaintorch.compile(model.infer_action)and 232.3 ms eager (MI355X, B=1, 10 steps, fresh process per measurement, interleaved order). - Op level. In the release-confirm session 11 of the 12 shipped kernel families beat the inductor-lowered torch code
they replace, in situ (switching one off slows the whole decision by 1.7 % to 30 %). PFGEMM (OFF/ON 0.996) did not
show a win in that session, after a win in the earlier validation; see
VALIDATION.md. A 13th family (the video-prefill fused Q/K post-processing) showed no win earlier and is removed. - Parity vs an fp64 reference. RMS error of the actions 1.06e-02 vs 1.32e-02 for eager bf16.
- Accuracy. For task accuracy (LIBERO success rates) see the FastWAM paper (arXiv:2603.16666) and the yuanty/fastwam model card.
Licence
Apache-2.0, the licence of AMD-AGI/faster-action-models. The shipped model modules keep their upstream headers:
mot.py, action_dit.py are "Modifications Copyright (c) 2026 Advanced Micro Devices, Inc. / SPDX-License-Identifier:
MIT" (FastWAM-derived, licenses/FastWAM-MIT.txt); wan_video_dit.py, wan_video_vae.py are based on Wan2.x /
DiffSynth-Studio (Apache-2.0) via FastWAM (MIT). See NOTICE. The model weights are not part of this package.
- Downloads last month
- -
- Kernel Builder
- 21bdf69
