|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +set -eo pipefail |
| 19 | + |
| 20 | +# Set default values for BASE_MODEL, NUM_GPU, and DATA |
| 21 | +BASE_MODEL=meta-llama/Llama-3.2-1B-Instruct |
| 22 | +NUM_GPU=1 |
| 23 | +DATA=Daring-Anteater/train.jsonl |
| 24 | + |
| 25 | +# Parse input arguments --base-model, --num_gpu, and --data |
| 26 | +while [[ $# -gt 0 ]]; do |
| 27 | + key="$1" |
| 28 | + case $key in |
| 29 | + --base_model) |
| 30 | + BASE_MODEL="$2" |
| 31 | + shift; shift |
| 32 | + ;; |
| 33 | + --num_gpu) |
| 34 | + NUM_GPU="$2" |
| 35 | + shift; shift |
| 36 | + ;; |
| 37 | + --data) |
| 38 | + DATA="$2" |
| 39 | + shift; shift |
| 40 | + ;; |
| 41 | + *) |
| 42 | + echo "Unknown argument: $1" |
| 43 | + exit 1 |
| 44 | + ;; |
| 45 | + esac |
| 46 | +done |
| 47 | + |
| 48 | + |
| 49 | +if [[ "$NUM_GPU" == 1 ]]; then |
| 50 | + export CUDA_VISIBLE_DEVICES=0 |
| 51 | +else |
| 52 | + # Export as 0,1,...,N-1 for NUM_GPU GPUs |
| 53 | + export CUDA_VISIBLE_DEVICES=$(seq -s, 0 $((NUM_GPU-1))) |
| 54 | +fi |
| 55 | + |
| 56 | +MODEL_BASENAME=$(basename "$BASE_MODEL") |
| 57 | + |
| 58 | +echo "==== [1/3] Training draft model ====" |
| 59 | +OUTPUT_DIR=ckpts/${MODEL_BASENAME}-$(date +%Y%m%d_%H%M) |
| 60 | +./launch_train.sh --model $BASE_MODEL \ |
| 61 | + --output_dir $OUTPUT_DIR \ |
| 62 | + --data $DATA \ |
| 63 | + --num_gpu $NUM_GPU \ |
| 64 | + --num_epochs 2 \ |
| 65 | + --eagle_config eagle_config.json |
| 66 | + |
| 67 | +echo "==== [2/3] Evaluating ModelOpt checkpoint on MT-Bench ====" |
| 68 | +python ar_validate.py --model_path $OUTPUT_DIR |
| 69 | + |
| 70 | +echo "==== [3/3] Exporting checkpoint to deployment format ====" |
| 71 | +EXPORT_PATH=export/${MODEL_BASENAME}-$(date +%Y%m%d_%H%M) |
| 72 | +python export_hf_checkpoint.py --model_path $OUTPUT_DIR --export_path $EXPORT_PATH |
0 commit comments