Comfy-Org/ComfyUI · error · ValueError
Unknown rope_img: {rope_img}
Error message
Unknown rope_img: {rope_img} What it means
calc_sizes accepts only two rope_img modes: 'extend' (plain grid over (th, tw)) and 'baseXXX' (interpolate relative to a base resolution, where XXX is the pixel size divided by 8*patch_size). Any other string is rejected because there is no defined way to build the position grid.
Source
Thrown at comfy/ldm/hydit/posemb_layers.py:205
freqs_sin = freqs.sin().repeat_interleave(2, dim=1) # [S, D]
return freqs_cos, freqs_sin
else:
freqs_cis = torch.polar(torch.ones_like(freqs), freqs) # complex64 # [S, D/2]
return freqs_cis
def calc_sizes(rope_img, patch_size, th, tw):
if rope_img == 'extend':
# Expansion mode
sub_args = [(th, tw)]
elif rope_img.startswith('base'):
# Based on the specified dimensions, other dimensions are obtained through interpolation.
base_size = int(rope_img[4:]) // 8 // patch_size
start, stop = get_fill_resize_and_crop((th, tw), base_size)
sub_args = [start, stop, (th, tw)]
else:
raise ValueError(f"Unknown rope_img: {rope_img}")
return sub_args
def init_image_posemb(rope_img,
resolutions,
patch_size,
hidden_size,
num_heads,
log_fn,
rope_real=True,
):
freqs_cis_img = {}
for reso in resolutions:
th, tw = reso.height // 8 // patch_size, reso.width // 8 // patch_size
sub_args = calc_sizes(rope_img, patch_size, th, tw)
freqs_cis_img[str(reso)] = get_2d_rotary_pos_embed(hidden_size // num_heads, *sub_args, use_real=rope_real)
log_fn(f" Using image RoPE ({rope_img}) ({'real' if rope_real else 'complex'}): {sub_args} | ({reso}) "
f"{freqs_cis_img[str(reso)][0].shape if rope_real else freqs_cis_img[str(reso)].shape}")View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Use 'extend' for plain grids, or 'base' + integer size like 'base1024' for the interpolated mode
- Check the model's config file for the exact rope_img string the checkpoint was trained with
- If you need a new mode, add an explicit branch rather than passing an unknown string
Example fix
# before rope_img = "1024" # ValueError # after rope_img = "base1024"
Defensive patterns
Strategy: validation
Validate before calling
assert rope_img == 'extend' or (rope_img.startswith('base') and rope_img[4:].isdigit()), rope_img Type guard
def is_valid_rope_img(v: str) -> bool:
return v == 'extend' or (v.startswith('base') and v[4:].isdigit()) Prevention
- Keep rope_img as an enum of two shapes in config tooling
- Validate config strings at load, not at forward
When it happens
Trigger: Calling init_image_posemb/calc_sizes with rope_img values like 'xy', 'base', '1024', or a typo such as 'extenda'; the 'base' branch requires trailing digits (e.g. 'base512').
Common situations: Ported config keys from other DiT implementations (Flux/Wan use different rope names), typos, or checkpoint configs with unsupported bucketing strategies.
Related errors
- Got {params.axes_dim} but expected positional dim {pe_dim}
- Got {params.axes_dim} but expected positional dim {pe_dim}
- Unknown interpolation method {self.interpolation}
- Got {params.axes_dim} but expected positional dim {pe_dim}
- Got {params.axes_dim} but expected positional dim {pe_dim}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/e2686e8cdf667579.
Report an issue: GitHub.