LykosAI/StabilityMatrix · error · InvalidOperationException

Qwen Image VAE model not found

Error message

Qwen Image VAE model not found

What it means

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.

Solutions

  1. Download qwen_image_vae.safetensors from huggingface.co/Comfy-Org/Qwen-Image_ComfyUI and place it in ComfyUI's models/vae folder
  2. Verify the filename still contains 'qwen_image_vae' (rename it if it was changed)
  3. Refresh the model index / restart the app so clientManager.VaeModels picks up the new file
  4. Confirm the file finished downloading (partial downloads may not be indexed)

Example fix

// before (missing VAE -> throw)
SelectModels(models);
// after (pre-check the VAE before invoking)
if (!models.Vae.Any(v => v.FileName.Contains("qwen_image_vae", StringComparison.OrdinalIgnoreCase)))
    throw new InvalidOperationException("Download qwen_image_vae.safetensors into models/vae first");
SelectModels(models);
Defensive patterns

Strategy: validation

Validate before calling

bool hasVae = models.Vae.Any(v => v.FileName?.Contains("qwen_image_vae", StringComparison.OrdinalIgnoreCase) == true);
if (!hasVae) throw new InvalidOperationException("Qwen Image VAE missing from models/vae");

Try / catch

try { manager.SelectModels(models); }
catch (InvalidOperationException ex) when (ex.Message.Contains("VAE model not found"))
{
    logger.LogWarning(ex, "Qwen Image VAE not installed");
    await PromptDownloadVaeAsync();
}

Prevention

When it happens

Trigger: 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).

Common situations: 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'.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/c7a69c5504722ce7. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/Services/QwenImageEditModelManager.cs:139

    /// <summary>
    /// Select the best available models for Qwen Image Edit (only selects LOCAL models)
    /// </summary>
    internal SelectedModels SelectModels(IInferenceClientManager clientManager)
    {
        var unetModel =
            clientManager.UnetModels.FirstOrDefault(m =>
                m.Local != null
                && (
                    m.FileName.Contains("qwen_image_edit", StringComparison.OrdinalIgnoreCase)
                    || m.FileName.Contains("qwen-image-edit", StringComparison.OrdinalIgnoreCase)
                )
            ) ?? throw new InvalidOperationException("Qwen Image Edit UNET model not found");

        var vaeModel =
            clientManager.VaeModels.FirstOrDefault(m =>
                m.Local != null && m.FileName.Contains("qwen_image_vae", StringComparison.OrdinalIgnoreCase)
            ) ?? throw new InvalidOperationException("Qwen Image VAE model not found");

        // Prefer an explicit 7B match, then any VL encoder without a size hint (could be a
        // renamed 7B). Smaller VL encoders (e.g. the 3B, hidden size 2048) load fine but die
        // mid-sampling with "expected input with shape [*, 3584]", so fail fast with a clear
        // message instead of silently picking one.
        var clipModel =
            clientManager.ClipModels.FirstOrDefault(m =>
                m.Local != null
                && IsQwenVlEncoder(m.FileName)
                && m.FileName.Contains("7b", StringComparison.OrdinalIgnoreCase)
            )
            ?? clientManager.ClipModels.FirstOrDefault(m =>
                m.Local != null && IsUsableQwenVlEncoder(m.FileName)
            )
            ?? throw new InvalidOperationException(
                clientManager.ClipModels.Any(m => m.Local != null && IsQwenVlEncoder(m.FileName))
                    ? "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). "

View on GitHub (pinned to af93d6ef57)