{"record":{"id":"a662153c2bbe0d5e","repo":"Comfy-Org/ComfyUI","slug":"got-params-axes-dim-but-expected-positional-dim-a66215","errorCode":null,"errorMessage":"Got {params.axes_dim} but expected positional dim {pe_dim}","messagePattern":"Got (.+?) but expected positional dim (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/hunyuan_video/model.py","lineNumber":219,"sourceCode":"    def __init__(self, image_model=None, final_layer=True, dtype=None, device=None, operations=None, **kwargs):\n        super().__init__()\n        self.dtype = dtype\n        operation_settings = {\"operations\": operations, \"device\": device, \"dtype\": dtype}\n\n        params = HunyuanVideoParams(**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        self.use_cond_type_embedding = params.use_cond_type_embedding\n        self.vision_in_dim = params.vision_in_dim\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.pe_embedder = EmbedND(dim=pe_dim, theta=params.theta, axes_dim=params.axes_dim)\n\n        self.img_in = comfy.ldm.modules.diffusionmodules.mmdit.PatchEmbed(None, self.patch_size, self.in_channels, self.hidden_size, conv3d=len(self.patch_size) == 3, dtype=dtype, device=device, operations=operations)\n        self.time_in = MLPEmbedder(in_dim=256, hidden_dim=self.hidden_size, dtype=dtype, device=device, operations=operations)\n        if params.vec_in_dim is not None:\n            self.vector_in = MLPEmbedder(params.vec_in_dim, self.hidden_size, dtype=dtype, device=device, operations=operations)\n        else:\n            self.vector_in = None\n\n        self.guidance_in = (\n            MLPEmbedder(in_dim=256, hidden_dim=self.hidden_size, dtype=dtype, device=device, operations=operations) if params.guidance_embed else nn.Identity()\n        )\n\n        self.txt_in = TokenRefiner(params.context_in_dim, self.hidden_size, self.num_heads, 2, dtype=dtype, device=device, operations=operations)\n\n        self.double_blocks = nn.ModuleList(","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/hunyuan_video/model.py#L201-L237","documentation":"Raised in the HunyuanVideo constructor when sum(params.axes_dim) does not equal head_dim = hidden_size // num_heads. The RoPE positional embedder (EmbedND) splits head_dim into per-axis frequencies (typically 3 axes for t/h/w), so the axes must exactly tile the head dimension.","triggerScenarios":"Constructing the model with a 3D axes_dim like (4,32,32) while hidden_size//num_heads = 128 (sum 64 != 128); or a 2D axes_dim applied to a 3D-patched video config after downgrading patch_size to 2D.","commonSituations":"Mixing 1.0 (2D image) and 2.1 (3D video) HunyuanVideo configs, hand-editing axes_dim for a different aspect bucketing, or transcribing configs between repos with different theta/axes conventions.","solutions":["Set axes_dim to a 3-way partition of hidden_size // num_heads that sums exactly to head_dim (e.g. head_dim 80 -> (16, 32, 32))","Check whether the checkpoint is image (2D) or video (3D) and use its original axes_dim/patch_size pair","Recompute: assert sum(axes_dim) == hidden_size // num_heads before building the model"],"exampleFix":"# before (2D image axes on a video config)\naxes_dim = (16, 112); hidden_size=1280; num_heads=16  # sum 128 != 80\n# after (3D video axes)\naxes_dim = (16, 32, 32)  # sums to 80 == 1280 // 16","handlingStrategy":"validation","validationCode":"head_dim = params.hidden_size // params.num_heads\nassert sum(params.axes_dim) == head_dim, (params.axes_dim, head_dim)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep axes_dim, patch_size, and num_heads together as one versioned config tuple","Never mix image (2D) and video (3D) config fragments"],"tags":["hunyuan-video","rope","config","init"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}