NAT action tokenizer
Turns robot action chunks into discrete tokens for a vision-language-action model, and tokens back into actions. Every 32-step chunk of up to 7 action columns becomes 14 tokens, in time order, so a model can stream actions before it has generated the whole chunk.
Paper: NAT: Scaling Causal Neural Action Tokenizers Across Embodiments. Code: github.com/ahadjawaid/nat.
Quick start
pip install nat-tokenizer
import numpy as np
from nat_tokenizer import NATActionTokenizer
tokenizer = NATActionTokenizer.from_pretrained() # downloads ahad-j/nat-tokenizer-h32-l4-c6400
# 1. Fit the normalization once, on your dataset's actions (any shape ending in action_dim).
tokenizer.fit(dataset_actions)
# 2. Tokenize 32-step chunks: (batch, 32, action_dim) or one chunk (32, action_dim).
tokens = tokenizer(action_chunks) # list (one per chunk) of lists of ints in [0, 25600)
# 3. Decode back to actions in your original units.
actions = tokenizer.decode(tokens, action_dim=action_chunks.shape[-1]) # (batch, 32, action_dim)
# 4. Save the fitted tokenizer (keeps your min and max) and load it later the same way.
tokenizer.save_pretrained("my-nat-tokenizer")
tokenizer = NATActionTokenizer.from_pretrained("my-nat-tokenizer")
Normalization (on by default)
The tokenizer was trained on actions in [-1, 1]. With normalize=True (the default) every column is mapped from
its min and max to [-1, 1] before encoding (values outside are clipped) and decoded actions are mapped back, so you
work in your own units throughout. Set the min and max with fit(dataset_actions), or pass them directly:
tokenizer = NATActionTokenizer.from_pretrained(action_min=[...], action_max=[...])
If your actions are already in [-1, 1], pass normalize=False to both calls:
tokenizer(chunks, normalize=False) and tokenizer.decode(tokens, action_dim=d, normalize=False).
A column whose min equals its max is encoded as 0 and decoded back to its constant value.
Streaming (causal decoding)
Within a group the 14 tokens are time ordered: the first 4 decode the chunk's first 8 steps, the first 7 its first 16,
the first 11 its first 24, and all 14 the whole chunk. A prefix decodes exactly the same first steps as the full chunk,
so a model can execute actions while it is still generating. stream() decodes one chunk token by token and returns each
latent's 8 actions as soon as its tokens are complete:
stream = tokenizer.stream(action_dim=7)
for token in generated_tokens: # one at a time, as your model generates them
actions = stream.push(token) # (8, 7) when a latent completes, else (0, 7)
if len(actions):
robot.execute(actions)
For real-time chunking, the next chunk can be generated while the robot executes the last actions of the current
one, so that it starts with them. tokens_starting_with turns those actions into the first tokens of the next chunk;
the model generates only the tokens after them, and the robot switches to the new chunk without a jump:
prefix = tokenizer.tokens_starting_with(executing_actions) # (batch, steps, d), steps ending a latent (8, 16 or 24)
# continue the model's generation after `prefix`, then decode the whole token list
A prefix of whole latents also decodes directly:
for steps in (8, 16, 24, 32):
prefix = [chunk[:tokenizer.prefix_token_count(steps)] for chunk in tokens]
first_steps = tokenizer.decode(prefix, action_dim=7) # (batch, steps, 7)
Streaming works for actions of up to 7 columns (one group).
Action dimensions
Columns are split into consecutive groups of up to 7 (8 columns = 7 + 1, 14 = 7 + 7, 21 = 7 + 7 + 7). Each group gets
its own 14 tokens and a chunk's tokens are the groups' tokens one after another: tokenizer.tokens_per_chunk(action_dim)
gives the count (14 per group). Chunks must be exactly 32 steps long.
GPU and CUDA graphs
tokenizer = tokenizer.to("cuda") # eager on the GPU
tokenizer = tokenizer.to("cuda", cuda_graphs=True) # captures the encoder and decoder once per batch shape
Inputs and outputs stay NumPy. GPU results match the CPU up to floating point (rarely a token on a quantization boundary differs).
API
| call | does |
|---|---|
NATActionTokenizer.from_pretrained(repo_or_folder, action_min=None, action_max=None) |
load (optionally with your min and max) |
tokenizer.fit(actions) |
per-column min and max of your actions (returns the tokenizer) |
tokenizer(chunks, normalize=True) |
(batch, 32, d) or (32, d) actions to a list of token lists |
tokenizer.decode(tokens, action_dim, normalize=True) |
token lists (whole chunks, or one group's prefix) to (batch, steps, d) actions |
tokenizer.stream(action_dim, normalize=True) |
a decoder whose push(token) returns each latent's actions as soon as its tokens are generated |
tokenizer.tokens_starting_with(actions, normalize=True) |
the first tokens of a chunk that starts with these actions (real-time chunking) |
tokenizer.prefix_token_count(steps) |
tokens that decode the first steps (8, 16, 24 or 32) |
tokenizer.tokens_per_chunk(action_dim) |
14 per group of 7 columns |
tokenizer.to(device, cuda_graphs=False) |
run on a device, optionally with CUDA graphs |
tokenizer.save_pretrained(directory) |
save, with the fitted min and max |
tokenizer.vocab_size |
25,600 (4 scales x 6,400 codes) |
Model
4 latents per chunk, 4 FSQ scales of 6,400 codes (one coarse token per two latents, three finer tokens per latent),
trained on a large corpus of robot and human action data (every window once, batch 4,096). The repository holds only
the weights (model.safetensors) and a JSON config; the network is plain PyTorch in the nat-tokenizer package.
Reconstruction on robot benchmarks, and speed
Random 32-step chunks of each benchmark's demonstrations, each normalized by its own min and max (MetaWorld's actions clipped to the [-1, 1] its simulator executes). Errors are mean absolute differences between the input and its reconstruction. Speed is in milliseconds per call on an RTX 4090 and 4 CPU threads, mean and SD over 20 calls.
| benchmark | chunks x shape | MAE in [-1, 1] units | MAE | max error |
|---|---|---|---|---|
| LIBERO-10 | 1000 x (32, 7) | 0.0304 | 0.0210 | 1.9762 |
| MetaWorld mt4 (clipped) | 1000 x (32, 4) | 0.0651 | 0.0651 | 1.7578 |
| RoboMimic mt4 | 1000 x (32, 7) | 0.0466 | 0.0404 | 1.5712 |
| RoboCasa mt4 | 1000 x (32, 12) | 0.0130 | 0.0107 | 0.9970 |
| device | batch of 32 x 7 chunks | encode ms | decode ms |
|---|---|---|---|
| cpu, eager | 1 | 11.11 ± 0.05 | 23.12 ± 0.28 |
| cpu, eager | 64 | 320.02 ± 0.90 | 249.54 ± 0.68 |
| cuda, eager | 1 | 4.21 ± 0.04 | 8.02 ± 0.57 |
| cuda, eager | 64 | 4.54 ± 0.11 | 8.46 ± 0.55 |
| cuda, CUDA graphs | 1 | 0.50 ± 0.01 | 2.14 ± 0.02 |
| cuda, CUDA graphs | 64 | 0.82 ± 0.01 | 3.55 ± 0.03 |
Citation
@misc{jawaid2026nat,
title={NAT: Scaling Causal Neural Action Tokenizers Across Embodiments},
author={Ahad Jawaid and Alexander Swerdlow and Yu Xiang},
year={2026},
eprint={2611.28873},
archivePrefix={arXiv},
primaryClass={cs.RO},
url={https://arxiv.org/abs/2611.28873}
}