sgl-project/sglang · error · ValueError

sound generation was requested (sound_duration > 0) but the

Error message

sound generation was requested (sound_duration > 0) but the loaded Cosmos3 checkpoint has no sound modality (sound_gen is False).

What it means

The request asks for audio output (sound_duration > 0 in sampling params), but the loaded Cosmos3 transformer checkpoint has sound_gen=False, meaning it was trained without the sound modality and cannot produce sound latents. The stage refuses rather than silently dropping the audio.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py:600

            self.log_info(
                f"Prepared {mode} latents with conditioning at frames {cond_indexes}"
            )
        else:
            latents = noise

        batch.latents = latents
        batch.raw_latent_shape = shape

        batch.extra["video_shape"] = (num_latent_frames, height_latent, width_latent)
        batch.extra["vae_scale_factor_temporal"] = vae_scale_factor_temporal
        batch.extra["vae_scale_factor_spatial"] = vae_scale_factor_spatial

        self.log_info(f"Prepared latents with shape {shape}")

        sound_duration = float(getattr(batch, "sound_duration", 0.0) or 0.0)
        if sound_duration > 0.0:
            if not getattr(self.transformer, "sound_gen", False):
                raise ValueError(
                    "sound generation was requested (sound_duration > 0) but the "
                    "loaded Cosmos3 checkpoint has no sound modality (sound_gen is "
                    "False)."
                )
            sound_latent_fps = self.transformer.sound_latent_fps
            sound_latent_frames = max(1, round(sound_duration * sound_latent_fps))
            sound_shape = (1, self.transformer.sound_dim, sound_latent_frames)
            batch.audio_latents = torch.randn(
                sound_shape, generator=generator, device=device, dtype=dtype
            )
            self.log_info(f"Prepared sound latents with shape {sound_shape}")

        action_mode = getattr(batch.sampling_params, "action_mode", None)
        if action_mode is not None:
            if getattr(self.transformer, "action_dim", None) is None:
                raise ValueError(
                    "action_mode is set but the loaded Cosmos3 checkpoint has no "
                    "action modality (action_gen is False)."

View on GitHub (pinned to 0132848349)

Solutions

  1. Remove sound_duration (or set it to 0) to request video-only generation
  2. Load a Cosmos3 checkpoint variant that includes the sound modality (sound_gen=True)
  3. Verify transformer.sound_gen after model load and route audio requests accordingly

Example fix

# before
sp.sound_duration = 4.0  # video-only checkpoint

# after
sp.sound_duration = 0.0  # or load audio-capable checkpoint
Defensive patterns

Strategy: type-guard

Validate before calling

sound_ok = getattr(model.transformer, 'sound_gen', False)
if sp.sound_duration and not sound_ok:
    sp.sound_duration = 0.0  # or raise to caller

Type guard

def checkpoint_supports_sound(transformer) -> bool:
    return bool(getattr(transformer, 'sound_gen', False))

Prevention

When it happens

Trigger: Passing sound_duration > 0 while the loaded checkpoint's transformer.sound_gen attribute is False (a video-only Cosmos3 model).

Common situations: Loading a video-only Cosmos3 checkpoint and reusing request params from a video+audio variant; upgrading/downgrading between checkpoint variants.

Related errors


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