invoke-ai/InvokeAI · error · InvalidMatchError

PiD decoder has lq_proj hidden dim {lq_hidden_dim}, but Invo

Error message

PiD decoder has lq_proj hidden dim {lq_hidden_dim}, but InvokeAI only supports the legacy 1280-dim architecture (NVIDIA's v1.5 checkpoints are not yet supported).

What it means

InvokeAI's PiD decoder identification checks the first dimension of `lq_proj.latent_proj.0.weight` (PidNet's `lq_hidden_dim`). Only the legacy 512-dim network can be constructed; NVIDIA's v1.5 checkpoints use 1024 (plus extra modules) and are rejected as `InvalidMatchError` before the key-contract check so the diagnosis names the architecture, not a pile of missing keys.

Source

Thrown at invokeai/backend/model_manager/configs/pid_decoder.py:101

    expected = contract[_LATENT_PROJ_KEY]
    if shape is None or len(shape) != len(expected) or shape[2:] != expected[2:]:
        raise InvalidMatchError(
            f"PiD checkpoint has a malformed {_LATENT_PROJ_KEY}: expected a "
            f"{len(expected)}D conv weight with a {'x'.join(str(d) for d in expected[2:])} kernel, got "
            f"{shape if shape is not None else 'a value with no shape'}"
        )


def _raise_if_architecture_unsupported(shapes: _Shapes) -> None:
    """Reject a PiD decoder whose network shape `build_pid_net` cannot construct.

    Runs before the contract check so the diagnosis is the accurate one: a v1.5 checkpoint is intact,
    and judging it against the legacy contract would report it as a pile of missing and unexpected
    keys rather than as the newer architecture it is.
    """
    lq_hidden_dim = shapes[_LATENT_PROJ_KEY][0]  # type: ignore[index]  # rank checked above
    if lq_hidden_dim != _SUPPORTED_LQ_HIDDEN_DIM:
        raise InvalidMatchError(
            f"PiD decoder has lq_proj hidden dim {lq_hidden_dim}, but InvokeAI only supports the legacy "
            f"{_SUPPORTED_LQ_HIDDEN_DIM}-dim architecture (NVIDIA's v1.5 checkpoints are not yet supported)."
        )


def _raise_if_no_backbone_can_accept(shapes: _Shapes) -> None:
    """Reject a PiD decoder that none of the five backbone configs could ever claim.

    The counterpart to `_validate_base`, and the reason the two are separate. `_validate_base` decides
    *which* backbone a checkpoint belongs to and says "not this one" with `NotAMatchError` — four of
    the five classes are meant to say exactly that about every valid checkpoint. A rejection here is
    backbone-independent, so all five would raise it for the same reason, leaving the file with no
    match at all and letting the factory register it through the `Unknown_Config` fallback: a PiD
    decoder on record as a model nothing can load. Hence `InvalidMatchError`.

    Runs before the contract check because a decoder for an unsupported backbone would otherwise be
    reported as a shape mismatch on one weight, which is true and useless.
    """

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use the legacy (non-v1.5) PiD checkpoint with the 512-dim architecture
  2. Wait for/upgrade to an InvokeAI release that supports the v1.5 (1024-dim + PiT injection) architecture
  3. If you are certain, convert the v1.5 weights to the legacy layout — generally not possible due to added modules (PiT injection, scalar gates)
  4. Do not override `base`/format expecting it to help; the check is architecture-based and will still reject

Example fix

// before: nvidia/PiD v1.5 checkpoint -> lq_proj.latent_proj.0.weight shape [1024, C, 3, 3]
// after: download the legacy checkpoint -> shape [512, C, 3, 3]
# e.g. pick the pre-v1.5 release from https://huggingface.co/nvidia/PiD
Defensive patterns

Strategy: validation

Validate before calling

import torch
sd = torch.load(ckpt_path, map_location='cpu')
key = next(k for k in sd if 'lq_proj' in k and 'latent_proj' in k)
lq_hidden_dim = sd[key].shape[0]
if lq_hidden_dim != 512:
    raise SystemExit(f'Unsupported PiD v1.5 checkpoint (hidden dim {lq_hidden_dim}); use the legacy 512-dim release.')

Type guard

def is_legacy_pid_decoder(sd: dict) -> bool:
    key = next((k for k in sd if 'lq_proj' in k and 'latent_proj' in k), None)
    return key is not None and getattr(sd[key], 'shape', None) is not None and sd[key].shape[0] == 512

Try / catch

from invokeai.backend.model_manager.configs.identification_utils import InvalidMatchError
try:
    install_model(path)
except InvalidMatchError as e:
    if 'v1.5 checkpoints are not yet supported' in str(e):
        logger.warning('PiD v1.5 not supported; download the legacy 512-dim checkpoint.')
    else:
        raise

Prevention

When it happens

Trigger: Loading/installing a NVIDIA PiD v1.5 checkpoint (.pth with a 1024-dim lq_proj) via the model manager; `from_model_on_disk` runs `_raise_if_architecture_unsupported` after the shape-discriminator check.

Common situations: User downloaded the latest PiD v1.5 weights from HuggingFace nvidia/PiD; library updated weights but InvokeAI only supports the earlier legacy architecture release.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/8a69f24641d7a9c0. Report an issue: GitHub.