sgl-project/sglang · error · ValueError

`time_shift_type` must either be 'exponential' or 'linear'.

Error message

`time_shift_type` must either be 'exponential' or 'linear'.

What it means

The constructor accepts time_shift_type of only 'exponential' or 'linear' (validated against a set). This controls how mu-based time shifting maps sigmas during set_timesteps.

Source

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

        use_beta_sigmas: bool | None = False,
        time_shift_type: str = "exponential",
        stochastic_sampling: bool = False,
    ):
        if (
            sum(
                [
                    self.config.use_beta_sigmas,
                    self.config.use_exponential_sigmas,
                    self.config.use_karras_sigmas,
                ]
            )
            > 1
        ):
            raise ValueError(
                "Only one of `config.use_beta_sigmas`, `config.use_exponential_sigmas`, `config.use_karras_sigmas` can be used."
            )
        if time_shift_type not in {"exponential", "linear"}:
            raise ValueError(
                "`time_shift_type` must either be 'exponential' or 'linear'."
            )

        timesteps = np.linspace(
            1, num_train_timesteps, num_train_timesteps, dtype=np.float32
        )[::-1].copy()
        timesteps = torch.from_numpy(timesteps).to(dtype=torch.float32)

        sigmas = timesteps / num_train_timesteps
        if not use_dynamic_shifting:
            # when use_dynamic_shifting is True, we apply the timestep shifting on the fly based on the image resolution
            sigmas = shift * sigmas / (1 + (shift - 1) * sigmas)

        self.timesteps = sigmas * num_train_timesteps
        self.num_train_timesteps = num_train_timesteps

        self._step_index: int | None = None
        self._begin_index: int | None = None

View on GitHub (pinned to 0132848349)

Solutions

  1. Use exactly 'exponential' or 'linear' (lowercase)
  2. If a new shift type is required, extend both the constructor check and time_shift() dispatch
  3. Verify the value in the model's scheduler config JSON

Example fix

# before
FlowMatchEulerDiscreteScheduler(..., time_shift_type="exp")
# after
FlowMatchEulerDiscreteScheduler(..., time_shift_type="exponential")
Defensive patterns

Strategy: validation

Validate before calling

assert time_shift_type in {"exponential", "linear"}, time_shift_type

Type guard

from typing import Literal
ShiftType = Literal["exponential", "linear"]

Prevention

When it happens

Trigger: Passing time_shift_type='sqrt' or another string at construction, or a config file carrying an unsupported value from a different scheduler version.

Common situations: Downstream schedulers adding new shift types (e.g. 'flux-like' or custom) while this copy only supports two; typos like 'Exponential'.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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