{"record":{"id":"f43e2f20d6061f1e","repo":"sgl-project/sglang","slug":"when-additional-t-cond-is-true-addition-t-cond-mu","errorCode":null,"errorMessage":"When additional_t_cond is True, addition_t_cond must be provided.","messagePattern":"When additional_t_cond is True, addition_t_cond must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/qwen_image.py","lineNumber":135,"sourceCode":"            num_channels=256, flip_sin_to_cos=True, downscale_freq_shift=0, scale=1000\n        )\n        self.timestep_embedder = TimestepEmbedding(\n            in_channels=256, time_embed_dim=embedding_dim\n        )\n        self.use_additional_t_cond = use_additional_t_cond\n        if use_additional_t_cond:\n            self.addition_t_embedding = nn.Embedding(2, embedding_dim)\n\n    def forward(self, timestep, hidden_states, addition_t_cond=None):\n        timesteps_proj = self.time_proj(timestep)\n        timesteps_emb = self.timestep_embedder(\n            timesteps_proj.to(dtype=hidden_states.dtype)\n        )  # (N, D)\n\n        conditioning = timesteps_emb\n        if self.use_additional_t_cond:\n            if addition_t_cond is None:\n                raise ValueError(\n                    \"When additional_t_cond is True, addition_t_cond must be provided.\"\n                )\n            addition_t_emb = self.addition_t_embedding(addition_t_cond)\n            addition_t_emb = addition_t_emb.to(dtype=hidden_states.dtype)\n            conditioning = conditioning + addition_t_emb\n\n        return conditioning\n\n\nclass QwenEmbedRope(nn.Module):\n    def __init__(self, theta: int, axes_dim: List[int], scale_rope=False):\n        super().__init__()\n        self.theta = theta\n        self.axes_dim = axes_dim\n        pos_index = torch.arange(4096)\n        neg_index = torch.arange(4096).flip(0) * -1 - 1\n        self.pos_freqs = torch.cat(\n            [","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/qwen_image.py#L117-L153","documentation":"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.","triggerScenarios":"Loading a checkpoint variant with additional timestep conditioning (e.g. distilled/plus variants) but calling forward without addition_t_cond.","commonSituations":"Reusing a generic pipeline call path with a checkpoint that has guidance/additional conditioning enabled; version upgrades adding the flag by default.","solutions":["Pass addition_t_cond (e.g. guidance values tensor) matching the batch size when calling forward","If your checkpoint doesn't need it, ensure use_additional_t_cond is False in the config used to build the module","Check the pipeline glue that populates timestep conditioning kwargs"],"exampleFix":"# before\nemb = timestep_module(t, encoder_hidden_states.shape[0])\n# after\nemb = timestep_module(t, encoder_hidden_states.shape[0], addition_t_cond=guidance)","handlingStrategy":"validation","validationCode":"if module.use_additional_t_cond:\n    assert addition_t_cond is not None, \"checkpoint requires addition_t_cond\"","typeGuard":"def needs_addition_t_cond(module) -> bool:\n    return bool(getattr(module, \"use_additional_t_cond\", False))","tryCatchPattern":null,"preventionTips":["Inspect use_additional_t_cond right after model construction","Wire guidance/additional conditioning through the pipeline unconditionally when the flag is set"],"tags":["qwen-image","timestep-conditioning","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}