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
4c2538b8
Unverified
Commit
4c2538b8
authored
Jul 09, 2024
by
Joao Gante
Committed by
GitHub
Jul 09, 2024
Browse files
Test loading generation config with safetensor weights (#31550)
fix test
parent
cffa2b9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
tests/utils/test_modeling_utils.py
tests/utils/test_modeling_utils.py
+5
-10
No files found.
tests/utils/test_modeling_utils.py
View file @
4c2538b8
...
...
@@ -1424,20 +1424,15 @@ class ModelUtilsTest(TestCasePlus):
self
.
assertEqual
(
model
.
__class__
.
__name__
,
model_ref
.
__class__
.
__name__
)
def
test_generation_config_is_loaded_with_model
(
self
):
# Note: `joaogante/tiny-random-gpt2-with-generation-config` has a `generation_config.json` containing a dummy
# `transformers_version` field set to `foo`. If loading the file fails, this test also fails.
# Note: `TinyLlama/TinyLlama-1.1B-Chat-v1.0` has a `generation_config.json` containing `max_length: 2048`
# 1. Load without further parameters
model
=
AutoModelForCausalLM
.
from_pretrained
(
"joaogante/tiny-random-gpt2-with-generation-config"
,
use_safetensors
=
False
)
self
.
assertEqual
(
model
.
generation_config
.
transformers_version
,
"foo"
)
model
=
AutoModelForCausalLM
.
from_pretrained
(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0"
)
self
.
assertEqual
(
model
.
generation_config
.
max_length
,
2048
)
# 2. Load with `device_map`
model
=
AutoModelForCausalLM
.
from_pretrained
(
"joaogante/tiny-random-gpt2-with-generation-config"
,
device_map
=
"auto"
,
use_safetensors
=
False
)
self
.
assertEqual
(
model
.
generation_config
.
transformers_version
,
"foo"
)
model
=
AutoModelForCausalLM
.
from_pretrained
(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0"
,
device_map
=
"auto"
)
self
.
assertEqual
(
model
.
generation_config
.
max_length
,
2048
)
@
require_safetensors
def
test_safetensors_torch_from_torch
(
self
):
...
...
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