base
base
¶
Base contracts for action decoders.
DecoderInput
dataclass
¶
DecoderInput(keys, required_types=list(), raises_for_types=list(), requires_actions=False, needs_raw_observations=False, conditioning_key=None, conditioning_required=list(), conditioning_one_of_groups=list())
Structured input specification for decoder architectures.
__post_init__
¶
Post-initialization to ensure feature keys are consistent.
Source code in src/versatil/models/decoding/decoders/base.py
validate_feature_types
¶
Validate that required feature types are available at instantiation time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available_features
|
dict[str, FeatureMetadata]
|
Dict mapping feature names to their metadata. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required type is missing or a rejected type is present. |
Source code in src/versatil/models/decoding/decoders/base.py
ActionDecoder
¶
ActionDecoder(decoder_input, observation_space, action_space, action_heads, device, observation_horizon, prediction_horizon)
Bases: ModuleAttrMixin, ABC
Abstract base class for neural network action decoders.
Initialize common action decoder state and action heads.
Source code in src/versatil/models/decoding/decoders/base.py
encoder_cache_enabled
property
¶
Whether an encoder cache is currently enabled.
use_orientation_actions
property
¶
Whether the architecture uses orientation actions.
set_tokenizer
¶
Set tokenizer for decoders trained on tokenized actions.
This method is called by Policy.set_tokenizer() to pass the tokenizer to the decoder. Continuous decoders ignore it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokenizer
|
Tokenizer | None
|
Tokenizer instance from data pipeline (can be None) |
None
|
Source code in src/versatil/models/decoding/decoders/base.py
set_normalizer
¶
Set normalizer for data-dependent initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalizer
|
LinearNormalizer
|
LinearNormalizer instance with loaded state. |
required |
Source code in src/versatil/models/decoding/decoders/base.py
enable_encoder_cache
¶
disable_encoder_cache
¶
set_encoder_cache_suppressed
¶
No-op. Override in decoders that support encoder caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suppressed
|
bool
|
While True, cache toggles must not change cache state; attribution uses this to re-run forwards without caching. |
required |
Source code in src/versatil/models/decoding/decoders/base.py
forward
abstractmethod
¶
Forward pass of the Neural Network architecture for action decoding.
Source code in src/versatil/models/decoding/decoders/base.py
get_auxiliary_output_keys
¶
Get keys for auxiliary outputs this decoder produces beyond action predictions.
The base implementation includes tokenized action keys and MoE routing weights when applicable. Subclasses override to add decoder-specific auxiliary keys.
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of auxiliary output key strings. |
Source code in src/versatil/models/decoding/decoders/base.py
get_loss_output_keys
¶
Return decoder output keys that can be supervised as actions.
Source code in src/versatil/models/decoding/decoders/base.py
get_prediction_output_keys
¶
Return predicted action keys in action-space metadata order.
The order is the canonical action-key ordering: exported policies and compressed-artifact metadata index output tensors by it.
Source code in src/versatil/models/decoding/decoders/base.py
validate_action_heads
¶
Validate that configured heads match this decoder's head layout.