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
6fde5a6d
Unverified
Commit
6fde5a6d
authored
Jul 07, 2023
by
Patrick von Platen
Committed by
GitHub
Jul 07, 2023
Browse files
[Tests] Fix some slow tests (#3989)
fix some slow tests
parent
d1d0b8af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
...lines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
+1
-1
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py
...able_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py
+1
-1
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+6
-2
tests/pipelines/text_to_video/test_text_to_video.py
tests/pipelines/text_to_video/test_text_to_video.py
+8
-1
No files found.
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
View file @
6fde5a6d
...
...
@@ -183,7 +183,7 @@ class StableDiffusionXLPipeline(DiffusionPipeline, FromSingleFileMixin):
self
.
to
(
"cpu"
,
silence_dtype_warnings
=
True
)
torch
.
cuda
.
empty_cache
()
# otherwise we don't see the memory savings (but they probably exist)
for
cpu_offloaded_model
in
[
self
.
unet
,
self
.
text_encoder
,
self
.
vae
]:
for
cpu_offloaded_model
in
[
self
.
unet
,
self
.
text_encoder
,
self
.
text_encoder_2
,
self
.
vae
]:
cpu_offload
(
cpu_offloaded_model
,
device
)
def
enable_model_cpu_offload
(
self
,
gpu_id
=
0
):
...
...
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py
View file @
6fde5a6d
...
...
@@ -191,7 +191,7 @@ class StableDiffusionXLImg2ImgPipeline(DiffusionPipeline, FromSingleFileMixin):
self
.
to
(
"cpu"
,
silence_dtype_warnings
=
True
)
torch
.
cuda
.
empty_cache
()
# otherwise we don't see the memory savings (but they probably exist)
for
cpu_offloaded_model
in
[
self
.
unet
,
self
.
text_encoder
,
self
.
vae
]:
for
cpu_offloaded_model
in
[
self
.
unet
,
self
.
text_encoder
,
self
.
text_encoder_2
,
self
.
vae
]:
cpu_offload
(
cpu_offloaded_model
,
device
)
def
enable_model_cpu_offload
(
self
,
gpu_id
=
0
):
...
...
tests/pipelines/test_pipelines_common.py
View file @
6fde5a6d
...
...
@@ -699,12 +699,16 @@ class PipelineTesterMixin:
inputs
=
self
.
get_dummy_inputs
(
torch_device
)
output_without_offload
=
pipe
(
**
inputs
)[
0
]
output_without_offload
.
cpu
()
if
torch
.
is_tensor
(
output_without_offload
)
else
output_without_offload
output_without_offload
=
(
output_without_offload
.
cpu
()
if
torch
.
is_tensor
(
output_without_offload
)
else
output_without_offload
)
pipe
.
enable_xformers_memory_efficient_attention
()
inputs
=
self
.
get_dummy_inputs
(
torch_device
)
output_with_offload
=
pipe
(
**
inputs
)[
0
]
output_with_offload
.
cpu
()
if
torch
.
is_tensor
(
output_with_offload
)
else
output_without_offload
output_with_offload
=
(
output_with_offload
.
cpu
()
if
torch
.
is_tensor
(
output_with_offload
)
else
output_without_offload
)
if
test_max_difference
:
max_diff
=
np
.
abs
(
output_with_offload
-
output_without_offload
).
max
()
...
...
tests/pipelines/text_to_video/test_text_to_video.py
View file @
6fde5a6d
...
...
@@ -26,7 +26,7 @@ from diffusers import (
TextToVideoSDPipeline
,
UNet3DConditionModel
,
)
from
diffusers.utils
import
load_numpy
,
skip_mps
,
slow
from
diffusers.utils
import
is_xformers_available
,
load_numpy
,
skip_mps
,
slow
,
torch_device
from
diffusers.utils.testing_utils
import
enable_full_determinism
from
..pipeline_params
import
TEXT_TO_IMAGE_BATCH_PARAMS
,
TEXT_TO_IMAGE_PARAMS
...
...
@@ -143,6 +143,13 @@ class TextToVideoSDPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
def
test_attention_slicing_forward_pass
(
self
):
self
.
_test_attention_slicing_forward_pass
(
test_mean_pixel_difference
=
False
,
expected_max_diff
=
3e-3
)
@
unittest
.
skipIf
(
torch_device
!=
"cuda"
or
not
is_xformers_available
(),
reason
=
"XFormers attention is only available with CUDA and `xformers` installed"
,
)
def
test_xformers_attention_forwardGenerator_pass
(
self
):
self
.
_test_xformers_attention_forwardGenerator_pass
(
test_mean_pixel_difference
=
False
,
expected_max_diff
=
1e-2
)
# (todo): sayakpaul
@
unittest
.
skip
(
reason
=
"Batching needs to be properly figured out first for this pipeline."
)
def
test_inference_batch_consistent
(
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