Config
IOMixinProto
Bases: Protocol
A Protocol for the get/set hparam functions of the IOMixin class from NeMo.
Source code in bionemo/llm/model/config.py
117 118 119 120 121 122 123 124 125 126 |
|
get_hparam(attribute)
Get the value of an attribute in the config attached to the class by the IOMixin.
Source code in bionemo/llm/model/config.py
124 125 126 |
|
set_hparam(attribute, value, also_change_value=True)
Set the value of an attribute in the config attached to the class by the IOMixin.
Source code in bionemo/llm/model/config.py
120 121 122 |
|
MegatronBioNeMoModelConfig
Bases: BionemoModelConfig[MegatronModelType]
, TransformerConfig
, WillHaveGetSetHparam
A ModelConfig class for bionemo that supports usage with Megatron models, for example as NeMo2 requires.
Source code in bionemo/llm/model/config.py
53 54 55 56 |
|
MegatronBioNeMoTrainableModelConfig
dataclass
Bases: MegatronBioNeMoModelConfig[MegatronModelType]
, BionemoTrainableModelConfig[MegatronModelType, MegatronLossType]
, Generic[MegatronModelType, MegatronLossType]
A TrainableModelConfig class for bionemo that supports usage with Megatron models, for example as NeMo2 requires.
Source code in bionemo/llm/model/config.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
load_settings_from_checkpoint(initial_ckpt_path)
Load settings into self from the checkpoint saved in self.
Any setting in self.override_parent_fields is not overriden. Note that this function will also update the hyper parameters in this config, as well as the associated attributes in self in case they were modified post-init.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_ckpt_path
|
str
|
The path to the checkpoint to load, note that everything is loaded from this checkpoint other than the settings in self.override_parent_fields. |
required |
Returns:
Type | Description |
---|---|
None
|
None, the settings are loaded into self in place, and the hyper-parameters that will later be saved into a checkpoint are updated. |
Source code in bionemo/llm/model/config.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
update_model_from_checkpoint(model, initial_ckpt_path)
Utility function to standardize how to load a megatron model from a checkpoint ignoring user-specified keys.
Update the model with the weights from the provided checkpoint path, skipping the keys with the prefixes in self.initial_ckpt_skip_keys_with_these_prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
MegatronModelType
|
The Megatron model to update. |
required |
initial_ckpt_path
|
str
|
The path to the megatron checkpoint to load. |
required |
Returns:
Type | Description |
---|---|
None
|
None, the model is updated in place, supporting megatron model parallelism abstractions, and ignoring any extra keys that are provided in self.initial_ckpt_skip_keys_with_these_prefixes. |
Source code in bionemo/llm/model/config.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
override_mutate_possibly_extra_mutated_fiddle(target_cfg, source_cfg, maybe_mutated_elements_to_clone)
Override the values of the target config with the values of the source config for the given elements.
This will modify the tracked init hyper-parameter values, as well as modifying the associated attributes in self incase they were modified later by post_init code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_cfg
|
IOMixinProto
|
The config to update. |
required |
source_cfg
|
IOMixinProto
|
The config to copy values from. |
required |
maybe_mutated_elements_to_clone
|
List[str]
|
The list of elements to copy from the source config to the target config. |
required |
Returns:
Type | Description |
---|---|
None
|
None, the target config is updated in place. |
Source code in bionemo/llm/model/config.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|