generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d82983e
commit a0552d5
Showing
4 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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,56 @@ | ||
#!/bin/bash | ||
# This script runs an SFT example end-to-end on a tiny model using different possible configurations | ||
# but defaults to QLoRA + PEFT | ||
OUTPUT_DIR="test_dpo/" | ||
MODEL_NAME="HuggingFaceM4/tiny-random-LlamaForCausalLM" | ||
MAX_STEPS=5 | ||
BATCH_SIZE=2 | ||
SEQ_LEN=128 | ||
|
||
# Handle extra arguments in case one passes accelerate configs. | ||
EXTRA_ACCELERATE_ARGS="" | ||
EXTRA_TRAINING_ARGS="""--use_peft \ | ||
--load_in_4bit | ||
""" | ||
|
||
# This is a hack to get the number of available GPUs | ||
mapfile -t num_gpus < <(nvidia-smi --format=csv --query-gpu=index | tail -n+2 | wc -l) | ||
NUM_GPUS=${num_gpus[0]} | ||
|
||
if [[ "${TRL_ACCELERATE_CONFIG}" == "" ]]; then | ||
EXTRA_ACCELERATE_ARGS="" | ||
else | ||
EXTRA_ACCELERATE_ARGS="--config_file $TRL_ACCELERATE_CONFIG" | ||
# For DeepSpeed configs we need to set the `--fp16` flag to comply with our configs exposed | ||
# on `examples/accelerate_configs` and our runners do not support bf16 mixed precision training. | ||
if [[ $TRL_ACCELERATE_CONFIG == *"deepspeed"* ]]; then | ||
EXTRA_TRAINING_ARGS="--fp16" | ||
else | ||
echo "Keeping QLoRA + PEFT" | ||
fi | ||
fi | ||
|
||
|
||
CMD=""" | ||
accelerate launch $EXTRA_ACCELERATE_ARGS \ | ||
--num_processes $NUM_GPUS \ | ||
`pwd`/examples/scripts/dpo.py \ | ||
--model_name_or_path $MODEL_NAME \ | ||
--output_dir $OUTPUT_DIR \ | ||
--max_steps $MAX_STEPS \ | ||
--per_device_train_batch_size $BATCH_SIZE \ | ||
--max_length $SEQ_LEN \ | ||
$EXTRA_TRAINING_ARGS | ||
""" | ||
|
||
echo "Starting program..." | ||
|
||
{ # try | ||
echo $CMD | ||
eval "$CMD" | ||
} || { # catch | ||
# save log for exception | ||
echo "Operation Failed!" | ||
exit 1 | ||
} | ||
exit 0 |
This file contains 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 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