|
| 1 | +# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | + |
| 17 | +import os |
| 18 | + |
| 19 | +from nemo_automodel.components.config._arg_parser import parse_args_and_load_config |
| 20 | +from nemo_automodel.recipes.llm.train_ft import TrainFinetuneRecipeForNextTokenPrediction |
| 21 | + |
| 22 | +# Default config: YAML in the same directory as this script (BIRD SQL PEFT for Nemotron-3-Nano, 2 GPUs) |
| 23 | +_THIS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 24 | +_DEFAULT_CONFIG = os.path.join(_THIS_DIR, "bird_peft_nemotron_nano.yaml") |
| 25 | + |
| 26 | + |
| 27 | +def main(default_config_path: str = _DEFAULT_CONFIG) -> None: |
| 28 | + """Main entry point for the fine-tuning recipe. |
| 29 | +
|
| 30 | + Loads the configuration, sets up the recipe, and initiates the training loop. |
| 31 | + Override the config path via CLI: --config /path/to/other.yaml |
| 32 | + """ |
| 33 | + cfg = parse_args_and_load_config(default_config_path) |
| 34 | + recipe = TrainFinetuneRecipeForNextTokenPrediction(cfg) |
| 35 | + recipe.setup() |
| 36 | + recipe.run_train_validation_loop() |
| 37 | + |
| 38 | + |
| 39 | +if __name__ == "__main__": |
| 40 | + main() |
0 commit comments