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
ComfyUI
Commits
fb3b7282
"vscode:/vscode.git/clone" did not exist on "f64ac3269f3212d460aae2e814c2462a39c894c6"
Commit
fb3b7282
authored
Sep 11, 2023
by
comfyanonymous
Browse files
Fix issue where autocast fp32 CLIP gave different results from regular.
parent
7d401ed1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
comfy/sd1_clip.py
comfy/sd1_clip.py
+4
-1
No files found.
comfy/sd1_clip.py
View file @
fb3b7282
...
...
@@ -60,6 +60,9 @@ class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
if
dtype
is
not
None
:
self
.
transformer
.
to
(
dtype
)
self
.
transformer
.
text_model
.
embeddings
.
token_embedding
.
to
(
torch
.
float32
)
self
.
transformer
.
text_model
.
embeddings
.
position_embedding
.
to
(
torch
.
float32
)
self
.
max_length
=
max_length
if
freeze
:
self
.
freeze
()
...
...
@@ -138,7 +141,7 @@ class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
tokens
=
self
.
set_up_textual_embeddings
(
tokens
,
backup_embeds
)
tokens
=
torch
.
LongTensor
(
tokens
).
to
(
device
)
if
backup_embeds
.
weight
.
dtype
!=
torch
.
float32
:
if
self
.
transformer
.
text_model
.
final_layer_norm
.
weight
.
dtype
!=
torch
.
float32
:
precision_scope
=
torch
.
autocast
else
:
precision_scope
=
lambda
a
,
b
:
contextlib
.
nullcontext
(
a
)
...
...
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