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
574a5384
Unverified
Commit
574a5384
authored
Oct 19, 2023
by
Younes Belkada
Committed by
GitHub
Oct 19, 2023
Browse files
[`FA-2`] Revert suggestion that broke FA2 fine-tuning with quantized models (#26916)
revert
parent
caa0ff0b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
src/transformers/models/falcon/modeling_falcon.py
src/transformers/models/falcon/modeling_falcon.py
+4
-1
src/transformers/models/llama/modeling_llama.py
src/transformers/models/llama/modeling_llama.py
+4
-1
src/transformers/models/mistral/modeling_mistral.py
src/transformers/models/mistral/modeling_mistral.py
+4
-1
No files found.
src/transformers/models/falcon/modeling_falcon.py
View file @
574a5384
...
@@ -614,7 +614,10 @@ class FalconFlashAttention2(FalconAttention):
...
@@ -614,7 +614,10 @@ class FalconFlashAttention2(FalconAttention):
input_dtype
=
query_layer
.
dtype
input_dtype
=
query_layer
.
dtype
if
input_dtype
==
torch
.
float32
:
if
input_dtype
==
torch
.
float32
:
# Handle the case where the model is quantized
# Handle the case where the model is quantized
target_dtype
=
getattr
(
self
.
config
,
"_pre_quantization_dtype"
,
self
.
query_key_value
.
weight
.
dtype
)
if
hasattr
(
self
.
config
,
"_pre_quantization_dtype"
):
target_dtype
=
self
.
config
.
_pre_quantization_dtype
else
:
target_dtype
=
self
.
query_key_value
.
weight
.
dtype
logger
.
warning_once
(
logger
.
warning_once
(
f
"The input hidden states seems to be silently casted in float32, this might be related to"
f
"The input hidden states seems to be silently casted in float32, this might be related to"
...
...
src/transformers/models/llama/modeling_llama.py
View file @
574a5384
...
@@ -476,7 +476,10 @@ class LlamaFlashAttention2(LlamaAttention):
...
@@ -476,7 +476,10 @@ class LlamaFlashAttention2(LlamaAttention):
input_dtype
=
query_states
.
dtype
input_dtype
=
query_states
.
dtype
if
input_dtype
==
torch
.
float32
:
if
input_dtype
==
torch
.
float32
:
# Handle the case where the model is quantized
# Handle the case where the model is quantized
target_dtype
=
getattr
(
self
.
config
,
"_pre_quantization_dtype"
,
self
.
q_proj
.
weight
.
dtype
)
if
hasattr
(
self
.
config
,
"_pre_quantization_dtype"
):
target_dtype
=
self
.
config
.
_pre_quantization_dtype
else
:
target_dtype
=
self
.
q_proj
.
weight
.
dtype
logger
.
warning_once
(
logger
.
warning_once
(
f
"The input hidden states seems to be silently casted in float32, this might be related to"
f
"The input hidden states seems to be silently casted in float32, this might be related to"
...
...
src/transformers/models/mistral/modeling_mistral.py
View file @
574a5384
...
@@ -409,7 +409,10 @@ class MistralFlashAttention2(MistralAttention):
...
@@ -409,7 +409,10 @@ class MistralFlashAttention2(MistralAttention):
input_dtype
=
query_states
.
dtype
input_dtype
=
query_states
.
dtype
if
input_dtype
==
torch
.
float32
:
if
input_dtype
==
torch
.
float32
:
# Handle the case where the model is quantized
# Handle the case where the model is quantized
target_dtype
=
getattr
(
self
.
config
,
"_pre_quantization_dtype"
,
self
.
q_proj
.
weight
.
dtype
)
if
hasattr
(
self
.
config
,
"_pre_quantization_dtype"
):
target_dtype
=
self
.
config
.
_pre_quantization_dtype
else
:
target_dtype
=
self
.
q_proj
.
weight
.
dtype
logger
.
warning_once
(
logger
.
warning_once
(
f
"The input hidden states seems to be silently casted in float32, this might be related to"
f
"The input hidden states seems to be silently casted in float32, this might be related to"
...
...
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