{"record":{"id":"4434c1d312bdf12e","repo":"LykosAI/StabilityMatrix","slug":"qwen-image-edit-requires-the-qwen2-5-vl-7b-text-encoder-but","errorCode":null,"errorMessage":"Qwen Image Edit requires the Qwen2.5-VL 7B text encoder, but only a different-size VL encoder was found (smaller variants fail with a tensor shape mismatch). Download qwen_2.5_vl_7b_fp8_scaled.safetensors from huggingface.co/Comfy-Org/Qwen-Image_ComfyUI and place it in your TextEncoders folder.|Qwen 2.5 VL CLIP model not found","messagePattern":"Qwen Image Edit requires the Qwen2\\.5-VL 7B text encoder, but only a different-size VL encoder was found \\(smaller variants fail with a tensor shape mismatch\\)\\. Download qwen_2\\.5_vl_7b_fp8_scaled\\.safetensors from huggingface\\.co/Comfy-Org/Qwen-Image_ComfyUI and place it in your TextEncoders folder\\.\\|Qwen 2\\.5 VL CLIP model not found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs","lineNumber":154,"sourceCode":"        var vaeModel =\n            clientManager.VaeModels.FirstOrDefault(m =>\n                m.Local != null && m.FileName.Contains(\"qwen_image_vae\", StringComparison.OrdinalIgnoreCase)\n            ) ?? throw new InvalidOperationException(\"Qwen Image VAE model not found\");\n\n        // Prefer an explicit 7B match, then any VL encoder without a size hint (could be a\n        // renamed 7B). Smaller VL encoders (e.g. the 3B, hidden size 2048) load fine but die\n        // mid-sampling with \"expected input with shape [*, 3584]\", so fail fast with a clear\n        // message instead of silently picking one.\n        var clipModel =\n            clientManager.ClipModels.FirstOrDefault(m =>\n                m.Local != null\n                && IsQwenVlEncoder(m.FileName)\n                && m.FileName.Contains(\"7b\", StringComparison.OrdinalIgnoreCase)\n            )\n            ?? clientManager.ClipModels.FirstOrDefault(m =>\n                m.Local != null && IsUsableQwenVlEncoder(m.FileName)\n            )\n            ?? throw new InvalidOperationException(\n                clientManager.ClipModels.Any(m => m.Local != null && IsQwenVlEncoder(m.FileName))\n                    ? \"Qwen Image Edit requires the Qwen2.5-VL 7B text encoder, but only a different-size \"\n                        + \"VL encoder was found (smaller variants fail with a tensor shape mismatch). \"\n                        + \"Download qwen_2.5_vl_7b_fp8_scaled.safetensors from \"\n                        + \"huggingface.co/Comfy-Org/Qwen-Image_ComfyUI and place it in your TextEncoders folder.\"\n                    : \"Qwen 2.5 VL CLIP model not found\"\n            );\n\n        return new SelectedModels(unetModel, vaeModel, clipModel);\n    }\n\n    private static bool IsQwenVlEncoder(string fileName) =>\n        fileName.Contains(\"qwen\", StringComparison.OrdinalIgnoreCase)\n        && fileName.Contains(\"vl\", StringComparison.OrdinalIgnoreCase);\n\n    // Qwen Image Edit pairs with the Qwen2.5-VL **7B** encoder (hidden size 3584). Other\n    // sizes produce \"Given normalized_shape=[3584], expected input with shape [*, 3584]\"\n    // deep in the sampler, so they are treated as not installed. Files without any size","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs#L136-L172","documentation":"Thrown by QwenImageEditModelManager.SelectModels when no usable Qwen2.5-VL text encoder can be selected. If any VL encoder exists but is not the 7B variant, a detailed message explains that only the 7B encoder works (smaller variants crash mid-sampling with a tensor shape mismatch); if no VL encoder is indexed at all, the plain 'Qwen 2.5 VL CLIP model not found' message is used. Note the thrown string concatenates both messages with a '|' separator, which is why the error text shows both.","triggerScenarios":"Calling SelectModels when (a) no CLIP model with a Qwen VL encoder filename is indexed, or (b) only a non-7B VL encoder (e.g. the 3B) is present, so neither the explicit 7B match nor the size-hint-free fallback can be satisfied.","commonSituations":"Downloading qwen_2.5_vl_3b instead of the required 7B encoder; encoder placed outside the TextEncoders folder so ClipModels doesn't index it; renamed file losing the '7b' hint so only the fallback branch applies and the fallback also fails.","solutions":["Download qwen_2.5_vl_7b_fp8_scaled.safetensors from huggingface.co/Comfy-Org/Qwen-Image_ComfyUI into the TextEncoders folder","Keep the '7b' token in the filename so the explicit 7B match succeeds","Remove or rename non-7B VL encoders that could be picked by the ambiguous fallback path","Refresh the model index / restart so clientManager.ClipModels sees the encoder"],"exampleFix":"// before (only 3B encoder installed -> throw)\n// after: ensure the exact 7B file is present\n// models/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors\nSelectModels(models); // now resolves the 7B match","handlingStrategy":"validation","validationCode":"bool has7B = models.Clip.Any(c => c.FileName?.Contains(\"qwen_2.5_vl\", StringComparison.OrdinalIgnoreCase) == true && c.FileName.Contains(\"7b\", StringComparison.OrdinalIgnoreCase));\nif (!has7B) throw new InvalidOperationException(\"Install qwen_2.5_vl_7b_fp8_scaled.safetensors\");","typeGuard":null,"tryCatchPattern":"try { manager.SelectModels(models); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Qwen2.5-VL 7B\"))\n{\n    logger.LogWarning(ex, \"Missing or wrong-size Qwen VL encoder\");\n    await PromptDownload7bEncoderAsync();\n}","preventionTips":["Download exactly qwen_2.5_vl_7b_fp8_scaled.safetensors, not smaller VL variants","Place encoders in the TextEncoders folder and keep '7b' in the filename","Remove 3B VL encoders from TextEncoders to avoid ambiguous fallbacks"],"tags":["model-missing","text-encoder","qwen-image","comfyui"],"backgroundTag":"resource-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}