From 72fa10f5ef4f2231dbaa2a19e6aab64d93f8e953 Mon Sep 17 00:00:00 2001 From: KuhnChris <761911+kuhnchris@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:02:07 +0100 Subject: [PATCH] fix: detect Ming-Image vs Z-Image by pad-token presence Ming-Image shares the Lumina2 tensor shape with Z-Image but lacks the Z-Image x_pad_token tensors. Reject the Z-Image match when x_pad_token is absent so those checkpoints resolve to VERSION_MING_IMAGE. --- src/model_loader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/model_loader.cpp b/src/model_loader.cpp index 86f49d8ae..65869cef8 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) {