Convert to nemo
HyenaOptimizerRemover
Bases: ModelConnector['HyenaModel', HyenaModel]
Removes the optimizer state from a nemo2 format model checkpoint.
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
config
property
Gets the model configuration.
Returns:
Name | Type | Description |
---|---|---|
HyenaConfig |
HyenaConfig
|
Model configuration |
tokenizer
property
Gets the tokenizer for the model.
Returns:
Type | Description |
---|---|
Tokenizer instance |
__new__(path, model_config=None)
Creates a new importer instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the PyTorch model |
required |
model_config
|
Optional model configuration |
None
|
Returns:
Type | Description |
---|---|
PyTorchHyenaImporter instance |
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
apply(output_path, checkpoint_format='torch_dist')
Applies the model conversion from PyTorch to NeMo format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_path
|
Path
|
Path to save the converted model |
required |
checkpoint_format
|
str
|
Format for saving checkpoints |
'torch_dist'
|
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path to the saved NeMo model |
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
convert_state(source, target)
Converts the state dictionary from source format to target format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Source model state |
required | |
target
|
Target model |
required |
Returns:
Type | Description |
---|---|
Result of applying state transforms |
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
get_source_model()
Returns the source model.
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
88 89 90 91 |
|
init()
Initializes a new HyenaModel instance.
Returns:
Name | Type | Description |
---|---|---|
HyenaModel |
HyenaModel
|
Initialized model |
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
80 81 82 83 84 85 86 |
|
main()
Convert a PyTorch Evo2 model checkpoint to a NeMo model checkpoint.
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
parse_args()
Parse command-line arguments.
Source code in bionemo/evo2/utils/checkpoint/convert_to_nemo.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|