Model Mismatch

mat1 and mat2 shapes cannot be multiplied

RuntimeError: mat1 and mat2 shapes cannot be multiplied (Ax768 and 1024xB)

A tensor dimension mismatch, almost always caused by pairing a text encoder, LoRA, or ControlNet from one model architecture with a base model of another.

What it means

This is a matrix-multiplication shape error: two tensors that need compatible inner dimensions do not have them. In practice it is a mismatch between model families — the numbers in the message are the giveaway. A 768-wide tensor is the SD 1.5 conditioning width; 1024/2048 widths belong to SDXL. When those meet, the multiply is impossible.

The fix is almost never to change sampler settings. It is to make every component in the graph belong to the same architecture: the checkpoint, the CLIP/text encoder that produces the conditioning, and any LoRA or ControlNet applied on top.

Common causes

  • An SD 1.5 text encoder/CLIP feeding conditioning into an SDXL model (or vice versa).
  • A LoRA trained for one architecture applied to a base model of another.
  • A ControlNet built for a different model family than the checkpoint.
  • A mismatched CLIP loader left over from a previous workflow.

How to fix it

  1. 1

    Read the dimensions in the message

    Note the two widths (e.g. 768 vs 1024). 768 points to an SD 1.5 component; 1024/2048 point to SDXL. That tells you which side is the odd one out.

  2. 2

    Match the text encoder to the base model

    Use the CLIP/text encoder that ships with — or matches — your checkpoint. For SDXL, both CLIP encoders must be the SDXL ones; do not mix in an SD 1.5 encoder.

  3. 3

    Use architecture-matched LoRAs and ControlNets

    Replace any LoRA or ControlNet with one trained for the same architecture as your checkpoint. An SD 1.5 LoRA cannot be applied to an SDXL model.

  4. 4

    Rebuild the conditioning path if unsure

    Delete and re-add the loader and CLIP-encode nodes from a known-good template for that architecture to rule out a stale connection.

Tracking which checkpoint, encoder, and LoRA versions produced a working image makes architecture mismatches easy to avoid on the next run — the compatible set is recorded, not remembered.

Frequently asked questions

Frequently Asked Questions

Quick answers to the most common questions.

Related nodes

Related errors

Make every ComfyUI run reproducible

Numonic captures the full workflow behind each ComfyUI generation — models, samplers, seeds, prompts, and custom nodes — so a setup that finally works is one you can find and rebuild, not re-debug.