sgl-project/sglang · error · ValueError

Expected scheduler.sigmas to be a tensor for LTX-2.

Error message

Expected scheduler.sigmas to be a tensor for LTX-2.

What it means

The LTX-2 step reads the current and next sigma from ctx.scheduler.sigmas to compute the Euler delta. If sigmas is missing or not a torch.Tensor (e.g. a list, tuple, or numpy array), indexing and device/dtype conversion would fail, so it validates first.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/denoising.py:1724

        return self._build_attn_metadata(step_index, batch, server_args)

    def _run_denoising_step(
        self,
        ctx: LTX2DenoisingContext,
        step: DenoisingStepState,
        batch: Req,
        server_args: ServerArgs,
    ) -> None:
        """Run one joint video/audio denoising step with LTX-2-specific guidance."""
        if ctx.audio_latents is None:
            raise ValueError("LTX-2 requires audio latents for denoising.")
        if ctx.audio_scheduler is None:
            raise ValueError("LTX-2 audio scheduler was not prepared.")

        # 1. Read the scheduler sigma pair and derive the Euler delta.
        sigmas = getattr(ctx.scheduler, "sigmas", None)
        if sigmas is None or not isinstance(sigmas, torch.Tensor):
            raise ValueError("Expected scheduler.sigmas to be a tensor for LTX-2.")
        sigma = sigmas[step.step_index].to(
            device=ctx.latents.device, dtype=torch.float32
        )
        sigma_next = sigmas[step.step_index + 1].to(
            device=ctx.latents.device, dtype=torch.float32
        )
        dt = sigma_next - sigma
        sigma_val = float(sigma.item())
        sigma_next_val = float(sigma_next.item())

        stage1_guider_params = self._get_ltx2_stage1_guider_params(
            batch, server_args, ctx.stage
        )
        model_inputs = self._prepare_ltx2_model_inputs(
            ctx, step, batch, server_args, sigma
        )
        batch_size = int(model_inputs.latent_model_input.shape[0])
        base_model_kwargs = self._build_ltx2_base_model_kwargs(ctx, batch, model_inputs)

View on GitHub (pinned to 0132848349)

Solutions

  1. Use one of the supported schedulers whose set_timesteps leaves sigmas as a torch tensor on the right device
  2. After scheduler setup, convert: scheduler.sigmas = torch.as_tensor(scheduler.sigmas, device=...)
  3. Check for a scheduler.reset()/re-init between prepare and the loop that nulls sigmas

Example fix

// before
sched.sigmas = list_of_sigmas  # raises
// after
import torch
sched.sigmas = torch.tensor(list_of_sigmas, device=latents.device, dtype=torch.float32)
Defensive patterns

Strategy: fallback

Validate before calling

sigmas = getattr(ctx.scheduler, "sigmas", None)
if not isinstance(sigmas, torch.Tensor):
    sigmas = torch.as_tensor(sigmas, device=ctx.latents.device, dtype=torch.float32)
    ctx.scheduler.sigmas = sigmas

Type guard

def has_tensor_sigmas(sched) -> bool:
    return isinstance(getattr(sched, "sigmas", None), torch.Tensor)

Prevention

When it happens

Trigger: ctx.scheduler.sigmas is None or a non-tensor type when the step indexes sigmas[step.step_index] and sigmas[step.step_index + 1].

Common situations: A custom or scheduler-mismatch (scheduler whose sigmas live elsewhere or are returned as a list); a scheduler reset that dropped sigmas; scheduler configured for a different framework version.

Related errors


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