For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python module
max.pipelines.architectures.olmo3
OLMo 3 transformer architecture for text generation.
Olmo3Configโ
class max.pipelines.architectures.olmo3.Olmo3Config(*, vocab_size, hidden_size, intermediate_size, num_hidden_layers, num_attention_heads, num_key_value_heads, head_dim, hidden_activation, max_position_embeddings, rms_norm_eps, tie_word_embeddings, rope_theta, attention_bias, sliding_window, layer_types, attention_dropout, rope_scaling, rope_scaling_type, query_pre_attn_scalar=None, final_logit_softcapping=None, attn_logit_softcapping=None, qk_norm_eps, use_qk_norm, use_cache, dtype, devices, interleaved_rope_weights, return_logits, kv_params)
Bases: ArchConfigWithPermissiveMaxSeqLen, ArchConfigWithStoredKVParams, ArchConfigWithKVCache
Configuration for Olmo3 models.
Contains parameters specific to the Olmo3 architecture, typically extracted from a HuggingFace configuration objectโs text config.
-
Parameters:
-
- vocab_size (int)
- hidden_size (int)
- intermediate_size (int)
- num_hidden_layers (int)
- num_attention_heads (int)
- num_key_value_heads (int)
- head_dim (int)
- hidden_activation (str)
- max_position_embeddings (int)
- rms_norm_eps (float)
- tie_word_embeddings (bool)
- rope_theta (float)
- attention_bias (bool)
- sliding_window (int)
- layer_types (list[str])
- attention_dropout (float)
- rope_scaling (YarnScalingParams | None)
- rope_scaling_type (str | None)
- query_pre_attn_scalar (float | None)
- final_logit_softcapping (float | None)
- attn_logit_softcapping (float | None)
- qk_norm_eps (float)
- use_qk_norm (bool)
- use_cache (bool)
- dtype (DType)
- devices (list[DeviceRef])
- interleaved_rope_weights (bool)
- return_logits (ReturnLogits)
- kv_params (KVCacheParams)
attention_biasโ
attention_bias: bool
Whether to use a bias in the query, key, value and output projection layers during self-attention.
attention_dropoutโ
attention_dropout: float
Dropout probability for attention weights.
attn_logit_softcappingโ
Softcapping value for attention logits.
devicesโ
Devices to run the model with.
dtypeโ
dtype: DType
DType of the model weights and input.
final_logit_softcappingโ
Softcapping value for final logits.
finalize()โ
finalize(huggingface_config, state_dict, return_logits)
Define parameters that canโt be determined just from the pipeline config.
-
Parameters:
-
- huggingface_config (AutoConfig) โ The HuggingFace model configuration object.
- state_dict (dict[str, WeightData]) โ The modelโs state dictionary containing weights.
- return_logits (ReturnLogits) โ Whether to return the last token, all tokens or a variable number of logits.
-
Return type:
-
None
get_num_layers()โ
static get_num_layers(huggingface_config)
Retrieves the number of hidden layers from the HuggingFace configuration.
-
Parameters:
-
huggingface_config (AutoConfig) โ The HuggingFace model configuration object (
transformers.AutoConfig). -
Returns:
-
The number of hidden layers specified in the configuration.
-
Return type:
head_dimโ
head_dim: int
Dimension of each attention head.
hidden_activationโ
hidden_activation: str
The non-linear activation function (function or string) in the decoder. Will default to โsiluโ if not specified.
hidden_sizeโ
hidden_size: int
Dimension of the hidden representations.
initialize()โ
classmethod initialize(pipeline_config, model_config=None)
Initializes a Olmo3Config instance from pipeline configuration.
This method creates a config instance with all fields that can be determined from the pipeline configuration, without needing to state_dict. Fields that depend on state_dict (like tie_word_embeddings) should be set via the finalize() method.
-
Parameters:
-
- pipeline_config (PipelineConfig) โ The MAX Engine pipeline configuration.
- model_config (MAXModelConfig | None)
-
Returns:
-
An initialized Olmo3Config instance.
-
Return type:
interleaved_rope_weightsโ
interleaved_rope_weights: bool
True if the rope weights are in interleaved complex format.
intermediate_sizeโ
intermediate_size: int
Dimension of the MLP representations.
kv_paramsโ
kv_params: KVCacheParams
KV cache parameters.
layer_typesโ
Type of attention for each layer (โfull_attentionโ or โsliding_attentionโ).
max_position_embeddingsโ
max_position_embeddings: int
The maximum sequence length that this model might ever be used with.
num_attention_headsโ
num_attention_heads: int
Number of attention heads for each attention layer in the Transformer decoder.
num_hidden_layersโ
num_hidden_layers: int
Number of hidden layers in the Transformer decoder.
num_key_value_headsโ
num_key_value_heads: int
Number of key_value heads that should be used to implement Grouped Query Attention.
qk_norm_epsโ
qk_norm_eps: float
Epsilon value for Q and K normalization layers.
query_pre_attn_scalarโ
Scalar applied to queries before attention computation.
return_logitsโ
return_logits: ReturnLogits
Whether to return the last token, all logits, or a variable number of logits.
rms_norm_epsโ
rms_norm_eps: float
The epsilon used by the rms normalization layers.
rope_scalingโ
rope_scaling: YarnScalingParams | None
Scaling configuration for the RoPE embeddings used in global attention.
rope_scaling_typeโ
Type of RoPE scaling (e.g., โyarnโ, โlinearโ, etc.).
rope_thetaโ
rope_theta: float
The base period of the RoPE embeddings.
sliding_windowโ
sliding_window: int
In the Olmo3 language model, specific layers use sliding window attention. This is the size of the sliding window.
tie_word_embeddingsโ
tie_word_embeddings: bool
Whether to tie weight embeddings. When true, the output linear layer uses the same weight as the embedding layer.
use_cacheโ
use_cache: bool
Whether to use a cache.
use_qk_normโ
use_qk_norm: bool
Whether to use Q and K normalization.
vocab_sizeโ
vocab_size: int
Vocabulary size of the Olmo3 model.
Olmo3Inputsโ
class max.pipelines.architectures.olmo3.Olmo3Inputs(tokens, input_row_offsets, return_n_logits, *, kv_cache_inputs=None, lora=None, vision_embeddings=<factory>, vision_scatter_indices=<factory>, hidden_states=None)
Bases: ModelInputs
A class representing inputs for the Olmo3 model.
This class encapsulates the input tensors required for the Olmo3 model execution.
-
Parameters:
input_row_offsetsโ
input_row_offsets: Buffer
Tensor containing the offsets for each row in the ragged input sequence.
return_n_logitsโ
return_n_logits: Buffer
Number of logits to return.
tokensโ
tokens: Buffer
Tensor containing the input token IDs.
Olmo3Modelโ
class max.pipelines.architectures.olmo3.Olmo3Model(pipeline_config, session, devices, kv_cache_config, weights, adapter=None, return_logits=ReturnLogits.LAST_TOKEN, max_batch_size=1)
Bases: ModuleV3PipelineModelWithKVCache[TextContext]
An Olmo3 pipeline model for text generation.
This class integrates the Olmo3 architecture with the MAX Engine pipeline infrastructure, handling model loading, KV cache management, and input preparation for inference.
-
Parameters:
-
- pipeline_config (PipelineConfig) โ The configuration settings for the entire pipeline.
- session (InferenceSession) โ The MAX Engine inference session managing the runtime.
- devices (list[Device]) โ A list of MAX Engine devices (
max.driver.Device) to run the model on. - kv_cache_config (KVCacheConfig) โ Configuration settings for the Key-Value cache
(
max.pipelines.max_config.KVCacheConfig). - weights (Weights) โ The model weights (
max.graph.weights.Weights). - adapter (WeightsAdapter | None) โ An optional adapter to modify weights before loading
(
max.graph.weights.WeightsAdapter). - return_logits (ReturnLogits) โ The number of top logits to return from the model execution.
- max_batch_size (int)
batch_processor_clsโ
batch_processor_cls
alias of Olmo3BatchProcessor
execute()โ
execute(model_inputs)
Executes the Olmo3 model with the prepared inputs.
-
Parameters:
-
model_inputs (ModelInputs) โ The prepared inputs for the model execution, typically including token IDs, attention masks/offsets, and KV cache inputs.
-
Returns:
-
An object containing the output logits from the model execution.
-
Return type:
model_config_clsโ
model_config_cls
alias of Olmo3Config
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!