Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Adapter pissa_init does not exist #4992

Closed
1 task done
xinghaow99 opened this issue Jul 28, 2024 · 3 comments · Fixed by #4995
Closed
1 task done

ValueError: Adapter pissa_init does not exist #4992

xinghaow99 opened this issue Jul 28, 2024 · 3 comments · Fixed by #4995
Labels
solved This problem has been already solved

Comments

@xinghaow99
Copy link

Reminder

  • I have read the README and searched the existing issues.

System Info

  • llamafactory version: 0.8.4.dev0
  • Platform: Linux-5.4.119-19.0009.28-x86_64-with-glibc2.31
  • Python version: 3.10.14
  • PyTorch version: 2.4.0+cu121 (GPU)
  • Transformers version: 4.43.3
  • Datasets version: 2.20.0
  • Accelerate version: 0.33.0
  • PEFT version: 0.12.0
  • TRL version: 0.9.6
  • GPU type: NVIDIA H800
  • DeepSpeed version: 0.14.4

Reproduction

### model
model_name_or_path: meta-llama/Llama-2-7b-hf

### method
stage: sft
do_train: true
finetuning_type: lora
lora_target: all
pissa_init: true
pissa_iter: 16
pissa_convert: true

### dataset
dataset_dir: LLaMA-Factory/data
dataset: identity,alpaca_en_demo
template: llama2
cutoff_len: 1024
max_samples: 100
overwrite_cache: true
preprocessing_num_workers: 16

### output
output_dir: ckpts/pissa_sft/llama-2-7b
logging_steps: 10
save_steps: 500
plot_loss: true
overwrite_output_dir: true

### train
per_device_train_batch_size: 1
gradient_accumulation_steps: 8
learning_rate: 1.0e-4
num_train_epochs: 3.0
lr_scheduler_type: cosine
warmup_ratio: 0.1
bf16: true
ddp_timeout: 180000000

examples中pissa样例,报错:

Traceback (most recent call last):
  File "/home/jovyan/wxh/LLaMA-Factory/src/llamafactory/launcher.py", line 23, in <module>
    launch()
  File "/home/jovyan/wxh/LLaMA-Factory/src/llamafactory/launcher.py", line 19, in launch
    run_exp()
  File "/home/jovyan/wxh/LLaMA-Factory/src/llamafactory/train/tuner.py", line 50, in run_exp
    run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks)
  File "/home/jovyan/wxh/LLaMA-Factory/src/llamafactory/train/sft/workflow.py", line 94, in run_sft
    train_result = trainer.train(resume_from_checkpoint=training_args.resume_from_checkpoint)
  File "/home/jovyan/conda-env/envs/wxh_lf/lib/python3.10/site-packages/transformers/trainer.py", line 1938, in train
    return inner_training_loop(
  File "/home/jovyan/conda-env/envs/wxh_lf/lib/python3.10/site-packages/transformers/trainer.py", line 2438, in _inner_training_loop
    self.control = self.callback_handler.on_train_end(args, self.state, self.control)
  File "/home/jovyan/conda-env/envs/wxh_lf/lib/python3.10/site-packages/transformers/trainer_callback.py", line 463, in on_train_end
    return self.call_event("on_train_end", args, state, control)
  File "/home/jovyan/conda-env/envs/wxh_lf/lib/python3.10/site-packages/transformers/trainer_callback.py", line 507, in call_event
    result = getattr(callback, event)(
  File "/home/jovyan/wxh/LLaMA-Factory/src/llamafactory/train/callbacks.py", line 168, in on_train_end
    model.delete_adapter("pissa_init")
  File "/home/jovyan/conda-env/envs/wxh_lf/lib/python3.10/site-packages/peft/tuners/lora/model.py", line 821, in delete_adapter
    raise ValueError(f"Adapter {adapter_name} does not exist")
ValueError: Adapter pissa_init does not exist

Expected behavior

No response

Others

No response

@github-actions github-actions bot added the pending This problem is yet to be addressed label Jul 28, 2024
@codemayq codemayq mentioned this issue Jul 29, 2024
2 tasks
@codemayq
Copy link
Collaborator

临时你可以 按照 这个 https://github.com/hiyouga/LLaMA-Factory/pull/4995, 手动修复一下。
另外 在推理的时候需要指定 lora 位置如下, 否则可能会出错

adapter_name_or_path: saves/llama3-8b/lora/sft/pissa_converted

@codemayq codemayq added solved This problem has been already solved and removed pending This problem is yet to be addressed labels Jul 29, 2024
@hiyouga hiyouga closed this as completed Jul 29, 2024
@keakon-pureglobal
Copy link

@codemayq @hiyouga 修改后在推理或导出时会报 size mismatch:

  File "/home/ps/.pyenv/versions/3.10.14/envs/train/lib/python3.10/site-packages/peft/utils/save_and_load.py", line 395, in set_peft_model_state_dict
    load_result = model.load_state_dict(peft_model_state_dict, strict=False)
  File "/home/ps/.pyenv/versions/3.10.14/envs/train/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2215, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for PeftModelForCausalLM:
        size mismatch for base_model.model.model.layers.0.attention.wqkv.lora_A.default.weight: copying a param with shape torch.Size([8, 4096]) from checkpoint, the shape in current model is torch.Size([16, 4096]).

用的是 webui,只要用 pissa 微调就出错。

@keakon-pureglobal
Copy link

搞定了,自己构造一个 yaml,把 adapter_name_or_path 改成 pissa_converted 的地址,然后执行 llamafactory-cli webchat xxx.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants