Skip to content

Commit c3cf41f

Browse files
committed
adding some tests
1 parent 243173f commit c3cf41f

File tree

2 files changed

+589
-0
lines changed

2 files changed

+589
-0
lines changed

src/diffusers/quantizers/quantization_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,19 @@ class FinegrainedFP8Config(QuantizationConfigMixin):
737737
The size of the weight blocks for quantization, default is (128, 128).
738738
modules_to_not_convert (`list`, *optional*):
739739
A list of module names that should not be converted during quantization.
740+
741+
Example:
742+
```python
743+
from diffusers import FluxTransformer2DModel, FinegrainedFP8Config
744+
745+
quantization_config = FinegrainedFP8Config()
746+
transformer = FluxTransformer2DModel.from_pretrained(
747+
"black-forest-labs/Flux.1-Dev",
748+
subfolder="transformer",
749+
quantization_config=quantization_config,
750+
torch_dtype=torch.bfloat16,
751+
)
752+
```
740753
"""
741754

742755
def __init__(
@@ -759,7 +772,9 @@ def post_init(self):
759772
self.activation_scheme = self.activation_scheme.lower()
760773
if self.activation_scheme not in ["dynamic"]:
761774
raise ValueError(f"Activation scheme {self.activation_scheme} not supported")
775+
762776
if len(self.weight_block_size) != 2:
763777
raise ValueError("weight_block_size must be a tuple of two integers")
778+
764779
if self.weight_block_size[0] <= 0 or self.weight_block_size[1] <= 0:
765780
raise ValueError("weight_block_size must be a tuple of two positive integers")

0 commit comments

Comments
 (0)