-
Notifications
You must be signed in to change notification settings - Fork 129
feat: Add Evo2 fine-tuning partial-conv benchmarking #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+145
−1
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
557a24f
add evo2 fine-tuning partial-conv benchmarking script
nvmvle da5bda8
Merge branch 'main' into mvle/evo2-fine-tuning
jwilber 5c40d42
update finetuning script w new data locations and correct args; remov…
jwilber 488bf5e
Merge branch 'main' into mvle/evo2-fine-tuning
jwilber d8caf5e
add default variant
nvmvle c1f71ff
add required precision param
nvmvle 4ca7cfc
fix lora_finetune variant logic
nvmvle afec57a
Merge branch 'main' into mvle/evo2-fine-tuning
jwilber a5cf703
Change number of brackets in artefact url
jwilber c792680
disable some keys to reduce artifacts name length
nvmvle 8fd96ba
reset CUDA memory on validation start
cf3926a
Split the CUDA cleanup handler to another file, add a param to contro…
7a828cf
Merge branch 'main' into mvle/evo2-fine-tuning
jwilber 9ec1f62
lint
jwilber 807f311
rename model_size to config_name for consistent naming convention
f8f216b
set stop_steps value to 100, increase max_steps
d3b59bd
Merge branch 'main' into mvle/evo2-fine-tuning
jwilber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| scope: partial-conv | ||
| time_limit: 14400 | ||
| key_segments: | ||
| # Modify keys to be renamed (str) or excluded (False) from run identifier. By default, all args under script_args are included. | ||
| dataset_config: False | ||
| dataset_dir: False | ||
| data_base_path: False | ||
| num_workers: False | ||
| limit_val_batches: False | ||
| val_check_interval: False | ||
| experiment_name: False | ||
| workspace: False | ||
| restore_from_checkpoint_path: False | ||
| activation_checkpoint_layers: False | ||
| lora_enabled: False | ||
| lr: False | ||
| min_lr: False | ||
| warmup_steps: False | ||
| accumulate_grad_batches: False | ||
| clip_grad: False | ||
| weight_decay: False | ||
| attention_dropout: False | ||
| hidden_dropout: False | ||
| precision: False | ||
| seq_length: False | ||
| script_args: | ||
| # All arguments referenced in the script string must be specified here. | ||
| # Arguments not referenced in the script string must have the 'arg' field specified. | ||
| # See jet/core/configs.py for the specification of the configuration class | ||
| workspace: /workspace/bionemo2 | ||
| data_base_path: /data/evo2 | ||
| restore_from_checkpoint_path: checkpoints/nemo2_evo2_1b_8k | ||
| nodes: 1 | ||
| model: evo2 | ||
| config_name: 1b | ||
| num_workers: 1 | ||
| limit_val_batches: 20 | ||
| dataset_config: training_data_config.yaml | ||
| dataset_dir: preprocessed_data | ||
| val_check_interval: 5 | ||
| seq_length: 8192 | ||
| warmup_steps: 10 | ||
| activation_checkpoint_layers: 2 | ||
| lr: 0.000015 | ||
| min_lr: 0.0000149 | ||
| accumulate_grad_batches: 4 | ||
| max_steps: 1000 | ||
| gpus: 1 | ||
| clip_grad: 250 | ||
| weight_decay: 0.001 | ||
| attention_dropout: 0.01 | ||
| hidden_dropout: 0.01 | ||
| stop_steps: 100 | ||
| batch_size: 2 | ||
| variant: finetune | ||
| precision: fp8 | ||
| products: | ||
| - variant: finetune | ||
| lora_enabled: "" | ||
| task: finetune_from_ckpt | ||
| experiment_name: evo2-finetune | ||
| - variant: lora_finetune | ||
| lora_enabled: "--lora-finetune" | ||
| task: lora_finetune_from_ckpt | ||
| experiment_name: evo2-lora-finetune | ||
| script: |- | ||
| WANDB_API_KEY=$BIONEMO_WANDB_API_KEY train_${model} \ | ||
| -d ${data_base_path}/${dataset_config} \ | ||
| --dataset-dir=${data_base_path}/${dataset_dir} \ | ||
| --ckpt-dir=${data_base_path}/${restore_from_checkpoint_path} \ | ||
| ${lora_enabled} \ | ||
| --model-size=${config_name} \ | ||
| --max-steps=${max_steps} \ | ||
| --experiment-name=${experiment_name}_${batch_size}bs_${nodes}node_${gpus}gpu_${max_steps}s \ | ||
| --lr=${lr} \ | ||
| --min-lr=${min_lr} \ | ||
| --warmup-steps=${warmup_steps} \ | ||
| --result-dir=${tensorboard_dir} \ | ||
nvmvle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --micro-batch-size=${batch_size} \ | ||
| --grad-acc-batches=${accumulate_grad_batches} \ | ||
| --limit-val-batches=${limit_val_batches} \ | ||
| --seq-length=${seq_length} \ | ||
| --clip-grad=${clip_grad} \ | ||
| --wd=${weight_decay} \ | ||
| --attention-dropout=${attention_dropout} \ | ||
| --hidden-dropout=${hidden_dropout} \ | ||
| --num-layers 4 \ | ||
| --hybrid-override-pattern 'SDH*' \ | ||
| --devices=${gpus} \ | ||
| --num-nodes=${nodes} \ | ||
| --val-check-interval=${val_check_interval} \ | ||
| --wandb-project=${wandb_project_name} \ | ||
nvmvle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --wandb-group=${model}_${variant}_${config_name}_${task}_${target} \ | ||
nvmvle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --create-tensorboard-logger \ | ||
| --activation-checkpoint-recompute-num-layers=${activation_checkpoint_layers} \ | ||
| --disable-checkpointing \ | ||
| --early-stop-on-step=${stop_steps} \ | ||
| --garbage-collect-at-inference; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
sub-packages/bionemo-evo2/src/bionemo/evo2/utils/callbacks.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: LicenseRef-Apache2 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import gc | ||
|
|
||
| import torch | ||
| from lightning.pytorch import Callback | ||
|
|
||
|
|
||
| class GarbageCollectAtInferenceTime(Callback): | ||
| """Callback to clean up CUDA memory before validation to prevent initialization errors.""" | ||
|
|
||
| def on_validation_start(self, trainer, pl_module) -> None: | ||
| """Clean up CUDA memory before validation to prevent initialization errors.""" | ||
| if torch.cuda.is_available(): | ||
| try: | ||
| torch.cuda.empty_cache() | ||
| torch.cuda.synchronize() | ||
| current_device = torch.cuda.current_device() | ||
| torch.cuda.set_device(current_device) | ||
| torch.cuda.synchronize() | ||
| gc.collect() | ||
| except Exception as e: | ||
| print(f"Warning: CUDA cleanup failed: {e}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.