For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python module
max.pipelines.architectures.flint
FlintForCausalLM architecture.
FlintConfig
class max.pipelines.architectures.flint.FlintConfig(*, hidden_size, num_attention_heads, num_key_value_heads, num_hidden_layers, rope_theta, max_seq_len, intermediate_size, vocab_size, dtype, kv_params, head_dim, devices, layer_types=<factory>, sliding_window, num_experts, num_experts_per_tok, moe_intermediate_size, norm_topk_prob, hidden_act, attention_bias, mlp_only_layers=<factory>, decoder_sparse_step=1, shared_expert_intermediate_size=1024, return_logits=ReturnLogits.LAST_TOKEN, rms_norm_eps=None, tie_word_embeddings=False, return_hidden_states=ReturnHiddenStates.NONE, quantization_encoding=None)
Bases: ArchConfigWithStoredKVParams, ArchConfigWithKVCache
Configuration for Flint.
-
Parameters:
-
- hidden_size (int)
- num_attention_heads (int)
- num_key_value_heads (int)
- num_hidden_layers (int)
- rope_theta (float)
- max_seq_len (int)
- intermediate_size (int)
- vocab_size (int)
- dtype (DType)
- kv_params (MultiKVCacheParams)
- head_dim (int)
- devices (list[DeviceRef])
- layer_types (list[str])
- sliding_window (int)
- num_experts (int)
- num_experts_per_tok (int)
- moe_intermediate_size (int)
- norm_topk_prob (bool)
- hidden_act (str)
- attention_bias (bool)
- mlp_only_layers (list[int])
- decoder_sparse_step (int)
- shared_expert_intermediate_size (int)
- return_logits (ReturnLogits)
- rms_norm_eps (float | None)
- tie_word_embeddings (bool)
- return_hidden_states (ReturnHiddenStates)
- quantization_encoding (SupportedEncoding | None)
DEFAULT_ENCODING
DEFAULT_ENCODING: ClassVar[SupportedEncoding] = 'bfloat16'
SUPPORTED_ENCODINGS
SUPPORTED_ENCODINGS: ClassVar[set[SupportedEncoding]] = {'bfloat16', 'float32'}
attention_bias
attention_bias: bool
construct_kv_params()
classmethod construct_kv_params(huggingface_config, pipeline_config, devices, kv_cache_config, cache_dtype, *, allow_kv_head_replication=False)
Builds one paged cache per attention type.
The sliding child is bounded by the sliding window; the full child is unbounded.
-
Parameters:
-
- huggingface_config (AutoConfig)
- pipeline_config (PipelineConfig)
- devices (list[DeviceRef])
- kv_cache_config (KVCacheConfig)
- cache_dtype (DType)
- allow_kv_head_replication (bool)
-
Return type:
decoder_sparse_step
decoder_sparse_step: int = 1
devices
dtype
dtype: DType
finalize()
finalize(huggingface_config, state_dict, return_logits, return_hidden_states=ReturnHiddenStates.NONE)
Resolves the fields that depend on the loaded weights.
-
Parameters:
-
- huggingface_config (AutoConfig)
- state_dict (dict[str, WeightData])
- return_logits (ReturnLogits)
- return_hidden_states (ReturnHiddenStates)
-
Return type:
-
None
get_head_dim()
static get_head_dim(huggingface_config)
Attention head size from head_dim or hidden_size // num_attention_heads.
-
Parameters:
-
huggingface_config (AutoConfig)
-
Return type:
get_num_layers()
static get_num_layers(huggingface_config)
Layer count for the decoder stack (override when HF uses a different field).
-
Parameters:
-
huggingface_config (AutoConfig)
-
Return type:
get_rope_theta()
static get_rope_theta(huggingface_config)
Returns the rope theta stored in the HF config.
transformers 5.x may nest the value under rope_parameters, so read
that first and fall back to the top-level key.
-
Parameters:
-
huggingface_config (AutoConfig)
-
Return type:
head_dim
head_dim: int
hidden_act
hidden_act: str
hidden_size
hidden_size: int
initialize()
classmethod initialize(pipeline_config, model_config=None, *, max_seq_len)
Initialize the config from a PipelineConfig.
-
Parameters:
-
- pipeline_config (PipelineConfig) – The pipeline configuration.
- model_config (MAXModelConfig | None) – The model configuration to read from. When
None(the default),pipeline_config.modelis used. Pass an explicit config (such aspipeline_config.draft_model) to initialize the arch config for a different model. - max_seq_len (int) – The effective maximum sequence length to store on
the config. The value is received, never derived here: the
pipeline model passes the memory plan’s VRAM-clamped length,
while memory planning (which runs before a plan exists)
passes the construction-resolved
model_config.max_length. Configs whose sequence length is pure model metadata (such as diffusion components) ignore it.
-
Return type:
intermediate_size
intermediate_size: int
kv_params
kv_params: MultiKVCacheParams
layer_types
max_seq_len
max_seq_len: int
mlp_only_layers
moe_intermediate_size
moe_intermediate_size: int
norm_topk_prob
norm_topk_prob: bool
num_attention_heads
num_attention_heads: int
num_experts
num_experts: int
num_experts_per_tok
num_experts_per_tok: int
num_hidden_layers
num_hidden_layers: int
num_key_value_heads
num_key_value_heads: int
quantization_encoding
quantization_encoding: SupportedEncoding | None = None
return_hidden_states
return_hidden_states: ReturnHiddenStates = 'none'
return_logits
return_logits: ReturnLogits = 'last_token'
rms_norm_eps
rope_theta
rope_theta: float
shared_expert_intermediate_size
shared_expert_intermediate_size: int = 1024
sliding_window
sliding_window: int
tie_word_embeddings
tie_word_embeddings: bool = False
vocab_size
vocab_size: int
FlintInputs
class max.pipelines.architectures.flint.FlintInputs(tokens: 'Buffer', input_row_offsets: 'Buffer', return_n_logits: 'Buffer', *, kv_cache_inputs: 'KVCacheInputs[Buffer, Buffer] | None' = None, lora_buffers: 'tuple[Buffer, ...]' = (), vision_embeddings: 'list[Buffer]' = <factory>, vision_scatter_indices: 'list[Buffer]' = <factory>, hidden_states: 'Buffer | list[Buffer] | None' = None)
Bases: ModelInputs
-
Parameters:
buffers
Returns positional Buffer inputs for model ABI calls.
input_row_offsets
input_row_offsets: Buffer
return_n_logits
return_n_logits: Buffer
tokens
tokens: Buffer
FlintModel
class max.pipelines.architectures.flint.FlintModel(pipeline_config, session, *args, **kwargs)
Bases: LogProbabilitiesMixin, ModuleV3PipelineModelWithKVCache[TextContext, Any]
Builds and compiles the ModuleV3 network for Flint.
-
Parameters:
-
- pipeline_config (Any)
- session (InferenceSession)
- args (Any)
- kwargs (Any)
batch_processor_cls
batch_processor_cls
alias of FlintBatchProcessor
config_class
config_class
alias of FlintConfig
model_config_cls
model_config_cls
alias of FlintConfig