sgl-project/sglang · error · ValueError

When additional_t_cond is True, addition_t_cond must be prov

Error message

When additional_t_cond is True, addition_t_cond must be provided.

What it means

In qwen_image's timestep conditioning module, when the model was built with use_additional_t_cond=True the forward call must supply addition_t_cond; omitting it raises ValueError since the conditioning sum would be incomplete.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/qwen_image.py:135

            num_channels=256, flip_sin_to_cos=True, downscale_freq_shift=0, scale=1000
        )
        self.timestep_embedder = TimestepEmbedding(
            in_channels=256, time_embed_dim=embedding_dim
        )
        self.use_additional_t_cond = use_additional_t_cond
        if use_additional_t_cond:
            self.addition_t_embedding = nn.Embedding(2, embedding_dim)

    def forward(self, timestep, hidden_states, addition_t_cond=None):
        timesteps_proj = self.time_proj(timestep)
        timesteps_emb = self.timestep_embedder(
            timesteps_proj.to(dtype=hidden_states.dtype)
        )  # (N, D)

        conditioning = timesteps_emb
        if self.use_additional_t_cond:
            if addition_t_cond is None:
                raise ValueError(
                    "When additional_t_cond is True, addition_t_cond must be provided."
                )
            addition_t_emb = self.addition_t_embedding(addition_t_cond)
            addition_t_emb = addition_t_emb.to(dtype=hidden_states.dtype)
            conditioning = conditioning + addition_t_emb

        return conditioning


class QwenEmbedRope(nn.Module):
    def __init__(self, theta: int, axes_dim: List[int], scale_rope=False):
        super().__init__()
        self.theta = theta
        self.axes_dim = axes_dim
        pos_index = torch.arange(4096)
        neg_index = torch.arange(4096).flip(0) * -1 - 1
        self.pos_freqs = torch.cat(
            [

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass addition_t_cond (e.g. guidance values tensor) matching the batch size when calling forward
  2. If your checkpoint doesn't need it, ensure use_additional_t_cond is False in the config used to build the module
  3. Check the pipeline glue that populates timestep conditioning kwargs

Example fix

# before
emb = timestep_module(t, encoder_hidden_states.shape[0])
# after
emb = timestep_module(t, encoder_hidden_states.shape[0], addition_t_cond=guidance)
Defensive patterns

Strategy: validation

Validate before calling

if module.use_additional_t_cond:
    assert addition_t_cond is not None, "checkpoint requires addition_t_cond"

Type guard

def needs_addition_t_cond(module) -> bool:
    return bool(getattr(module, "use_additional_t_cond", False))

Prevention

When it happens

Trigger: Loading a checkpoint variant with additional timestep conditioning (e.g. distilled/plus variants) but calling forward without addition_t_cond.

Common situations: Reusing a generic pipeline call path with a checkpoint that has guidance/additional conditioning enabled; version upgrades adding the flag by default.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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