sgl-project/sglang · error · ValueError

shift must be positive

Error message

shift must be positive

What it means

Inside _dual_sigma_shift, the per-column builder _build_column validates the modality-specific shift parameter (visual_shift / audio_shift, defaulted from scheduler.shift or kwargs). A value <= 0 (including 0.0 and negatives) raises ValueError because the flow-match shift multiplies/expands the sigma schedule and only positive values are mathematically valid.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py:383

            def _dual_sigma_shift(pairs: torch.Tensor, *, source: str):
                if not isinstance(pairs, torch.Tensor):
                    raise TypeError("pairs must be a torch.Tensor")
                if pairs.ndim != 2 or pairs.shape[1] != 2:
                    raise ValueError("pairs must be a torch.Tensor of shape [N, 2]")
                if pairs.shape[0] == 0:
                    raise ValueError("pairs length must be greater than 0")
                if source not in ("timesteps", "sigmas"):
                    raise ValueError("source must be 'timesteps' or 'sigmas'")

                num_steps = pairs.shape[0]
                device = pairs.device
                dtype = pairs.dtype

                def _build_column(
                    shift_value: float, denoising_strength: float, mu_override
                ):
                    if shift_value <= 0:
                        raise ValueError("shift must be positive")
                    if denoising_strength <= 0:
                        raise ValueError("denoising_strength must be positive")

                    sigma_start = (
                        self.sigma_min
                        + (self.sigma_max - self.sigma_min) * denoising_strength
                    )
                    if self.extra_one_step:
                        base = torch.linspace(
                            sigma_start,
                            self.sigma_min,
                            num_steps + 1,
                            device=device,
                            dtype=dtype,
                        )[:-1]
                    else:
                        base = torch.linspace(
                            sigma_start,

View on GitHub (pinned to 0132848349)

Solutions

  1. Set a positive shift, e.g. set_pair_postprocess_by_name('dual_sigma_shift', visual_shift=3.0, audio_shift=3.0)
  2. If the base scheduler shift is 0, override both per-modality kwargs since they inherit it by default
  3. Validate config at load time: shift values must be > 0 for dual_sigma_shift
  4. If you truly want no shift, use a different postprocess mode (None) instead of shift=0

Example fix

# before
scheduler.set_pair_postprocess_by_name("dual_sigma_shift", visual_shift=0, audio_shift=0)

# after
scheduler.set_pair_postprocess_by_name("dual_sigma_shift", visual_shift=3.0, audio_shift=3.0)
Defensive patterns

Strategy: validation

Validate before calling

visual_shift = float(cfg.get("visual_shift", 3.0))
audio_shift = float(cfg.get("audio_shift", 3.0))
if visual_shift <= 0 or audio_shift <= 0:
    raise ValueError("shift values for dual_sigma_shift must be > 0")
scheduler.set_pair_postprocess_by_name(
    "dual_sigma_shift",
    visual_shift=visual_shift,
    audio_shift=audio_shift,
)

Prevention

When it happens

Trigger: set_pair_postprocess_by_name('dual_sigma_shift', visual_shift=0, ...) or audio_shift=-1, or a scheduler constructed with shift=0.0 (default in some configs) and no per-modality override — the check fires when the postprocess runs on the first timestep refresh.

Common situations: Copy-pasting a unimodal config where shift=0 meant 'no shift' — in the dual path you must disable shifting differently; reading shift from a model config field that is absent and defaults to 0; typo'd negative value in YAML.

Related errors


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