|
Mila
Deep Neural Network Library
|
Public Member Functions | |
| RopeConfig (dim_t channels, dim_t n_heads, dim_t n_kv_heads, dim_t max_seq_len) | |
| Construct with all structurally required parameters. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| float | getBase () const noexcept |
| dim_t | getEmbeddingDim () const noexcept |
| dim_t | getHeadDim () const noexcept |
| Per-head dimension, derived as channels / n_heads. | |
| dim_t | getMaxSequenceLength () const noexcept |
| Returns the training maximum sequence length. | |
| dim_t | getNumHeads () const noexcept |
| dim_t | getNumKVHeads () const noexcept |
| dim_t | getRotaryDim () const noexcept |
| SerializationMetadata | toMetadata () const override |
| Convert configuration into a SerializationMetadata object. | |
| std::string | toString () const override |
| Produce a short, human-readable summary of the configuration. | |
| void | validate () const override |
| Validate configuration. | |
| template<typename Self> | |
| decltype(auto) | withBase (this Self &&self, float base) |
| Set frequency base for rotary angle computation. | |
| template<typename Self> | |
| decltype(auto) | withRotaryDim (this Self &&self, dim_t rotary_dim) |
| Set rotary sub-dimension per head (number of channels to rotate). | |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
|
inline |
Construct with all structurally required parameters.
| channels | Total Q embedding width (n_heads * head_dim). |
| n_heads | Number of query heads. |
| n_kv_heads | Number of key/value heads (GQA: <= n_heads). |
| max_seq_len | Maximum sequence length for cos/sin cache precomputation. |
|
inlineoverridevirtual |
Populate configuration from provided metadata.
Implementations should read available keys and leave missing keys at their current/default values to preserve forward/backward compatibility.
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
|
inlinenoexcept |
Per-head dimension, derived as channels / n_heads.
Valid only after validate() has confirmed consistency.
|
inlinenoexcept |
Returns the training maximum sequence length.
|
inlineoverridevirtual |
Convert configuration into a SerializationMetadata object.
Implementations should include any fields required to fully reconstruct the configuration via fromMetadata.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Produce a short, human-readable summary of the configuration.
Implementations should return a compact, single-line description suitable for logging and debugging.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Validate configuration.
Enforces: required fields are positive, channels is divisible by n_heads, head_dim is even (RoPE requires paired dimensions), n_kv_heads <= n_heads, and rotary_dim (if set) does not exceed head_dim.
| std::invalid_argument | on any violated constraint. |
Implements Mila::Dnn::ComponentConfig.
|
inline |
Set frequency base for rotary angle computation.
Standard RoPE default is 10000.0f. Llama 3 uses 500000.0f. Default: 10000.0f.
|
inline |
Set rotary sub-dimension per head (number of channels to rotate).
Default: 0 – the full head_dim is rotated.