Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions invokeai/backend/model_manager/load/model_loaders/z_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _convert_z_image_gguf_to_diffusers(sd: dict[str, Any]) -> dict[str, Any]:
- x_embedder.* -> all_x_embedder.2-1.*
- final_layer.* -> all_final_layer.2-1.*
- norm_final.* -> skipped (diffusers uses non-learnable LayerNorm)
- x_pad_token, cap_pad_token: [dim] -> [1, dim] (diffusers expects batch dimension)
"""
new_sd: dict[str, Any] = {}

Expand All @@ -50,6 +51,17 @@ def _convert_z_image_gguf_to_diffusers(sd: dict[str, Any]) -> dict[str, Any]:
new_sd[key] = value
continue

# Handle padding tokens: GGUF has shape [dim], diffusers expects [1, dim]
if key in ("x_pad_token", "cap_pad_token"):
if hasattr(value, "shape") and len(value.shape) == 1:
# GGMLTensor doesn't support unsqueeze, so dequantize first if needed
if hasattr(value, "get_dequantized_tensor"):
value = value.get_dequantized_tensor()
# Use reshape instead of unsqueeze for better compatibility
value = torch.as_tensor(value).reshape(1, -1)
new_sd[key] = value
continue

# Handle x_embedder -> all_x_embedder.2-1
if key.startswith("x_embedder."):
suffix = key[len("x_embedder.") :]
Expand Down