{"record":{"id":"a04e3486a7d7e62e","repo":"sgl-project/sglang","slug":"mu-must-be-passed-when-use-dynamic-shifting-is","errorCode":null,"errorMessage":"`mu` must be passed when `use_dynamic_shifting` is set to be `True`","messagePattern":"`mu` must be passed when `use_dynamic_shifting` is set to be `True`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py","lineNumber":302,"sourceCode":"\n        Args:\n            num_inference_steps (`int`, *optional*):\n                The number of diffusion steps used when generating samples with a pre-trained model.\n            device (`str` or `torch.device`, *optional*):\n                The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.\n            sigmas (`List[float]`, *optional*):\n                Custom values for sigmas to be used for each diffusion step. If `None`, the sigmas are computed\n                automatically.\n            mu (`float`, *optional*):\n                Determines the amount of shifting applied to sigmas when performing resolution-dependent timestep\n                shifting.\n            timesteps (`List[float]`, *optional*):\n                Custom values for timesteps to be used for each diffusion step. If `None`, the timesteps are computed\n                automatically.\n        \"\"\"\n\n        if self.config.use_dynamic_shifting and mu is None:\n            raise ValueError(\n                \"`mu` must be passed when `use_dynamic_shifting` is set to be `True`\"\n            )\n\n        if (\n            sigmas is not None\n            and timesteps is not None\n            and len(sigmas) != len(timesteps)\n        ):\n            raise ValueError(\"`sigmas` and `timesteps` should have the same length\")\n\n        if num_inference_steps is not None:\n            if (sigmas is not None and len(sigmas) != num_inference_steps) or (\n                timesteps is not None and len(timesteps) != num_inference_steps\n            ):\n                raise ValueError(\n                    \"`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided\"\n                )\n        else:","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py#L284-L320","documentation":"When config.use_dynamic_shifting is True, set_timesteps applies resolution-dependent shifting that requires mu; passing mu=None raises. Same contract as diffusers FlowMatchEulerDiscreteScheduler.","triggerScenarios":"scheduler.set_timesteps(50) with use_dynamic_shifting=True and no mu; pipelines that compute mu but skip passing it for cached/short paths.","commonSituations":"Standalone scheduler use; upgrading configs that turned dynamic shifting on; latent resolution changes without recomputing mu.","solutions":["Pass mu to set_timesteps (compute from sequence length / shift as the pipeline does)","Disable use_dynamic_shifting if static shifting suffices","Ensure mu is recomputed whenever resolution or token count changes"],"exampleFix":"# before\nscheduler.set_timesteps(num_inference_steps=steps)\n# after\nscheduler.set_timesteps(num_inference_steps=steps, mu=calculate_shift(seqlen, shift))","handlingStrategy":"validation","validationCode":"if scheduler.config.use_dynamic_shifting:\n    assert mu is not None, \"mu required for dynamic shifting\"\nscheduler.set_timesteps(num_inference_steps=steps, mu=mu)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute mu from sequence length before every set_timesteps","Centralize scheduler setup in one helper that handles mu"],"tags":["scheduler","diffusion","missing-parameter","dynamic-shifting"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}