sgl-project/sglang · error · ValueError

Got {config.rope_axes_dim} but expected positional dim {pe_d

Error message

Got {config.rope_axes_dim} but expected positional dim {pe_dim}

What it means

HunyuanVideo computes pe_dim = hidden_size // num_attention_heads and requires sum(config.rope_axes_dim) to equal it, since the 3-axis RoPE must exactly fill each head's channel budget. A mismatch raises this ValueError in __init__.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/hunyuanvideo.py:683

        self.patch_size = [config.patch_size_t, config.patch_size, config.patch_size]
        self.in_channels = config.in_channels
        self.num_channels_latents = config.num_channels_latents
        self.out_channels = (
            config.in_channels if config.out_channels is None else config.out_channels
        )
        self.unpatchify_channels = self.out_channels
        self.guidance_embeds = config.guidance_embeds
        self.rope_dim_list = list(config.rope_axes_dim)
        self.rope_theta = config.rope_theta
        self.text_states_dim = config.text_embed_dim
        self.text_states_dim_2 = config.pooled_projection_dim
        # TODO(will): hack?
        self.dtype = config.dtype

        pe_dim = config.hidden_size // config.num_attention_heads
        if sum(config.rope_axes_dim) != pe_dim:
            raise ValueError(
                f"Got {config.rope_axes_dim} but expected positional dim {pe_dim}"
            )

        self.hidden_size = config.hidden_size
        self.num_attention_heads = config.num_attention_heads
        self.num_channels_latents = config.num_channels_latents

        # Image projection
        self.img_in = PatchEmbed(
            self.patch_size,
            self.in_channels,
            self.hidden_size,
            dtype=config.dtype,
            prefix=f"{config.prefix}.img_in",
        )

        self.txt_in = SingleTokenRefiner(
            self.text_states_dim,

View on GitHub (pinned to 0132848349)

Solutions

  1. Set rope_axes_dim entries to sum to hidden_size//num_attention_heads (e.g. pe_dim=128 → [16,24,88] or similar valid split)
  2. If you changed heads/width, recompute rope_axes_dim to match
  3. Use the original config JSON shipped with the checkpoint

Example fix

# before
# hidden_size=3072, num_attention_heads=24 -> pe_dim=128
"rope_axes_dim": [16, 24, 32]  # sums to 72

# after
"rope_axes_dim": [16, 24, 88]  # sums to 128
Defensive patterns

Strategy: validation

Validate before calling

pe_dim = config.hidden_size // config.num_attention_heads
assert sum(config.rope_axes_dim) == pe_dim, f'{config.rope_axes_dim} != pe_dim {pe_dim}'

Type guard

def rope_axes_valid(config) -> bool:
    return sum(config.rope_axes_dim) == config.hidden_size // config.num_attention_heads

Prevention

When it happens

Trigger: Loading a HunyuanVideo config where rope_axes_dim doesn't sum to hidden_size//num_attention_heads — e.g. editing num_attention_heads or hidden_size without adjusting rope_axes_dim, or mixing configs across HunyuanVideo variants.

Common situations: Config edits for distillation/pruning experiments; merging a config from a different video model size variant; hand-writing a config file.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/2367a1d1861828ab. Report an issue: GitHub.