Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Dnn::ModelConfig Class Referenceabstractexport

Abstract base configuration for all deployable Mila models. More...

Public Member Functions

 ModelConfig (const ModelConfig &)=delete
virtual ~ModelConfig ()=default
dim_t getContextLength () const noexcept
ModelConfigoperator= (const ModelConfig &)=delete
virtual std::string toString () const =0
 Produce a human-readable summary of the model configuration.
template<typename Self>
Self & withContextLength (this Self &self, dim_t context_length)
 Set the weight quantization policy.

Protected Member Functions

 ModelConfig ()=default
 Default constructor for subclasses that set context_length via withContextLength().
 ModelConfig (dim_t context_length)
 Construct with required context_length.
std::string baseToString () const
 Produce the base fields portion of toString().

Protected Attributes

dim_t context_length_ { 0 }

Detailed Description

Abstract base configuration for all deployable Mila models.

Subclasses add architecture-specific deployment concerns (e.g. LlamaModelConfig adds nothing beyond what ModelConfig already owns — all Llama architectural parameters come from checkpoint metadata).

Non-copyable by design — model configs are constructed once and passed by const reference into fromPretrained().

Constructor & Destructor Documentation

◆ ~ModelConfig()

virtual Mila::Dnn::ModelConfig::~ModelConfig ( )
virtualdefault

◆ ModelConfig() [1/3]

Mila::Dnn::ModelConfig::ModelConfig ( const ModelConfig & )
delete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ModelConfig() [2/3]

Mila::Dnn::ModelConfig::ModelConfig ( dim_t context_length)
inlineexplicitprotected

Construct with required context_length.

Protected — construction is via concrete subclass only.

Parameters
context_lengthMaximum sequence length. Must be > 0.

◆ ModelConfig() [3/3]

Mila::Dnn::ModelConfig::ModelConfig ( )
protecteddefault

Default constructor for subclasses that set context_length via withContextLength().

context_length_ is initialised to zero. Subclasses or fromPretrained() must call withContextLength() before passing the config to build().

Member Function Documentation

◆ baseToString()

std::string Mila::Dnn::ModelConfig::baseToString ( ) const
inlineprotected

Produce the base fields portion of toString().

Subclasses call this and append their own fields.

◆ getContextLength()

dim_t Mila::Dnn::ModelConfig::getContextLength ( ) const
inlinenoexcept

◆ operator=()

ModelConfig & Mila::Dnn::ModelConfig::operator= ( const ModelConfig & )
delete
Here is the call graph for this function:

◆ toString()

virtual std::string Mila::Dnn::ModelConfig::toString ( ) const
pure virtual

Produce a human-readable summary of the model configuration.

Implementations should include base fields by calling baseToString() and appending subclass-specific fields.

◆ withContextLength()

template<typename Self>
Self & Mila::Dnn::ModelConfig::withContextLength ( this Self & self,
dim_t context_length )
inline

Set the weight quantization policy.

Determines weight storage dtype and scale allocation for all quantizable components (currently Linear only).

Parameters
quantizationQuantization policy to apply.
Returns
Reference to the concrete config for chaining.

Set the maximum sequence length.

Required. The model is built at this context length so that RoPE embeddings and KV cache buffers cover the full range.

Parameters
context_lengthMaximum sequence length in tokens.
Returns
Reference to the concrete config for chaining.

Member Data Documentation

◆ context_length_

dim_t Mila::Dnn::ModelConfig::context_length_ { 0 }
protected

The documentation for this class was generated from the following file: