huggingface/pytorch-image-models · error · ValueError

Unknown rope_type: {cfg.rope_type}

Error message

Unknown rope_type: {cfg.rope_type}

What it means

The block decoder in naflexvit only supports a fixed set of rope_type values (e.g. None/'none' and the rope paths above the else branch). Any other cfg.rope_type string hits the catch-all ValueError.

Source

Thrown at timm/models/naflexvit.py:1280

                    temperature=cfg.rope_temperature,
                    feat_shape=None,  # Dynamic shapes for NaFlex
                    grid_indexing=cfg.rope_grid_indexing,
                    rotate_half=cfg.rope_rotate_half,
                    **dd,
                )
                self.rope_is_mixed = False
            elif cfg.rope_type == 'mrope':
                assert cfg.rope_mrope_section is not None, "rope_type='mrope' requires cfg.rope_mrope_section"
                self.rope = RotaryEmbeddingMRope(
                    cfg.embed_dim // cfg.num_heads,
                    mrope_section=cfg.rope_mrope_section,
                    temperature=cfg.rope_temperature,
                    grid_indexing=cfg.rope_grid_indexing,
                    **dd,
                )
                self.rope_is_mixed = False
            else:
                raise ValueError(f"Unknown rope_type: {cfg.rope_type}")

        # Patch dropout
        if cfg.patch_drop_rate > 0:
            self.patch_drop = PatchDropoutWithIndices(
                cfg.patch_drop_rate,
                num_prefix_tokens=self.num_prefix_tokens,
            )
        else:
            self.patch_drop = None

        # Transformer blocks
        dpr = calculate_drop_path_rates(cfg.drop_path_rate, cfg.depth)  # stochastic depth decay rule
        # Create transformer blocks
        self.blocks = nn.Sequential(*[
            block_fn(
                dim=cfg.embed_dim,
                num_heads=cfg.num_heads,
                mlp_ratio=cfg.mlp_ratio,

View on GitHub (pinned to 9a5261e31b)

Solutions

  1. Use one of the supported rope_type values in the block cfg (check the if/elif chain above line 1280 for accepted names)
  2. Set rope_type=None/'none' to disable RoPE

Example fix

# before
cfg = replace(cfg, rope_type='axial')
# after
cfg = replace(cfg, rope_type='rope')
Defensive patterns

Strategy: validation

Validate before calling

VALID_ROPE = {None, 'none', 'rope'}  # match branch names at naflexvit.py:1280
assert cfg.rope_type in VALID_ROPE

Prevention

When it happens

Trigger: Building NaFlexViT blocks with cfg.rope_type set to an unsupported value such as 'axial', 'partial', or a typo like 'npe' instead of 'rope'/'none'.

Common situations: Porting RoPE config keys from other ViT implementations (HF llama-style rope_type names) into timm NaFlex configs.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27). Data as JSON: /api/errors/1ea5b83e37dbadec. Report an issue: GitHub.