Skip to content

Ming-Image 0.1 Design no longer loads since #2396: "invalid tensor part ...attention.qkv.weight.1" and missing pad tokens #2438

Done

Description

@tmac1973

What happens

Since master-1116-bf31b9c, Ming-Image 0.1 Design fails metadata validation when the diffusion model loads, so nothing can be generated. master-1111-6874e49 loads and runs the same files. Between the two, the only change that touches model loading is #2396 (Diffusion Graph Language support), so I think that's where it came from. Still failing on master-1141-e637c7b.

The server starts fine (weights now load on demand), and the first generation fails with:

[E] Diffusion model tensor 'model.diffusion_model.cap_pad_token' not in model metadata --- model_manager.cpp:1085
[E] Diffusion model tensor 'model.diffusion_model.x_pad_token' not in model metadata --- model_manager.cpp:1085
[E] invalid tensor part 'model.diffusion_model.context_refiner.0.attention.qkv.weight.1' for 'model.diffusion_model.context_refiner.0.attention.qkv.weight' --- model_manager.cpp:1099
... (34 of these, one per attention block)
[E] model metadata validation failed --- model_runtime.cpp:474

and the request returns {"error":"line 38, column 18: cannot load component from '.../ming_image_0.1_design-Q8_0.gguf'"}.

The weights

I tested with a Q8_0 GGUF converted from Comfy-Org's ming_image_0.1_design_bf16.safetensors, the file docs/models/ming_image.md links. The GGUF has the same 519 tensors as that file, and neither has a fused QKV or any pad token:

layers.6.attention.to_q.weight     [3840, 3840]
layers.6.attention.to_k.weight     [3840, 3840]
layers.6.attention.to_v.weight     [3840, 3840]
layers.6.attention.to_out.0.weight [3840, 3840]
layers.6.attention.norm_q.weight   [128]
layers.6.attention.norm_k.weight   [128]
(no x_pad_token, no cap_pad_token)

So I'd expect the bf16 safetensors to fail the same way. I haven't run it, though.

What I suspect (not verified)

  • MingImageConfig::detect_from_weights sets split_qkv from tensors.count(prefix + ".layers.0.attention.qkv.weight") == 0. The qkv.weight.1 part names in the log suggest the loader has already mapped to_q/to_k/to_v onto parts of qkv.weight before that check runs. If so, split_qkv ends up false, the block gets one fused QKV tensor, and the parts no longer fit the shape it expects.
  • x_pad_token and cap_pad_token look like they come from the Z-Image side that Ming's config and blocks build on. Ming's checkpoint has neither, so they may need to be optional for Ming.

To reproduce

Linux x86_64, Vulkan (RX 9070 XT), the release bin-Linux-...-vulkan zips:

./sd-server \
  --diffusion-model ming_image_0.1_design-Q8_0.gguf \
  --llm ming_ling_mini_2.0-Q4_K.gguf \
  --vae ming_image_vae_bf16.safetensors \
  --tokenizer tokenizer.json \
  --diffusion-fa --backend te=cpu --vae-tiling \
  --listen-ip 127.0.0.1 --listen-port 8798

curl -s -H 'Content-Type: application/json' \
  -d '{"prompt":"x","width":256,"height":256,"steps":1,"cfg_scale":1,"sampler_name":"euler","seed":1}' \
  http://127.0.0.1:8798/sdapi/v1/txt2img

Bisected over release builds:

Release Result
master-929-3f8527a loads
master-1028-37bc88b loads
master-1078-73fef08 loads
master-1092-5d78740 loads
master-1098-b521db4 loads
master-1106-532d2c1 loads
master-1111-6874e49 loads
master-1116-bf31b9c validation fails
master-1117-0d71f96 validation fails
master-1141-e637c7b validation fails

The GGUF is public, if it helps: https://huggingface.co/voltaire321/Ming-Image-0.1-Design-GGUF

Thanks for the --api-key-file and --cors-origins work in #2367, by the way. That's what I was updating for when I hit this.

Activity

  1. kuhnchris commented on Nov 27, 2026

    @kuhnchris
    Contributor

    Does it also show "Model detected as Z-Image"?
    If so, it may be due to a detection change of the DGL, according to GLM-Flash:

    Confirmed — the reports line up exactly, and the regression window contains precisely one relevant commit:
    
    **`git log 6874e49..bf31b9c` = 5 commits, only one touches detection: `6cd0ef1` "feat: add Diffusion Graph Language support (#2396)"** (the big DGL refactor, Nov 22). The Ming detection lines in `model_loader.cpp` themselves are byte-identical across the range.
    
    **What changed:**
    
    - **Old path (master-1111, works):** `init_model_loader()` in `diffusion_engine.cpp` loaded *every* component into **one shared `ModelLoader`/tensor map** — `--diffusion-model` under `model.diffusion_model.`, then `--llm` under `text_encoders.llm.`. Only *afterward* did `apply_model_update()` call `get_sd_version()` on the **merged** map. So the Ming check could see `model.diffusion_model.cap_embedder.0.weight` **and** `text_encoders.llm.connector.layers.0.self_attn.q_proj.weight` (from the *separate TE file's* tensors) in one map → `VERSION_MING_IMAGE`. ✅
    
    - **New path (≥ the DGL commit, breaks):** `6cd0ef1` introduced `resolve_family()` (`src/dgl/models/component_sources.cpp`), which probes **only the primary file**: `probe.add_file(family_from, "")` → retry with `model.diffusion_model.` prefix → `get_sd_version()` → done. The `--llm` file is never consulted during family resolution, so `text_encoders.*.connector…` is structurally absent, the Ming branch can never fire, and the check falls through to `return VERSION_Z_IMAGE`. The old merged-map condition still exists in `get_sd_version()` but is now **dead code for split-file loading** — it can only trigger on a single combined checkpoint. ❌
    
    So the cause isn't the Ming support itself (#2063 was fine) — it's the family-probe refactor in #2396, which silently assumed every model family is identifiable from the diffusion file alone. That assumption fails for Ming, whose DiT is Lumina2-shaped and was only ever distinguished by text-encoder tensors living in a different file.
    

    Workaround that works on your existing build (no recompile): run a DGL script with explicit family = "ming_image" (pattern in docs/dgl/ming_image/ming-image-0-1-design-txt2img.dgl )

    The following diff was suggested for a permanent fix but I cannot say that this not may cause side effects, someone more aligned with tensors would need to verify:

    
    diff --git a/src/model_loader.cpp b/src/model_loader.cpp
    index 86f49d8..65869ce 100644
    --- a/src/model_loader.cpp
    +++ b/src/model_loader.cpp
    @@ -568,6 +568,11 @@ SDVersion ModelLoader::get_sd_version() const {
                 if (tensor_storage_map.find("model.diffusion_model.local_decoder.out_conv.weight") != tensor_storage_map.end()) {
                     return VERSION_Z_IMAGE_L2P;
                 }
    +            if (tensor_storage_map.find("model.diffusion_model.x_pad_token") == tensor_storage_map.end()) {
    +                // The pad tokens are part of the Z-Image architecture and always present in its
    +                // checkpoints; Ming-Image shares the Lumina2 shape without them.
    +                return VERSION_MING_IMAGE;
    +            }
                 return VERSION_Z_IMAGE;
             }
             if (tensor_storage.name.find("double_stream_layers.0.img_instruct_attn.processor.img_to_q.weight") != std::string::npos) {
    
    

    Side effect, this also makes it work with the new Ming-Image-0.2-Design (tested with the https://huggingface.co/Abiray/Ming-Image-0.2-Design-GGUF )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions