Comfy-Org/ComfyUI · critical · ValueError

Hidden size {params.hidden_size} must be divisible by num_he

Error message

Hidden size {params.hidden_size} must be divisible by num_heads {params.num_heads}

What it means

ChromaRadiance performs the same head-divisibility validation as its Chroma parent: hidden_size must be divisible by num_heads because attention splits the per-head dimension (pe_dim) out of hidden_size. The parameters come from ChromaRadianceParams(**kwargs), which extends the Chroma config with NeRF/radiance fields but keeps the same attention geometry. A mismatch is a malformed config and fails at construction.

Source

Thrown at comfy/ldm/chroma_radiance/model.py:60

    use_sequential_txt_ids: bool

class ChromaRadiance(Chroma):
    """
    Transformer model for flow matching on sequences.
    """

    def __init__(self, image_model=None, final_layer=True, dtype=None, device=None, operations=None, **kwargs):
        if operations is None:
            raise RuntimeError("Attempt to create ChromaRadiance object without setting operations")
        nn.Module.__init__(self)
        self.dtype = dtype
        params = ChromaRadianceParams(**kwargs)
        self.params = params
        self.patch_size = params.patch_size
        self.in_channels = params.in_channels
        self.out_channels = params.out_channels
        if params.hidden_size % params.num_heads != 0:
            raise ValueError(
                f"Hidden size {params.hidden_size} must be divisible by num_heads {params.num_heads}"
            )
        pe_dim = params.hidden_size // params.num_heads
        if sum(params.axes_dim) != pe_dim:
            raise ValueError(f"Got {params.axes_dim} but expected positional dim {pe_dim}")
        self.hidden_size = params.hidden_size
        self.num_heads = params.num_heads
        self.in_dim = params.in_dim
        self.out_dim = params.out_dim
        self.hidden_dim = params.hidden_dim
        self.n_layers = params.n_layers
        self.pe_embedder = EmbedND(dim=pe_dim, theta=params.theta, axes_dim=params.axes_dim)
        self.img_in_patch = operations.Conv2d(
            params.in_channels,
            params.hidden_size,
            kernel_size=params.patch_size,
            stride=params.patch_size,
            bias=True,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Verify the checkpoint's hidden_size and num_heads against the official Chroma Radiance configuration
  2. Choose num_heads as a divisor of hidden_size (typically head_dim of 125 for the 3000/24 config)
  3. Re-download the checkpoint if the stored config looks corrupted

Example fix

# before
ChromaRadiance(hidden_size=3000, num_heads=32, ...)  # 3000 % 32 != 0

# after
ChromaRadiance(hidden_size=3000, num_heads=24, ...)  # 3000 % 24 == 0
Defensive patterns

Strategy: validation

Validate before calling

if config["hidden_size"] % config["num_heads"] != 0:
    config["num_heads"] = config["hidden_size"] // 125  # official head_dim
model = ChromaRadiance(**config, operations=ops)

Prevention

When it happens

Trigger: Constructing ChromaRadiance with a config whose hidden_size % num_heads != 0, e.g. a community radiance checkpoint that stores num_heads=32 against hidden_size=3000 (3000/32 = 93.75).

Common situations: Loading a non-standard or corrupted Chroma Radiance checkpoint; merging config edits (e.g. changing num_heads for memory reasons) without keeping divisibility; a detection function picking up config values from the wrong checkpoint section.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/218816e7409ed890. Report an issue: GitHub.