{"record":{"id":"1e1513023d5311f3","repo":"LykosAI/StabilityMatrix","slug":"qwen-image-edit-unet-model-not-found","errorCode":null,"errorMessage":"Qwen Image Edit UNET model not found","messagePattern":"Qwen Image Edit UNET model not found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs","lineNumber":134,"sourceCode":"                _ => model.FileName,\n            };\n            yield return name;\n        }\n    }\n\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)","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs#L116-L152","documentation":"QwenImageEditModelManager.SelectModels throws this InvalidOperationException when the connected client's UNET model list contains no local model whose file name contains 'qwen_image_edit' or 'qwen-image-edit' (case-insensitive). The workflow requires that specific checkpoint to build the Qwen Image Edit graph.","triggerScenarios":"Running the Qwen Image Edit workflow while the required qwen_image_edit UNET diffusion model is absent from the ComfyUI models/unet (or diffusion_models) directory, or is present but not registered locally (m.Local == null).","commonSituations":"User never downloaded the Qwen Image Edit model; model placed in the wrong folder (checkpoints instead of unet); file renamed so the 'qwen_image_edit'/'qwen-image-edit' substring no longer matches; ComfyUI not rescanned after adding the model.","solutions":["Download the Qwen Image Edit UNET model into ComfyUI's models/unet (diffusion_models) directory","Ensure the file name contains 'qwen_image_edit' or 'qwen-image-edit' (no arbitrary renaming)","Rescan/refresh the model list in ComfyUI so it appears in clientManager.UnetModels with a Local entry","Verify the manager's connection is fresh (UnetModels populated from the current server) and retry"],"exampleFix":"// before\nvar models = manager.SelectModels(); // throws if UNET missing\n// after\nvar hasQwen = clientManager.UnetModels.Any(m => m.Local != null\n    && (m.FileName.Contains(\"qwen_image_edit\", StringComparison.OrdinalIgnoreCase)\n        || m.FileName.Contains(\"qwen-image-edit\", StringComparison.OrdinalIgnoreCase)));\nif (!hasQwen)\n{\n    throw new InvalidOperationException(\"Download the Qwen Image Edit UNET model into models/unet first\");\n}\nvar models = manager.SelectModels();","handlingStrategy":"validation","validationCode":"var unet = clientManager.UnetModels.FirstOrDefault(m => m.Local != null\n    && (m.FileName.Contains(\"qwen_image_edit\", StringComparison.OrdinalIgnoreCase)\n        || m.FileName.Contains(\"qwen-image-edit\", StringComparison.OrdinalIgnoreCase)));\nif (unet is null)\n    throw new InvalidOperationException(\"Qwen Image Edit UNET model not downloaded\");","typeGuard":"bool HasQwenEditUnet(InferenceClientManager m) => m.UnetModels.Any(u => u.Local != null\n    && (u.FileName.Contains(\"qwen_image_edit\", StringComparison.OrdinalIgnoreCase)\n        || u.FileName.Contains(\"qwen-image-edit\", StringComparison.OrdinalIgnoreCase)));","tryCatchPattern":"try\n{\n    var models = qwenManager.SelectModels();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Qwen\"))\n{\n    // guide user to download the required model files\n}","preventionTips":["Pre-flight check the model list before launching the workflow","Keep model file names intact (matching substrings)","Rescan ComfyUI models after adding files","Download all required pieces (UNET, VAE, text encoders) together"],"tags":["qwen","model-missing","workflow","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"}