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

QLora微调Chatglm3-6b时报错RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn #3324

Closed
1 task done
Shuming-Cheng opened this issue Apr 18, 2024 · 3 comments
Labels
solved This problem has been already solved

Comments

@Shuming-Cheng
Copy link

Reminder

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

Reproduction

CUDA_VISIBLE_DEVICES=0 python src/train_bash.py
--stage sft
--do_train True
--model_name_or_path /home/csm/Csm_Workspace/Chatglm3-6b_finetuning/model
--finetuning_type lora
--quantization_bit 4
--template chatglm3
--dataset_dir data
--dataset alpaca_zh
--cutoff_len 1024
--learning_rate 5e-05
--num_train_epochs 3.0
--max_samples 100000
--per_device_train_batch_size 2
--gradient_accumulation_steps 8
--lr_scheduler_type cosine
--max_grad_norm 1.0
--logging_steps 5
--save_steps 100
--warmup_steps 0
--optim adamw_torch
--report_to none
--output_dir saves/ChatGLM3-6B-Chat/lora/train_2024-04-18-11-34-47
--fp16 True
--lora_rank 8
--lora_alpha 16
--lora_dropout 0.1
--lora_target query_key_value
--plot_loss True

Expected behavior

使用了更新后的代码对Chatglm3进行QLora微调,之前提到的‘enable’问题已经得到了解决,但是又出现了RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn,大概知道是什么问题但是实在是没找到哪里可以改。

System Info

  • transformers version: 4.39.3
  • Platform: Linux-5.15.0-102-generic-x86_64-with-glibc2.31
  • Python version: 3.11.7
  • Huggingface_hub version: 0.22.2
  • Safetensors version: 0.4.2
  • Accelerate version: 0.29.3
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.2+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Others

No response

@hiyouga
Copy link
Owner

hiyouga commented Apr 18, 2024

已修复

@hiyouga hiyouga added the solved This problem has been already solved label Apr 18, 2024
@jiaohuix
Copy link

道是什么问题但是实在是没找到哪

大佬,这个问题是由什么原因导致的,修复的代码子在哪里可以找到哇

@Shuming-Cheng
Copy link
Author

道是什么问题但是实在是没找到哪

大佬,这个问题是由什么原因导致的,修复的代码子在哪里可以找到哇

这个问题hiyouga大佬应该已经修复了,用他现在最新的代码就可以了,自己不用改。

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

No branches or pull requests

3 participants