Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

Summary

Fix shape mismatch when loading GGUF-quantized Z-Image transformer models.

GGUF Z-Image models store x_pad_token and cap_pad_token with shape [3840], but diffusers ZImageTransformer2DModel expects [1, 3840] (with batch dimension). This caused a RuntimeError on Linux systems when loading models like z_image_turbo-Q4_K.gguf.

The fix:

  • Dequantizes GGMLTensors first (since they don't support unsqueeze)
  • Reshapes the tensors to add the missing batch dimension

Related Issues / Discussions

Reported by Linux user using:

QA Instructions

  1. Install a GGUF-quantized Z-Image model (e.g., z_image_turbo-Q4_K.gguf)
  2. Install a Qwen3 GGUF encoder
  3. Run a Z-Image generation
  4. Verify no RuntimeError: size mismatch for x_pad_token error occurs

Merge Plan

None, straightforward fix.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

GGUF Z-Image models store x_pad_token and cap_pad_token with shape [dim],
but diffusers ZImageTransformer2DModel expects [1, dim]. This caused a
RuntimeError when loading GGUF-quantized Z-Image models.

The fix dequantizes GGMLTensors first (since they don't support unsqueeze),
then reshapes to add the batch dimension.
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Dec 22, 2025
@blessedcoolant blessedcoolant merged commit 90e3400 into invoke-ai:main Dec 23, 2025
13 checks passed
@Pfannkuchensack Pfannkuchensack deleted the fix/z-image-gguf-padding-token-shape branch December 23, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants