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
renzhc
diffusers_dcu
Commits
9723f8a5
Unverified
Commit
9723f8a5
authored
Nov 02, 2023
by
Patrick von Platen
Committed by
GitHub
Nov 02, 2023
Browse files
[Tests] Fix cpu offload test (#5626)
* fix more * fix more
parent
b81f709f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+7
-7
No files found.
tests/pipelines/test_pipelines_common.py
View file @
9723f8a5
...
@@ -742,14 +742,14 @@ class PipelineTesterMixin:
...
@@ -742,14 +742,14 @@ class PipelineTesterMixin:
max_diff
=
np
.
abs
(
to_np
(
output_with_offload
)
-
to_np
(
output_without_offload
)).
max
()
max_diff
=
np
.
abs
(
to_np
(
output_with_offload
)
-
to_np
(
output_without_offload
)).
max
()
self
.
assertLess
(
max_diff
,
expected_max_diff
,
"CPU offloading should not affect the inference results"
)
self
.
assertLess
(
max_diff
,
expected_max_diff
,
"CPU offloading should not affect the inference results"
)
offloaded_modules
=
[
v
for
k
,
v
in
pipe
.
components
.
items
()
if
isinstance
(
v
,
torch
.
nn
.
Module
)
and
k
not
in
pipe
.
_exclude_from_cpu_offload
]
self
.
assertTrue
(
self
.
assertTrue
(
all
(
all
(
v
.
device
.
type
==
"cpu"
for
v
in
offloaded_modules
)
v
.
device
==
"cpu"
),
f
"Not offloaded:
{
[
v
for
v
in
offloaded_modules
if
v
.
device
.
type
!=
'cpu'
]
}
"
for
k
,
v
in
pipe
.
components
.
values
()
if
isinstance
(
v
,
torch
.
nn
.
Module
)
and
k
not
in
pipe
.
_exclude_from_cpu_offload
),
"CPU offloading should leave all pipeline components on the CPU after inference"
,
)
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
torch_device
!=
"cuda"
or
not
is_xformers_available
(),
torch_device
!=
"cuda"
or
not
is_xformers_available
(),
...
...
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