Index
optimus_dl.recipe.mixins
¶
Shared mixins that can be used across different recipe types.
ModelBuilder
¶
Mixin for building models and applying transformations.
Encapsulates the logic for:
1. Instantiating a BaseModel from a configuration object.
2. Sequentially applying a list of ModelTransforms (e.g., FSDP, DDP, compile).
3. Logging model statistics (parameter count).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
ModelBuilderConfig
|
Builder configuration. |
required |
model_transforms
|
list[ModelTransformConfig] | None
|
List of configurations for transforms to apply. |
None
|
Source code in optimus_dl/recipe/mixins/model_builder.py
build_model(model_config, collective, **kwargs)
¶
Build the model and apply all configured transforms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config
|
ModelConfig | None
|
Configuration for the model architecture. |
required |
collective
|
Collective
|
Distributed collective for transforms that need it. |
required |
**kwargs
|
Additional arguments passed to model constructor and transforms. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
The fully constructed and transformed model. |
Source code in optimus_dl/recipe/mixins/model_builder.py
Modules and Sub-packages¶
model_builder: Model builder mixin for building and transforming models with checkpoint loading.