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

[FIX] offload_weight() takes from 3 to 4 positional arguments but 5 were given #29457

Merged
merged 5 commits into from Mar 6, 2024

Conversation

faaany
Copy link
Contributor

@faaany faaany commented Mar 5, 2024

What does this PR do?

2 tests fail with the following messages:

FAILED tests/test_modeling_utils.py::ModelUtilsTest::test_from_pretrained_disk_offload_derived_to_base_model - TypeError: offload_weight() takes from 3 to 4 positional arguments but 5 were given
FAILED tests/test_modeling_utils.py::ModelUtilsTest::test_from_pretrained_disk_offload_task_model - TypeError: offload_weight() takes from 3 to 4 positional arguments but 5 were given

Below is the Traceback:

Traceback (most recent call last):
  File "/mnt/disk4/fanlilin/transformers/fanli.py", line 42, in <module>
    new_model_with_offload = AutoModel.from_pretrained(
  File "/mnt/disk4/fanlilin/transformers/src/transformers/models/auto/auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
  File "/mnt/disk4/fanlilin/transformers/src/transformers/modeling_utils.py", line 3507, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/mnt/disk4/fanlilin/transformers/src/transformers/modeling_utils.py", line 3932, in _load_pretrained_model
    new_error_msgs, offload_index, state_dict_index = _load_state_dict_into_meta_model(
  File "/mnt/disk4/fanlilin/transformers/src/transformers/modeling_utils.py", line 798, in _load_state_dict_into_meta_model
    state_dict_index = offload_weight(param, param_name, model, state_dict_folder, state_dict_index)
TypeError: offload_weight() takes from 3 to 4 positional arguments but 5 were given

I remove the additional model argument and also change require_torch_accelerator to require_torch_gpu. Because 0 implied cuda:0 and on non-nv-gpu devices, I would get AssertionError: Torch not compiled with CUDA enabled.

@younesbelkada @SunMarc

@SunMarc SunMarc self-requested a review March 5, 2024 16:40
Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @faaany ! This is indeed a typo from this PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe great catch!

@ArthurZucker ArthurZucker merged commit 00bf442 into huggingface:main Mar 6, 2024
21 checks passed
damithsenanayake pushed a commit to damithsenanayake/transformers that referenced this pull request Mar 7, 2024
… were given (huggingface#29457)

* use require_torch_gpu

* enable on XPU

* fix
research4pan added a commit to OptimalScale/LMFlow that referenced this pull request Mar 14, 2024
- Bug introduced by `transformers 4.38.0`, fixed a week ago and will appear in
  >4.38.2 (huggingface/transformers#29457)
- By restricting `transformers<4.38.0` in `requirements.txt`
astachowiczhabana pushed a commit to astachowiczhabana/transformers that referenced this pull request May 9, 2024
… were given (huggingface#29457)

* use require_torch_gpu

* enable on XPU

* fix
astachowiczhabana pushed a commit to astachowiczhabana/transformers that referenced this pull request May 9, 2024
… were given (huggingface#29457)

* use require_torch_gpu

* enable on XPU

* fix
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

Successfully merging this pull request may close these issues.

None yet

4 participants