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
b8f1cde9
Unverified
Commit
b8f1cde9
authored
Oct 16, 2023
by
Yih-Dar
Committed by
GitHub
Oct 16, 2023
Browse files
Fix Mistral OOM again (#26847)
fix Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
fd6a0ade
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
tests/models/mistral/test_modeling_mistral.py
tests/models/mistral/test_modeling_mistral.py
+3
-2
No files found.
tests/models/mistral/test_modeling_mistral.py
View file @
b8f1cde9
...
...
@@ -437,6 +437,7 @@ class MistralIntegrationTest(unittest.TestCase):
input_ids
=
[
1
,
306
,
4658
,
278
,
6593
,
310
,
2834
,
338
]
model
=
MistralForCausalLM
.
from_pretrained
(
"mistralai/Mistral-7B-v0.1"
,
device_map
=
"auto"
)
input_ids
=
torch
.
tensor
([
input_ids
]).
to
(
model
.
model
.
embed_tokens
.
weight
.
device
)
with
torch
.
no_grad
():
out
=
model
(
input_ids
).
logits
.
cpu
()
# Expected mean on dim = -1
EXPECTED_MEAN
=
torch
.
tensor
([[
-
2.5548
,
-
2.5737
,
-
3.0600
,
-
2.5906
,
-
2.8478
,
-
2.8118
,
-
2.9325
,
-
2.7694
]])
...
...
@@ -457,8 +458,8 @@ class MistralIntegrationTest(unittest.TestCase):
EXPECTED_TEXT_COMPLETION
=
"""My favourite condiment is 100% ketchup. I love it on everything. I’m not a big"""
prompt
=
"My favourite condiment is "
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"mistralai/Mistral-7B-v0.1"
,
use_fast
=
False
)
input_ids
=
tokenizer
.
encode
(
prompt
,
return_tensors
=
"pt"
).
to
(
torch_device
)
model
=
MistralForCausalLM
.
from_pretrained
(
"mistralai/Mistral-7B-v0.1"
,
device_map
=
"auto"
)
input_ids
=
tokenizer
.
encode
(
prompt
,
return_tensors
=
"pt"
).
to
(
model
.
model
.
embed_tokens
.
weight
.
device
)
# greedy generation outputs
generated_ids
=
model
.
generate
(
input_ids
,
max_new_tokens
=
20
,
temperature
=
0
)
...
...
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