Source: llm/axolotl
Axolotl#
This example is using the same config located OpenAccess-AI-Collective/axolotl
Simple training example
HF_TOKEN=abc sky launch -c axolotl axolotl.yaml --env HF_TOKEN -y -i30 --down
ssh -L 8888:localhost:8888 axolotl
sky down axolotl -y
To launch an unmanaged spot instance (no auto-recovery; good for debugging)
HF_TOKEN=abc BUCKET=<unique-name> sky launch -c axolotl-spot axolotl-spot.yaml --env HF_TOKEN --env BUCKET -i30 --down
ssh -L 8888:localhost:8888 axolotl-spot
Launch managed spot instances (auto-recovery; for full runs):
HF_TOKEN=abc BUCKET=<unique-name> sky jobs launch -n axolotl-spot axolotl-spot.yaml --env HF_TOKEN --env BUCKET
Included files#
axolotl-docker.yaml
# Usage:
# HF_TOKEN=abc sky launch -c axolotl axolotl.yaml --env HF_TOKEN -y -i30 --down
name: axolotl
resources:
accelerators: L4:1
cloud: gcp # optional
workdir: mistral
setup: |
docker pull winglian/axolotl:main-py3.10-cu118-2.0.1
run: |
docker run --gpus all \
-v ~/sky_workdir:/sky_workdir \
-v /root/.cache:/root/.cache \
winglian/axolotl:main-py3.10-cu118-2.0.1 \
huggingface-cli login --token ${HF_TOKEN}
docker run --gpus all \
-v ~/sky_workdir:/sky_workdir \
-v /root/.cache:/root/.cache \
winglian/axolotl:main-py3.10-cu118-2.0.1 \
accelerate launch -m axolotl.cli.train /sky_workdir/qlora.yaml
envs:
HF_TOKEN: # TODO: Fill with your own huggingface token, or use --env to pass.
axolotl-spot.yaml
# Usage:
#
# Unmanaged spot (no auto-recovery; for debugging):
# HF_TOKEN=abc BUCKET=<unique-name> sky launch -c axolotl-spot axolotl-spot.yaml --env HF_TOKEN --env BUCKET -i30 --down
#
# Managed spot (auto-recovery; for full runs):
# HF_TOKEN=abc BUCKET=<unique-name> sky jobs launch -n axolotl-spot axolotl-spot.yaml --env HF_TOKEN --env BUCKET
name: axolotl
resources:
accelerators: A100:1
cloud: gcp # optional
use_spot: True
image_id: docker:winglian/axolotl:main-py3.10-cu118-2.0.1
workdir: mistral
file_mounts:
/sky-notebook:
name: ${BUCKET}
mode: MOUNT
run: |
huggingface-cli login --token ${HF_TOKEN}
accelerate launch -m axolotl.cli.train qlora-checkpoint.yaml
envs:
HF_TOKEN: # TODO: Fill with your own huggingface token, or use --env to pass.
BUCKET: # TODO: Fill with your unique bucket name, or use --env to pass.
axolotl.yaml
# Usage:
# HF_TOKEN=abc sky launch -c axolotl axolotl.yaml --env HF_TOKEN -y -i30 --down
name: axolotl
resources:
accelerators: L4:1
image_id: docker:winglian/axolotl:main-py3.10-cu118-2.0.1
workdir: mistral
run: |
huggingface-cli login --token ${HF_TOKEN}
accelerate launch -m axolotl.cli.train qlora.yaml
envs:
HF_TOKEN: # TODO: Fill with your own huggingface token, or use --env to pass.
mistral/qlora-checkpoint.yaml
base_model: mistralai/Mistral-7B-v0.1
model_type: MistralForCausalLM
tokenizer_type: LlamaTokenizer
is_mistral_derived_model: true
load_in_8bit: false
load_in_4bit: true
strict: false
datasets:
- path: mhenrichsen/alpaca_2k_test
type: alpaca
dataset_prepared_path: /sky-notebook/alpaca_2k_test/last_run_prepared
val_set_size: 0.05
output_dir: /sky-notebook/alpaca_2k_test
# hub_model_id: manishiitg/mistral-alpaca_2k_test # TODO: Replace with hub model id
# hf_use_auth_token: false # TODO: push as private or public model
adapter: qlora
lora_model_dir:
sequence_len: 8192
sample_packing: true
pad_to_sequence_len: true
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_linear: true
lora_fan_in_fan_out:
lora_target_modules:
- gate_proj
- down_proj
- up_proj
- q_proj
- v_proj
- k_proj
- o_proj
wandb_project:
wandb_entity:
wandb_watch:
wandb_run_id:
wandb_log_model:
gradient_accumulation_steps: 4
micro_batch_size: 2
num_epochs: 1
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002
train_on_inputs: false
group_by_length: false
bf16: true
fp16: false
tf32: false
gradient_checkpointing: true
early_stopping_patience:
resume_from_checkpoint:
auto_resume_from_checkpoints: true ## manage check point resume from here
local_rank:
logging_steps: 1
xformers_attention:
flash_attention: true
warmup_steps: 10
eval_steps: 0.05
eval_table_size:
eval_table_max_new_tokens: 128
eval_sample_packing: false
save_steps: 2 ## increase based on your dataset
save_strategy: steps
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
special_tokens:
bos_token: "<s>"
eos_token: "</s>"
unk_token: "<unk>"
mistral/qlora.yaml
base_model: mistralai/Mistral-7B-v0.1
model_type: MistralForCausalLM
tokenizer_type: LlamaTokenizer
is_mistral_derived_model: true
load_in_8bit: false
load_in_4bit: true
strict: false
datasets:
- path: mhenrichsen/alpaca_2k_test
type: alpaca
dataset_prepared_path: last_run_prepared
val_set_size: 0.05
output_dir: ./qlora-out
# hub_model_id: manishiitg/mhenrichsen-alpaca_2k_test # TODO: Replace with hub model id
# hf_use_auth_token: false # TODO: push as private or public model
adapter: qlora
lora_model_dir:
sequence_len: 8192
sample_packing: true
pad_to_sequence_len: true
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_linear: true
lora_fan_in_fan_out:
lora_target_modules:
- gate_proj
- down_proj
- up_proj
- q_proj
- v_proj
- k_proj
- o_proj
wandb_project:
wandb_entity:
wandb_watch:
wandb_run_id:
wandb_log_model:
gradient_accumulation_steps: 4
micro_batch_size: 2
num_epochs: 1
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002
train_on_inputs: false
group_by_length: false
bf16: true
fp16: false
tf32: false
gradient_checkpointing: true
early_stopping_patience:
resume_from_checkpoint:
local_rank:
logging_steps: 1
xformers_attention:
flash_attention: true
warmup_steps: 10
eval_steps: 0.05
eval_table_size:
eval_table_max_new_tokens: 128
eval_sample_packing: false
save_steps:
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
special_tokens:
bos_token: "<s>"
eos_token: "</s>"
unk_token: "<unk>"