Skip to content

Support for transformers versions < 4.46.1 will soon be discontinued due to issues with incorrect gradient accumulation. #29

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

Open
1 task done
chenzihan1 opened this issue Mar 14, 2025 · 1 comment

Comments

@chenzihan1
Copy link

Reminder

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

System Info

该LLama-Factory版本只支持transformers versions < 4.46.1,但是这个版本存在梯度计算错误的问题。是否考虑更新版本来解决该问题。

Reproduction

grpo_02: Traceback (most recent call last):
grpo_02: File "/mnt/tenant-home_speed/czh/360-LLaMA-Factory-sp/src/train.py", line 15, in
grpo_02: from llamafactory.train.tuner import run_exp
grpo_02: File "/mnt/tenant-home_speed/czh/360-LLaMA-Factory-sp/src/llamafactory/train/tuner.py", line 25, in
grpo_02: from ..hparams import get_infer_args, get_train_args
grpo_02: File "/mnt/tenant-home_speed/czh/360-LLaMA-Factory-sp/src/llamafactory/hparams/init.py", line 20, in
grpo_02: from .parser import get_eval_args, get_infer_args, get_train_args
grpo_02: File "/mnt/tenant-home_speed/czh/360-LLaMA-Factory-sp/src/llamafactory/hparams/parser.py", line 44, in
grpo_02: check_dependencies()
grpo_02: File "/mnt/tenant-home_speed/czh/360-LLaMA-Factory-sp/src/llamafactory/extras/misc.py", line 83, in check_dependencies
grpo_02: require_version("transformers>=4.41.2,<=4.46.1", "To fix: pip install transformers>=4.41.2,<=4.46.1")
grpo_02: File "/root/miniconda3/envs/lf_sp/lib/python3.10/site-packages/transformers/utils/versions.py", line 111, in require_version
grpo_02: _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
grpo_02: File "/root/miniconda3/envs/lf_sp/lib/python3.10/site-packages/transformers/utils/versions.py", line 44, in _compare_versions
grpo_02: raise ImportError(
grpo_02: ImportError: transformers>=4.41.2,<=4.46.1 is required for a normal functioning of this module, but found transformers==4.48.3.
grpo_02: To fix: pip install transformers>=4.41.2,<=4.46.1

Expected behavior

No response

Others

No response

@HaoshengZou
Copy link
Collaborator

可以先注释掉
require_version("transformers>=4.41.2,<=4.46.1", "To fix: pip install transformers>=4.41.2,<=4.46.1")

然后用你想用的transformer版本。

建议使用LLaMA-Factory主仓最新划定的transformer版本
https://github.com/hiyouga/LLaMA-Factory/blob/main/src/llamafactory/extras/misc.py#L91
https://github.com/hiyouga/LLaMA-Factory/blob/main/src/llamafactory/extras/misc.py#L97

我们之前也发现4.46梯度累积有bug #1 ,< 4.46的反而不算bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants