sgl-project/sglang · error · ValueError

Hunyuan3D Paint does not use extra UNet conditioning.

Error message

Hunyuan3D Paint does not use extra UNet conditioning.

What it means

The Hunyuan3D Paint UNet forward explicitly rejects timestep_cond and cross_attention_kwargs because this pipeline variant handles conditioning internally (via camera info, reference embeddings, and the block-level caches). Passing either argument raises this ValueError immediately.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/hunyuan3d_paint.py:325

        encoder_hidden_states: torch.Tensor,
        *,
        ref_latents: torch.Tensor,
        num_in_batch: int,
        condition_embed_dict: dict[str, torch.Tensor],
        normal_imgs: torch.Tensor | None = None,
        position_imgs: torch.Tensor | None = None,
        camera_info_gen: torch.Tensor,
        camera_info_ref: torch.Tensor,
        ref_scale: float | torch.Tensor = 1.0,
        mva_scale: float | torch.Tensor = 1.0,
        position_attn_mask: dict[int, torch.Tensor] | None = None,
        timestep_cond: torch.Tensor | None = None,
        cross_attention_kwargs: dict[str, Any] | None = None,
        added_cond_kwargs: dict[str, torch.Tensor] | None = None,
        return_dict: bool = True,
    ) -> StableDiffusionUNetOutput | tuple[torch.Tensor]:
        if timestep_cond is not None or cross_attention_kwargs is not None:
            raise ValueError("Hunyuan3D Paint does not use extra UNet conditioning.")
        if added_cond_kwargs is not None:
            raise ValueError("Hunyuan3D Paint does not use added conditioning.")
        batch_size, num_generated, _, height, width = sample.shape
        if height != width or num_generated != num_in_batch:
            raise ValueError(
                "Hunyuan3D Paint expects square latents and a matching view count."
            )

        camera_gen = rearrange(
            camera_info_gen + self.max_num_ref_images, "b n -> (b n)"
        )
        inputs = [sample]
        if normal_imgs is not None:
            inputs.append(normal_imgs)
        if position_imgs is not None:
            inputs.append(position_imgs)
        sample = rearrange(torch.cat(inputs, dim=2), "b n c h w -> (b n) c h w")
        encoder_gen = encoder_hidden_states.unsqueeze(1).repeat(1, num_generated, 1, 1)

View on GitHub (pinned to 0132848349)

Solutions

  1. Call the paint UNet forward without timestep_cond and cross_attention_kwargs
  2. Use the pipeline/sampling code shipped with Hunyuan3D Paint rather than a generic diffusers scheduler loop
  3. If writing a custom sampler, strip those arguments before invoking this UNet

Example fix

# before
noise_pred = unet(sample, t, encoder_hidden_states=ctx, cross_attention_kwargs=kwargs)["sample"]

# after
noise_pred = unet(sample, t, encoder_hidden_states=ctx)["sample"]
Defensive patterns

Strategy: validation

Validate before calling

assert timestep_cond is None and cross_attention_kwargs is None, 'paint UNet takes no timestep_cond/cross_attention_kwargs'

Prevention

When it happens

Trigger: Calling the paint UNet's forward with a non-None timestep_cond or cross_attention_kwargs — typical when reusing a generic diffusers sampling loop (DDIM/Euler) that always forwards these to the UNet.

Common situations: Plugging the paint UNet into a standard diffusers pipeline or custom sampler that passes cross_attention_kwargs by default; copying sample code from a vanilla SD pipeline.

Related errors


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