{"record":{"id":"218816e7409ed890","repo":"Comfy-Org/ComfyUI","slug":"hidden-size-params-hidden-size-must-be-divisible-218816","errorCode":null,"errorMessage":"Hidden size {params.hidden_size} must be divisible by num_heads {params.num_heads}","messagePattern":"Hidden size (.+?) must be divisible by num_heads (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ldm/chroma_radiance/model.py","lineNumber":60,"sourceCode":"    use_sequential_txt_ids: bool\n\nclass ChromaRadiance(Chroma):\n    \"\"\"\n    Transformer model for flow matching on sequences.\n    \"\"\"\n\n    def __init__(self, image_model=None, final_layer=True, dtype=None, device=None, operations=None, **kwargs):\n        if operations is None:\n            raise RuntimeError(\"Attempt to create ChromaRadiance object without setting operations\")\n        nn.Module.__init__(self)\n        self.dtype = dtype\n        params = ChromaRadianceParams(**kwargs)\n        self.params = params\n        self.patch_size = params.patch_size\n        self.in_channels = params.in_channels\n        self.out_channels = params.out_channels\n        if params.hidden_size % params.num_heads != 0:\n            raise ValueError(\n                f\"Hidden size {params.hidden_size} must be divisible by num_heads {params.num_heads}\"\n            )\n        pe_dim = params.hidden_size // params.num_heads\n        if sum(params.axes_dim) != pe_dim:\n            raise ValueError(f\"Got {params.axes_dim} but expected positional dim {pe_dim}\")\n        self.hidden_size = params.hidden_size\n        self.num_heads = params.num_heads\n        self.in_dim = params.in_dim\n        self.out_dim = params.out_dim\n        self.hidden_dim = params.hidden_dim\n        self.n_layers = params.n_layers\n        self.pe_embedder = EmbedND(dim=pe_dim, theta=params.theta, axes_dim=params.axes_dim)\n        self.img_in_patch = operations.Conv2d(\n            params.in_channels,\n            params.hidden_size,\n            kernel_size=params.patch_size,\n            stride=params.patch_size,\n            bias=True,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/chroma_radiance/model.py#L42-L78","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the checkpoint's hidden_size and num_heads against the official Chroma Radiance configuration","Choose num_heads as a divisor of hidden_size (typically head_dim of 125 for the 3000/24 config)","Re-download the checkpoint if the stored config looks corrupted"],"exampleFix":"# before\nChromaRadiance(hidden_size=3000, num_heads=32, ...)  # 3000 % 32 != 0\n\n# after\nChromaRadiance(hidden_size=3000, num_heads=24, ...)  # 3000 % 24 == 0","handlingStrategy":"validation","validationCode":"if config[\"hidden_size\"] % config[\"num_heads\"] != 0:\n    config[\"num_heads\"] = config[\"hidden_size\"] // 125  # official head_dim\nmodel = ChromaRadiance(**config, operations=ops)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate divisibility before constructing; keep official head_dim","Treat configs from community radiance checkpoints with suspicion and cross-check against official values"],"tags":["chroma-radiance","attention","config","model-init"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}