{"record":{"id":"d5f6729bc5449cdc","repo":"Comfy-Org/ComfyUI","slug":"got-params-axes-dim-but-expected-positional-dim","errorCode":null,"errorMessage":"Got {params.axes_dim} but expected positional dim {pe_dim}","messagePattern":"Got (.+?) but expected positional dim (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ldm/chroma/model.py","lineNumber":67,"sourceCode":"    \"\"\"\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        super().__init__()\n        self.dtype = dtype\n        params = ChromaParams(**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 = operations.Linear(self.in_channels, self.hidden_size, bias=True, dtype=dtype, device=device)\n        self.txt_in = operations.Linear(params.context_in_dim, self.hidden_size, dtype=dtype, device=device)\n        # set as nn identity for now, will overwrite it later.\n        self.distilled_guidance_layer = Approximator(\n                    in_dim=self.in_dim,\n                    hidden_dim=self.hidden_dim,\n                    out_dim=self.out_dim,\n                    n_layers=self.n_layers,\n                    dtype=dtype, device=device, operations=operations\n                )\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/chroma/model.py#L49-L85","documentation":"After checking head divisibility, Chroma derives pe_dim = hidden_size // num_heads and requires the rotational-position-embedding axes_dim list to sum exactly to pe_dim: each axis gets a slice of the per-head dim in EmbedND. If sum(axes_dim) != pe_dim, RoPE would be built over the wrong dimensionality, so the constructor rejects the config. This is the same family of check as [121]: config-derived parameters must be internally consistent.","triggerScenarios":"Constructing Chroma with axes_dim whose entries do not sum to hidden_size // num_heads. E.g. hidden_size=3000, num_heads=24 gives pe_dim=125 but axes_dim=[16,56,56] sums to 128 - the constructor raises.","commonSituations":"Porting a config from a different DiT (Flux-style axes_dim=[16,56,56] with 128 head dim) into Chroma; editing axes_dim when customizing positional encoding without recomputing pe_dim; loading a misidentified checkpoint.","solutions":["Recompute axes_dim so its entries sum to hidden_size // num_heads (pe_dim)","If editing one axes_dim entry (e.g. the time axis), adjust another entry so the total stays equal to pe_dim","Restore the official Chroma axes_dim values from the checkpoint config instead of hand-writing them"],"exampleFix":"# before\n# hidden_size=3000, num_heads=24 -> pe_dim=125\naxes_dim = [16, 56, 56]  # sums to 128, raises\n\n# after\npe_dim = hidden_size // num_heads\nt_axes = pe_dim - 56 - 56  # keep image axes at 56 each, derive the rest\naxes_dim = [t_axes, 56, 56]","handlingStrategy":"validation","validationCode":"pe_dim = hidden_size // num_heads\nif sum(axes_dim) != pe_dim:\n    axes_dim = [pe_dim - sum(axes_dim[1:])] + list(axes_dim[1:])  # rebalance first axis\nassert sum(axes_dim) == pe_dim","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat axes_dim as derived, not free: compute the last axis as pe_dim minus the fixed axes","Unit-test config builders: assert sum(axes_dim) == hidden_size // num_heads"],"tags":["chroma","rope","positional-encoding","config","model-init"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}