Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
00bf4427
Unverified
Commit
00bf4427
authored
Mar 06, 2024
by
Fanli Lin
Committed by
GitHub
Mar 06, 2024
Browse files
[FIX] `offload_weight()` takes from 3 to 4 positional arguments but 5 were given (#29457)
* use require_torch_gpu * enable on XPU * fix
parent
7b01579f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+1
-1
tests/test_modeling_utils.py
tests/test_modeling_utils.py
+2
-2
No files found.
src/transformers/modeling_utils.py
View file @
00bf4427
...
...
@@ -796,7 +796,7 @@ def _load_state_dict_into_meta_model(
if
not
is_safetensors
:
offload_index
=
offload_weight
(
param
,
param_name
,
offload_folder
,
offload_index
)
elif
param_device
==
"cpu"
and
state_dict_index
is
not
None
:
state_dict_index
=
offload_weight
(
param
,
param_name
,
model
,
state_dict_folder
,
state_dict_index
)
state_dict_index
=
offload_weight
(
param
,
param_name
,
state_dict_folder
,
state_dict_index
)
elif
(
hf_quantizer
is
None
or
(
not
hf_quantizer
.
requires_parameters_quantization
)
...
...
tests/test_modeling_utils.py
View file @
00bf4427
...
...
@@ -765,7 +765,7 @@ class ModelUtilsTest(TestCasePlus):
@
require_accelerate
@
mark
.
accelerate_tests
@
require_torch_
accelerator
@
require_torch_
gpu
def
test_from_pretrained_disk_offload_task_model
(
self
):
model
=
AutoModel
.
from_pretrained
(
"hf-internal-testing/tiny-random-gpt2"
)
device_map
=
{
...
...
@@ -808,7 +808,7 @@ class ModelUtilsTest(TestCasePlus):
@
require_accelerate
@
mark
.
accelerate_tests
@
require_torch_
accelerator
@
require_torch_
gpu
def
test_from_pretrained_disk_offload_derived_to_base_model
(
self
):
derived_model
=
AutoModelForCausalLM
.
from_pretrained
(
"hf-internal-testing/tiny-random-gpt2"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment