Skip to content

[Bug] GGUF with 5D patch_embedding fails #1759

Description

@desirel-dev

Git commit

Subject: Wan 2.1 GGUF with 5D patch_embedding fails on older builds – request for compatibility note

Hi leejet,

First of all, thank you for the amazing work on stable-diffusion.cpp — I use sd-server daily on Windows with Vulkan (Intel Iris Xe) and it's the only backend that runs reliably on my hardware.

I'm hitting a loader mismatch with Wan 2.1 1.3B models exported by current community converters.

Environment:

sd-server.exe commit bb84971 (pre-September 2025 build)
Model: wan2.1-i2v-1.3b-480p-q8_0.gguf (from city96 / calcuis)
Command: --diffusion-model wan2.1-i2v-1.3b-480p-q8_0.gguf --t5xxl umt5-xxl-encoder-Q4_K_M.gguf --vae wan_2.1_vae.safetensors

Error:
Code

[ERROR] ggml_extend.hpp:70 - gguf_init_from_reader: tensor 'patch_embedding.weight' has invalid number of dimensions: 5 > 4
[ERROR] ggml_extend.hpp:70 - gguf_init_from_reader: failed to read tensor info
[ERROR] stable-diffusion.cpp:1416 - model metadata validation failed

The GGUF contains patch_embedding.weight with shape [2, 2, 1, 48, 1536] (5D), while the loader in this build expects max 4D. I understand that Wan 2.1 support (including 5D tensors) was added on 2025-09-14, but many users still use older prebuilt binaries.

Would it be possible to either:

Add a clear note in the README/releases that Wan 2.1 GGUFs require build >= 2025-09-14 due to 5D patch_embedding, or
Consider a small backport that gracefully reports "model requires newer build with 5D support" instead of the generic dimension error?

I'm happy to test any patch on Windows/Vulkan if helpful.

Thanks again for your work, and for maintaining such a lightweight project.

Best regards,

Operating System & Version

win11

GGML backends

Vulkan

Command-line arguments used

sd-cpp> cd C:\sd-cpp; .\sd-server.exe --diffusion-model wan2.1-fun-control-1.3b-q8_0.gguf --t5xxl umt5-xxl-encoder-Q4_K_M.gguf --vae wan_2.1_vae.safetensors -l 127.0.0.1 --listen-port 8080 --backend diffusion=vulkan0,vae=cpu,te=cpu --threads 8 --fa .\sd-server.exe :

Steps to reproduce

sd-cpp> cd C:\sd-cpp; .\sd-server.exe --diffusion-model wan2.1-fun-control-1.3b-q8_0.gguf --t5xxl umt5-xxl-encoder-Q4_K_M.gguf --vae wan_2.1_vae.safetensors -l 127.0.0.1 --listen-port 8080 --backend diffusion=vulkan0,vae=cpu,te=cpu --threads 8 --fa
.\sd-server.exe :

What you expected to happen

change that if (tensor->n_dims > 4) {
LOG_ERROR("tensor '%s' has invalid number of dimensions: %d > 4", name, tensor->n_dims);
return false;
}

What actually happened

error dim>4

Logs / error messages / stack trace

No response

Additional context / environment details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions