Comfy-Org/ComfyUI · error · ValueError
Unknown pos_emb_cls {self.pos_emb_cls}
Error message
Unknown pos_emb_cls {self.pos_emb_cls} What it means
ComfyUI's Cosmos video DiT builds its positional-embedding module in build_pos_embed(), and the only supported class string is 'rope3d' (VideoRopePosition3DEmb). Any other value of the model config field pos_emb_cls raises ValueError at model construction. The field comes from the checkpoint's JSON config, so an unknown value almost always means an unsupported or mis-parsed Cosmos checkpoint.
Source
Thrown at comfy/ldm/cosmos/model.py:217
else:
self.affline_norm = nn.Identity()
self.final_layer = FinalLayer(
hidden_size=self.model_channels,
spatial_patch_size=self.patch_spatial,
temporal_patch_size=self.patch_temporal,
out_channels=self.out_channels,
use_adaln_lora=self.use_adaln_lora,
adaln_lora_dim=self.adaln_lora_dim,
weight_args=weight_args,
operations=operations,
)
def build_pos_embed(self, device=None, dtype=None):
if self.pos_emb_cls == "rope3d":
cls_type = VideoRopePosition3DEmb
else:
raise ValueError(f"Unknown pos_emb_cls {self.pos_emb_cls}")
logging.debug(f"Building positional embedding with {self.pos_emb_cls} class, impl {cls_type}")
kwargs = dict(
model_channels=self.model_channels,
len_h=self.max_img_h // self.patch_spatial,
len_w=self.max_img_w // self.patch_spatial,
len_t=self.max_frames // self.patch_temporal,
is_learnable=self.pos_emb_learnable,
interpolation=self.pos_emb_interpolation,
head_dim=self.model_channels // self.num_heads,
h_extrapolation_ratio=self.rope_h_extrapolation_ratio,
w_extrapolation_ratio=self.rope_w_extrapolation_ratio,
t_extrapolation_ratio=self.rope_t_extrapolation_ratio,
device=device,
)
self.pos_embedder = cls_type(
**kwargs,
)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Check the checkpoint's config JSON and set pos_emb_cls to "rope3d" (the only value this implementation supports).
- If the checkpoint genuinely uses another embedding scheme, it is not supported by this port; use a Cosmos checkpoint that ships pos_emb_cls=rope3d.
- Inspect how the config reaches the model (custom-node loader) and normalize/override pos_emb_cls before construction instead of editing the checkpoint.
Example fix
// before (config from checkpoint)
cfg = {"pos_emb_cls": "rope_3d", ...}
model = CosmosImageToVideoModel(cfg, ...)
// after
cfg = {**raw_cfg, "pos_emb_cls": "rope3d"} # normalize to the only supported value
model = CosmosImageToVideoModel(cfg, ...) Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"rope3d"}
assert cfg.get("pos_emb_cls") in SUPPORTED, f"pos_emb_cls must be one of {SUPPORTED}, got {cfg.get('pos_emb_cls')!r}" Type guard
def is_valid_cosmos_pos_emb_cls(cfg: dict) -> bool:
return cfg.get("pos_emb_cls") == "rope3d" Try / catch
try:
model.build_pos_embed(device, dtype)
except ValueError as e:
raise RuntimeError(f"Unsupported Cosmos config: {e}; set pos_emb_cls='rope3d'") from e Prevention
- Normalize checkpoint configs to ComfyUI's expected schema at load time.
- Whitelist config enum fields (pos_emb_cls, pos_emb_interpolation) before model construction.
- Keep a known-good Cosmos checkpoint around to diff configs against when adding new ones.
When it happens
Trigger: Instantiating the Cosmos transformer with a config dict whose pos_emb_cls key is missing, misspelled (e.g. 'Rope3D', 'rope_3d'), or set to a variant (e.g. 'positional_embedding_3d') that this port does not implement. Happens when a custom node loads a Cosmos-family checkpoint with a config that was not remapped to ComfyUI's expected schema.
Common situations: Loading a new Cosmos/Predict2-variant checkpoint whose upstream config uses a different embedding name; a custom node passing raw model config through without sanitizing pos_emb_cls; typos in hand-written model config dicts.
Related errors
- Unknown interpolation method {self.interpolation}
- Unknown pos_emb_cls {self.pos_emb_cls}
- Normalization {name} not found
- Normalization mode {self.qkv_norm_mode} not found, only supp
- Unknown patch method: {self.patch_method}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/6a921ea4722de14c.
Report an issue: GitHub.