|
Mila
Deep Neural Network Library
|
Public Member Functions | |
| RmsNormConfig (int64_t axis) | |
| Construct in axis mode. | |
| RmsNormConfig (shape_t normalized_shape) | |
| Construct in shape mode. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| std::optional< int64_t > | getAxis () const noexcept |
| float | getEpsilon () const noexcept |
| const shape_t & | getNormalizedShape () const noexcept |
| float | getUnitOffset () const noexcept |
| bool | hasBias () const noexcept |
| bool | hasNormalizedShape () 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 parameters. | |
| template<typename Self> | |
| decltype(auto) | withBias (this Self &&self, bool has_bias) |
| Enable or disable learnable bias. | |
| template<typename Self> | |
| decltype(auto) | withEpsilon (this Self &&self, float epsilon) |
| Set epsilon for numerical stability. | |
| template<typename Self> | |
| decltype(auto) | withUnitOffset (this Self &&self, float unit_offset) |
| Set the unit offset added to the loaded weight before scaling. | |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
|
inlineexplicit |
Construct in shape mode.
Normalizes over the trailing dimensions described by normalized_shape.
| normalized_shape | Trailing dimensions to normalize over (e.g. shape_t{ model_dim }). |
|
inlineexplicit |
Construct in axis mode.
Normalizes over a single axis.
| axis | Axis along which to normalize (negative indexing supported). |
|
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.
|
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 parameters.
Called by callers to ensure the configuration represents a valid, constructible component. Implementations must throw std::invalid_argument (or a derived exception) when validation fails.
| std::invalid_argument | If the configuration is invalid. |
Implements Mila::Dnn::ComponentConfig.
|
inline |
Enable or disable learnable bias.
Default: true. Llama 3 uses false.
|
inline |
Set epsilon for numerical stability.
Default: 1e-5f. Llama 3 uses 1e-5f; some models use 1e-6f.
|
inline |
Set the unit offset added to the loaded weight before scaling.
The normalized activation is scaled by (weight + unit_offset). Default 0.0 reproduces standard RMSNorm (x_norm * weight) – used by Llama 3 / GPT-2. Gemma sets 1.0: its RMSNorm is x_norm * (1 + weight), with weights stored raw (zero-centered, weight-decay-friendly). The offset is applied at the kernel so the stored/loaded weights remain identical to the source checkpoint.