sgl-project/sglang · error · ValueError

`mu` must be passed when `use_dynamic_shifting` is set to be

Error message

`mu` must be passed when `use_dynamic_shifting` is set to be `True`

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py:302

        Args:
            num_inference_steps (`int`, *optional*):
                The number of diffusion steps used when generating samples with a pre-trained model.
            device (`str` or `torch.device`, *optional*):
                The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
            sigmas (`List[float]`, *optional*):
                Custom values for sigmas to be used for each diffusion step. If `None`, the sigmas are computed
                automatically.
            mu (`float`, *optional*):
                Determines the amount of shifting applied to sigmas when performing resolution-dependent timestep
                shifting.
            timesteps (`List[float]`, *optional*):
                Custom values for timesteps to be used for each diffusion step. If `None`, the timesteps are computed
                automatically.
        """

        if self.config.use_dynamic_shifting and mu is None:
            raise ValueError(
                "`mu` must be passed when `use_dynamic_shifting` is set to be `True`"
            )

        if (
            sigmas is not None
            and timesteps is not None
            and len(sigmas) != len(timesteps)
        ):
            raise ValueError("`sigmas` and `timesteps` should have the same length")

        if num_inference_steps is not None:
            if (sigmas is not None and len(sigmas) != num_inference_steps) or (
                timesteps is not None and len(timesteps) != num_inference_steps
            ):
                raise ValueError(
                    "`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided"
                )
        else:

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass mu to set_timesteps (compute from sequence length / shift as the pipeline does)
  2. Disable use_dynamic_shifting if static shifting suffices
  3. Ensure mu is recomputed whenever resolution or token count changes

Example fix

# before
scheduler.set_timesteps(num_inference_steps=steps)
# after
scheduler.set_timesteps(num_inference_steps=steps, mu=calculate_shift(seqlen, shift))
Defensive patterns

Strategy: validation

Validate before calling

if scheduler.config.use_dynamic_shifting:
    assert mu is not None, "mu required for dynamic shifting"
scheduler.set_timesteps(num_inference_steps=steps, mu=mu)

Prevention

When it happens

Trigger: scheduler.set_timesteps(50) with use_dynamic_shifting=True and no mu; pipelines that compute mu but skip passing it for cached/short paths.

Common situations: Standalone scheduler use; upgrading configs that turned dynamic shifting on; latent resolution changes without recomputing mu.

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/a04e3486a7d7e62e. Report an issue: GitHub.