{"record":{"id":"c7a69c5504722ce7","repo":"LykosAI/StabilityMatrix","slug":"qwen-image-vae-model-not-found","errorCode":null,"errorMessage":"Qwen Image VAE model not found","messagePattern":"Qwen Image VAE model not found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs","lineNumber":139,"sourceCode":"\n    /// <summary>\n    /// Select the best available models for Qwen Image Edit (only selects LOCAL models)\n    /// </summary>\n    internal SelectedModels SelectModels(IInferenceClientManager clientManager)\n    {\n        var unetModel =\n            clientManager.UnetModels.FirstOrDefault(m =>\n                m.Local != null\n                && (\n                    m.FileName.Contains(\"qwen_image_edit\", StringComparison.OrdinalIgnoreCase)\n                    || m.FileName.Contains(\"qwen-image-edit\", StringComparison.OrdinalIgnoreCase)\n                )\n            ) ?? throw new InvalidOperationException(\"Qwen Image Edit UNET model not found\");\n\n        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). \"","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs#L121-L157","documentation":"This InvalidOperationException is thrown by QwenImageEditModelManager.SelectModels when no VAE model in the ComfyUI client's VaeModels list has a filename containing 'qwen_image_vae'. The manager requires the Qwen Image VAE checkpoint to construct the Qwen Image Edit workflow and refuses to continue without it.","triggerScenarios":"Calling SelectModels (via selectedModels) when the ComfyUI installation has no downloaded VAE whose FileName matches 'qwen_image_vae' (case-insensitive), or the VAE exists but is not indexed by the client (m.Local == null).","commonSituations":"Fresh ComfyUI installs where only the UNET/clip models were downloaded; VAE placed in the wrong folder (e.g. models/unet or models/checkpoints) so VaeModels doesn't index it; VAE file renamed so the filename no longer contains 'qwen_image_vae'.","solutions":["Download qwen_image_vae.safetensors from huggingface.co/Comfy-Org/Qwen-Image_ComfyUI and place it in ComfyUI's models/vae folder","Verify the filename still contains 'qwen_image_vae' (rename it if it was changed)","Refresh the model index / restart the app so clientManager.VaeModels picks up the new file","Confirm the file finished downloading (partial downloads may not be indexed)"],"exampleFix":"// before (missing VAE -> throw)\nSelectModels(models);\n// after (pre-check the VAE before invoking)\nif (!models.Vae.Any(v => v.FileName.Contains(\"qwen_image_vae\", StringComparison.OrdinalIgnoreCase)))\n    throw new InvalidOperationException(\"Download qwen_image_vae.safetensors into models/vae first\");\nSelectModels(models);","handlingStrategy":"validation","validationCode":"bool hasVae = models.Vae.Any(v => v.FileName?.Contains(\"qwen_image_vae\", StringComparison.OrdinalIgnoreCase) == true);\nif (!hasVae) throw new InvalidOperationException(\"Qwen Image VAE missing from models/vae\");","typeGuard":null,"tryCatchPattern":"try { manager.SelectModels(models); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"VAE model not found\"))\n{\n    logger.LogWarning(ex, \"Qwen Image VAE not installed\");\n    await PromptDownloadVaeAsync();\n}","preventionTips":["Always install the Qwen Image VAE alongside the UNET model","Keep original model filenames so filename matching works","Refresh the model index after adding files"],"tags":["model-missing","comfyui","qwen-image"],"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"}