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
06116314
Unverified
Commit
06116314
authored
Aug 07, 2025
by
Sayak Paul
Committed by
GitHub
Aug 07, 2025
Browse files
[tests] tighten compilation tests for quantization (#12002)
* tighten compilation tests for quantization * up * up
parent
5780776c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
tests/quantization/bnb/test_4bit.py
tests/quantization/bnb/test_4bit.py
+1
-0
tests/quantization/bnb/test_mixed_int8.py
tests/quantization/bnb/test_mixed_int8.py
+4
-0
tests/quantization/test_torch_compile_utils.py
tests/quantization/test_torch_compile_utils.py
+8
-2
No files found.
tests/quantization/bnb/test_4bit.py
View file @
06116314
...
@@ -886,6 +886,7 @@ class Bnb4BitCompileTests(QuantCompileTests, unittest.TestCase):
...
@@ -886,6 +886,7 @@ class Bnb4BitCompileTests(QuantCompileTests, unittest.TestCase):
components_to_quantize
=
[
"transformer"
,
"text_encoder_2"
],
components_to_quantize
=
[
"transformer"
,
"text_encoder_2"
],
)
)
@
require_bitsandbytes_version_greater
(
"0.46.1"
)
def
test_torch_compile
(
self
):
def
test_torch_compile
(
self
):
torch
.
_dynamo
.
config
.
capture_dynamic_output_shape_ops
=
True
torch
.
_dynamo
.
config
.
capture_dynamic_output_shape_ops
=
True
super
().
test_torch_compile
()
super
().
test_torch_compile
()
...
...
tests/quantization/bnb/test_mixed_int8.py
View file @
06116314
...
@@ -847,6 +847,10 @@ class Bnb8BitCompileTests(QuantCompileTests, unittest.TestCase):
...
@@ -847,6 +847,10 @@ class Bnb8BitCompileTests(QuantCompileTests, unittest.TestCase):
components_to_quantize
=
[
"transformer"
,
"text_encoder_2"
],
components_to_quantize
=
[
"transformer"
,
"text_encoder_2"
],
)
)
@
pytest
.
mark
.
xfail
(
reason
=
"Test fails because of an offloading problem from Accelerate with confusion in hooks."
" Test passes without recompilation context manager. Refer to https://github.com/huggingface/diffusers/pull/12002/files#r2240462757 for details."
)
def
test_torch_compile
(
self
):
def
test_torch_compile
(
self
):
torch
.
_dynamo
.
config
.
capture_dynamic_output_shape_ops
=
True
torch
.
_dynamo
.
config
.
capture_dynamic_output_shape_ops
=
True
super
().
_test_torch_compile
(
torch_dtype
=
torch
.
float16
)
super
().
_test_torch_compile
(
torch_dtype
=
torch
.
float16
)
...
...
tests/quantization/test_torch_compile_utils.py
View file @
06116314
...
@@ -56,11 +56,17 @@ class QuantCompileTests:
...
@@ -56,11 +56,17 @@ class QuantCompileTests:
pipe
.
transformer
.
compile
(
fullgraph
=
True
)
pipe
.
transformer
.
compile
(
fullgraph
=
True
)
# small resolutions to ensure speedy execution.
# small resolutions to ensure speedy execution.
with
torch
.
_dynamo
.
config
.
patch
(
error_on_recompile
=
True
):
pipe
(
"a dog"
,
num_inference_steps
=
2
,
max_sequence_length
=
16
,
height
=
256
,
width
=
256
)
pipe
(
"a dog"
,
num_inference_steps
=
2
,
max_sequence_length
=
16
,
height
=
256
,
width
=
256
)
def
_test_torch_compile_with_cpu_offload
(
self
,
torch_dtype
=
torch
.
bfloat16
):
def
_test_torch_compile_with_cpu_offload
(
self
,
torch_dtype
=
torch
.
bfloat16
):
pipe
=
self
.
_init_pipeline
(
self
.
quantization_config
,
torch_dtype
)
pipe
=
self
.
_init_pipeline
(
self
.
quantization_config
,
torch_dtype
)
pipe
.
enable_model_cpu_offload
()
pipe
.
enable_model_cpu_offload
()
# regional compilation is better for offloading.
# see: https://pytorch.org/blog/torch-compile-and-diffusers-a-hands-on-guide-to-peak-performance/
if
getattr
(
pipe
.
transformer
,
"_repeated_blocks"
):
pipe
.
transformer
.
compile_repeated_blocks
(
fullgraph
=
True
)
else
:
pipe
.
transformer
.
compile
()
pipe
.
transformer
.
compile
()
# small resolutions to ensure speedy execution.
# small resolutions to ensure speedy execution.
...
...
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