LykosAI/StabilityMatrix · error · InvalidOperationException

Qwen Image Edit requires the Qwen2.5-VL 7B text encoder…

Error message

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

What it means

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.

Solutions

  1. Download qwen_2.5_vl_7b_fp8_scaled.safetensors from huggingface.co/Comfy-Org/Qwen-Image_ComfyUI into the TextEncoders folder
  2. Keep the '7b' token in the filename so the explicit 7B match succeeds
  3. Remove or rename non-7B VL encoders that could be picked by the ambiguous fallback path
  4. Refresh the model index / restart so clientManager.ClipModels sees the encoder

Example fix

// before (only 3B encoder installed -> throw)
// after: ensure the exact 7B file is present
// models/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors
SelectModels(models); // now resolves the 7B match
Defensive patterns

Strategy: validation

Validate before calling

bool has7B = models.Clip.Any(c => c.FileName?.Contains("qwen_2.5_vl", StringComparison.OrdinalIgnoreCase) == true && c.FileName.Contains("7b", StringComparison.OrdinalIgnoreCase));
if (!has7B) throw new InvalidOperationException("Install qwen_2.5_vl_7b_fp8_scaled.safetensors");

Try / catch

try { manager.SelectModels(models); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Qwen2.5-VL 7B"))
{
    logger.LogWarning(ex, "Missing or wrong-size Qwen VL encoder");
    await PromptDownload7bEncoderAsync();
}

Prevention

When it happens

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

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

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/4434c1d312bdf12e. Report an issue: GitHub.

Appendix: source

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

        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). "
                        + "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"
            );

        return new SelectedModels(unetModel, vaeModel, clipModel);
    }

    private static bool IsQwenVlEncoder(string fileName) =>
        fileName.Contains("qwen", StringComparison.OrdinalIgnoreCase)
        && fileName.Contains("vl", StringComparison.OrdinalIgnoreCase);

    // Qwen Image Edit pairs with the Qwen2.5-VL **7B** encoder (hidden size 3584). Other
    // sizes produce "Given normalized_shape=[3584], expected input with shape [*, 3584]"
    // deep in the sampler, so they are treated as not installed. Files without any size

View on GitHub (pinned to af93d6ef57)