invoke-ai/InvokeAI · error · ValueError

{noise_type} noise width and height must be a multiple of {m

Error message

{noise_type} noise width and height must be a multiple of {multiple_of}

What it means

validate_noise_dimensions enforces model-specific pixel-dimension constraints before generating latent noise: FLUX/FLUX.2/SD3/Z-Image require width and height to be multiples of 16, CogView4 multiples of 32, and other types multiples of 8 (the default). If width % multiple_of or height % multiple_of is nonzero, a ValueError naming the noise type and required multiple is raised. This ensures the latent shapes produced by dividing by LATENT_SCALE_FACTOR are valid for the transformer's patching scheme.

Source

Thrown at invokeai/app/invocations/latent_noise.py:19

from typing import Literal

import torch

from invokeai.app.invocations.constants import LATENT_SCALE_FACTOR
from invokeai.backend.util.devices import TorchDevice

LatentNoiseType = Literal["SD", "FLUX", "FLUX.2", "SD3", "CogView4", "Z-Image", "Anima"]


def validate_noise_dimensions(noise_type: LatentNoiseType, width: int, height: int) -> None:
    multiple_of = 8
    if noise_type in ("FLUX", "FLUX.2", "SD3", "Z-Image"):
        multiple_of = 16
    elif noise_type == "CogView4":
        multiple_of = 32

    if width % multiple_of != 0 or height % multiple_of != 0:
        raise ValueError(f"{noise_type} noise width and height must be a multiple of {multiple_of}")


def get_expected_noise_shape(
    noise_type: LatentNoiseType,
    width: int,
    height: int,
) -> tuple[int, ...]:
    validate_noise_dimensions(noise_type, width, height)

    if noise_type == "SD":
        return (1, 4, height // LATENT_SCALE_FACTOR, width // LATENT_SCALE_FACTOR)
    if noise_type == "FLUX":
        return (1, 16, height // LATENT_SCALE_FACTOR, width // LATENT_SCALE_FACTOR)
    if noise_type == "FLUX.2":
        return (1, 32, height // LATENT_SCALE_FACTOR, width // LATENT_SCALE_FACTOR)
    if noise_type == "SD3":
        return (1, 16, height // LATENT_SCALE_FACTOR, width // LATENT_SCALE_FACTOR)
    if noise_type == "CogView4":

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Round width and height down (or to nearest) to the required multiple before invoking: 16 for FLUX/FLUX.2/SD3/Z-Image, 32 for CogView4, 8 otherwise.
  2. Insert a resize/crop step in the workflow so the noise dimensions match the model constraint.
  3. If writing code, compute dimensions as (width // multiple_of) * multiple_of before calling generate_noise_tensor.

Example fix

// before
generate_noise_tensor("FLUX", 1026, 770, seed, device, dtype)
// after
width = (1026 // 16) * 16   # 1024
height = (770 // 16) * 16   # 768
generate_noise_tensor("FLUX", width, height, seed, device, dtype)
Defensive patterns

Strategy: validation

Validate before calling

def check_dims(noise_type: str, width: int, height: int) -> None:
    multiple_of = 8
    if noise_type in ("FLUX", "FLUX.2", "SD3", "Z-Image"):
        multiple_of = 16
    elif noise_type == "CogView4":
        multiple_of = 32
    assert width % multiple_of == 0 and height % multiple_of == 0, \
        f"{noise_type} requires width/height multiples of {multiple_of}, got {width}x{height}"

Try / catch

try:
    noise = generate_noise_tensor(noise_type, width, height, seed, device, dtype)
except ValueError as e:
    if "must be a multiple of" in str(e):
        mult = int(str(e).rsplit(" ", 1)[-1])
        width, height = (width // mult) * mult, (height // mult) * mult
        noise = generate_noise_tensor(noise_type, width, height, seed, device, dtype)
    else:
        raise

Prevention

When it happens

Trigger: Calling validate_noise_dimensions, get_expected_noise_shape, or generate_noise_tensor with width/height not divisible by the model's required multiple — e.g. width=1025 for FLUX (needs multiple of 16) or width=1000 for CogView4 (needs multiple of 32); typically from user-entered image dimensions or a workflow with an arbitrary resize node upstream.

Common situations: Users type odd resolutions in the UI (e.g. 1366x768 for FLUX); a FLUX workflow fed dimensions from an SD-sized default (like 512) is fine, but e.g. 520x520 is not; CogView4 workflows reusing FLUX-sized dimensions that are multiples of 16 but not 32.

Related errors


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