gpt_action_transformer
gpt_action_transformer
¶
Action GPT Decoder for tokenized action prediction.
It uses a GPT-style autoregressive decoder (only self-attention) to generate sequences of tokenized actions.
GPTActionTransformer
¶
GPTActionTransformer(action_heads, input_keys, action_space, observation_space, observation_horizon, prediction_horizon, device, max_seq_len=512, embedding_dimension=256, number_of_heads=8, number_of_key_value_heads=None, feedforward_dimension=None, number_of_layers=6, activation=value, normalization_type=value, attention_type=value, dropout_rate=0.1, attention_dropout=0.0, positional_encoding_type=value, temperature=1.0, learnable_temperature=False, deterministic=True)
Bases: AutoregressiveDecoderMixin, DiscreteDecoder
Autoregressive decoder for tokenized action prediction.
Uses pure GPT-style transformer with self-attention only (no cross-attention). Observation features are concatenated as prefix tokens, followed by action token embeddings for autoregressive generation. This is similar to Pi0 FAST but adapted to work with any feature encoder.
Initialize GPTActionTransformer decoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_heads
|
dict[str, ActionHead]
|
Action heads for different action components (only DecoderOutputKey.ACTION_LOGITS.value used here). |
required |
input_keys
|
list[str]
|
Feature keys expected from encoder pipeline |
required |
action_space
|
ActionSpace
|
Action space configuration |
required |
observation_space
|
ObservationSpace
|
Observation space configuration |
required |
observation_horizon
|
int
|
Number of observation timesteps |
required |
prediction_horizon
|
int
|
Max action horizon for generation |
required |
device
|
str
|
Device to run model on |
required |
max_seq_len
|
int
|
Maximum sequence length for GPT (features + action tokens) |
512
|
embedding_dimension
|
int
|
Common embedding dimension to bring input tokens to, also Transformer hidden size |
256
|
number_of_heads
|
int
|
Number of query attention heads |
8
|
number_of_key_value_heads
|
int | None
|
Number of K/V heads for GQA (None = same as heads = MHA) |
None
|
feedforward_dimension
|
int | None
|
FFN hidden dimension (default: 4 * embedding_dimension) |
None
|
number_of_layers
|
int
|
Number of transformer layers |
6
|
activation
|
str
|
Activation function (swiglu, gelu, relu, silu) |
value
|
normalization_type
|
str
|
Normalization type (rmsnorm, layernorm) |
value
|
attention_type
|
str
|
Attention type (gqa, mha) |
value
|
dropout_rate
|
float
|
Dropout probability |
0.1
|
attention_dropout
|
float
|
Attention dropout probability |
0.0
|
positional_encoding_type
|
str | None
|
Type of positional encoding (sinusoidal, rope, None) |
value
|
temperature
|
float
|
Initial temperature for sampling (not used in greedy decoding) |
1.0
|
learnable_temperature
|
bool
|
If True, make temperature a learnable parameter |
False
|
deterministic
|
bool
|
If True, use greedy decoding during inference |
True
|
Source code in src/versatil/models/decoding/decoders/factory/gpt_action_transformer.py
forward
¶
Forward pass.
Training: Teacher forcing with ground truth tokens Inference: Autoregressive generation with KV caching
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
dict[str, Tensor]
|
Encoded features from pipeline |
required |
actions
|
dict[str, Tensor] | None
|
Ground truth tokenized actions (training) or None (inference) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict with DecoderOutputKey.ACTION_LOGITS.value (training) or DecoderOutputKey.PREDICTED_ACTION_TOKENS.value (inference) |