Skip to content

Commit 3f67ed0

Browse files
committed
update
1 parent bf1ac4a commit 3f67ed0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/diffusers/loaders/single_file_utils.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
6161

6262
CHECKPOINT_KEY_NAMES = {
63+
"v1": "model.diffusion_model.output_blocks.11.0.skip_connection.weight",
6364
"v2": "model.diffusion_model.input_blocks.2.1.transformer_blocks.0.attn2.to_k.weight",
6465
"xl_base": "conditioner.embedders.1.model.transformer.resblocks.9.mlp.c_proj.bias",
6566
"xl_refiner": "conditioner.embedders.0.model.transformer.resblocks.9.mlp.c_proj.bias",
@@ -2196,12 +2197,6 @@ def convert_flux_transformer_checkpoint_to_diffusers(checkpoint, **kwargs):
21962197
if "model.diffusion_model." in k:
21972198
checkpoint[k.replace("model.diffusion_model.", "")] = checkpoint.pop(k)
21982199

2199-
original_flux = any(k.startswith("double_blocks.") for k in checkpoint) or any(
2200-
k.startswith("single_blocks.") for k in checkpoint
2201-
)
2202-
if not original_flux:
2203-
return checkpoint
2204-
22052200
num_layers = list(set(int(k.split(".", 2)[1]) for k in checkpoint if "double_blocks." in k))[-1] + 1 # noqa: C401
22062201
num_single_layers = list(set(int(k.split(".", 2)[1]) for k in checkpoint if "single_blocks." in k))[-1] + 1 # noqa: C401
22072202
mlp_ratio = 4.0

tests/quantization/gguf/test_gguf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def _check_for_gguf_linear(model):
212212

213213
class FluxGGUFSingleFileTests(GGUFSingleFileTesterMixin, unittest.TestCase):
214214
ckpt_path = "https://huggingface.co/city96/FLUX.1-dev-gguf/blob/main/flux1-dev-Q2_K.gguf"
215+
diffusers_ckpt_path = "https://huggingface.co/sayakpaul/flux-diffusers-gguf/blob/main/model-Q4_0.gguf"
215216
torch_dtype = torch.bfloat16
216217
model_cls = FluxTransformer2DModel
217218
expected_memory_use_in_gb = 5
@@ -296,6 +297,16 @@ def test_pipeline_inference(self):
296297
max_diff = numpy_cosine_similarity_distance(expected_slice, output_slice)
297298
assert max_diff < 1e-4
298299

300+
def test_loading_gguf_diffusers_format(self):
301+
model = self.model_cls.from_single_file(
302+
self.diffusers_ckpt_path,
303+
subfolder="transformer",
304+
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
305+
config="black-forest-labs/FLUX.1-dev",
306+
)
307+
model.to("cuda")
308+
model(**self.get_dummy_inputs())
309+
299310

300311
class SD35LargeGGUFSingleFileTests(GGUFSingleFileTesterMixin, unittest.TestCase):
301312
ckpt_path = "https://huggingface.co/city96/stable-diffusion-3.5-large-gguf/blob/main/sd3.5_large-Q4_0.gguf"

0 commit comments

Comments
 (0)