axolotl-ai-cloud / axolotl

Go ahead and axolotl questions
https://axolotl-ai-cloud.github.io/axolotl/
Apache License 2.0
6.99k stars 766 forks source link

ValueError: We need an `offload_dir` to dispatch this model according to this `device_map` #1251

Open mashdragon opened 5 months ago

mashdragon commented 5 months ago

Please check that this issue hasn't been reported before.

Expected Behavior

axolotl.cli.merge_lora is able to merge my LoRA with a LLaMA-based base model (cognitivecomputations/WizardLM-30B-Uncensored)

Current behaviour

After loading the checkpoints, the program exits with this message:

ValueError: We need an `offload_dir` to dispatch this model according to this `device_map`, the following submodules need to be offloaded: base_model.model.model.layers.27, base_model.model.model.layers.28, base_model.model.model.layers.29, base_model.model.model.layers.30, base_model.model.model.layers.31, base_model.model.model.layers.32, base_model.model.model.layers.33, base_model.model.model.layers.34, base_model.model.model.layers.35, base_model.model.model.layers.36, base_model.model.model.layers.37, base_model.model.model.layers.38, base_model.model.model.layers.39, base_model.model.model.layers.40, base_model.model.model.layers.41, base_model.model.model.layers.42, base_model.model.model.layers.43, base_model.model.model.layers.44, base_model.model.model.layers.45, base_model.model.model.layers.46, base_model.model.model.layers.47, base_model.model.model.layers.48, base_model.model.model.layers.49, base_model.model.model.layers.50, base_model.model.model.layers.51, base_model.model.model.layers.52, base_model.model.model.layers.53, base_model.model.model.layers.54, base_model.model.model.layers.55, base_model.model.model.layers.56, base_model.model.model.layers.57, base_model.model.model.layers.58, base_model.model.model.layers.59, base_model.model.model.norm, base_model.model.lm_head.

I've tried passing --offload_folder="<some folder>", but that did not work.

Steps to reproduce

Use examples/llama-2/qlora.yml and change the model to cognitivecomputations/WizardLM-30B-Uncensored. Train a qLoRA on this model.

Then, run CUDA_VISIBLE_DEVICES="" python3 -m axolotl.cli.merge_lora examples/llama-2/qlora.yml --lora_model_dir='./qlora-out. I moved the qlora-out folder somewhere else due to disk constraints, however. I didn't want the merged folder to be created here in ./qlora-out.

Config yaml

base_model: cognitivecomputations/WizardLM-30B-Uncensored
model_type: LlamaForCausalLM
tokenizer_type: LlamaTokenizer
is_llama_derived_model: true

load_in_8bit: false
load_in_4bit: true
strict: false

datasets:
  - path: mhenrichsen/alpaca_2k_test
    type: alpaca
dataset_prepared_path:
val_set_size: 0.05
output_dir: ./qlora-out

adapter: qlora
lora_model_dir:

sequence_len: 2048
sample_packing: true
pad_to_sequence_len: true

lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules:
lora_target_linear: true
lora_fan_in_fan_out:

wandb_project:
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model:

gradient_accumulation_steps: 8
micro_batch_size: 1
num_epochs: 2
optimizer: paged_adamw_32bit
lr_scheduler: cosine
learning_rate: 0.0002

train_on_inputs: true
group_by_length: false
bf16: auto
fp16:
tf32: false

gradient_checkpointing: true
early_stopping_patience:
resume_from_checkpoint:
local_rank:
logging_steps: 1
xformers_attention:
flash_attention: true

warmup_steps: 10
evals_per_epoch: 4
eval_table_size:
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
special_tokens:

Possible solution

No response

Which Operating Systems are you using?

Python Version

Python 3.10.12

axolotl branch-commit

main/4cb7900a567e97b278cc713ec6bd8af616d2ebf7

Acknowledgements

mashdragon commented 5 months ago

I think adding lora_on_cpu: true to the config caused it to work

Justinxixili commented 3 months ago

adding where