sgl-project/sglang · error · ValueError

noise_aug must be in [0, 1], got {noise_aug}

Error message

noise_aug must be in [0, 1], got {noise_aug}

What it means

minimax_h3_imgvid_cond_noise_aug_rows validates that the imgvid condition noise augmentation coefficient is a float within [0,1]. Values below 0.0 or above 1.0 (or NaN after float() conversion, which fails the chained comparison) raise this ValueError before any tensor work happens.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/condition_noise.py:44

    *,
    condition_shapes: Sequence[Sequence[int]],
    target_latent_t: int,
    imgvid_cond_num_frames: int,
    seed: int,
    noise_aug: float,
) -> torch.Tensor:
    """Apply the imgvid-condition RF noise recipe to packed clean rows.

    ``condition_shapes`` contains ``(latent_t, latent_h, latent_w)`` in packed
    visual-condition order. A new CPU generator with the same row seed is
    created for every condition. Under the dependent-noise policy, each draw
    uses the target temporal length plus the template's imgvid-condition frame
    count, then slices the prefix matching the current condition.
    """

    noise_aug = float(noise_aug)
    if not 0.0 <= noise_aug <= 1.0:
        raise ValueError(f"noise_aug must be in [0, 1], got {noise_aug}")
    if noise_aug == 1.0:
        return clean_rows
    if clean_rows.ndim != 2 or int(clean_rows.shape[1]) != 96:
        raise ValueError(
            "clean imgvid condition rows must have shape [n, 96], got "
            f"{list(clean_rows.shape)}"
        )

    target_latent_t = int(target_latent_t)
    imgvid_cond_num_frames = int(imgvid_cond_num_frames)
    if target_latent_t <= 0:
        raise ValueError(f"target_latent_t must be positive, got {target_latent_t}")
    if imgvid_cond_num_frames <= 0:
        raise ValueError(
            "imgvid_cond_num_frames must be positive when condition rows exist, "
            f"got {imgvid_cond_num_frames}"
        )

View on GitHub (pinned to 0132848349)

Solutions

  1. Clamp noise_aug to [0,1] at the config/request boundary: noise_aug = min(max(float(noise_aug), 0.0), 1.0)
  2. Check for NaN and reject or default the request parameter before invoking the stage
  3. Validate the sampler config schema with bounds 0<=noise_aug<=1 at load time

Example fix

// before
rows = minimax_h3_imgvid_cond_noise_aug_rows(clean_rows, noise_aug=cfg.sigma, ...)
// after
noise_aug = min(max(float(cfg.noise_aug), 0.0), 1.0)
rows = minimax_h3_imgvid_cond_noise_aug_rows(clean_rows, noise_aug=noise_aug, ...)
Defensive patterns

Strategy: validation

Validate before calling

noise_aug = float(noise_aug)
assert math.isfinite(noise_aug) and 0.0 <= noise_aug <= 1.0, 'noise_aug out of range'

Type guard

def valid_noise_aug(x) -> bool:
    try:
        v = float(x)
    except (TypeError, ValueError):
        return False
    return math.isfinite(v) and 0.0 <= v <= 1.0

Prevention

When it happens

Trigger: Passing noise_aug outside [0,1] (e.g. 1.5, -0.1) or a non-finite value like float('nan') to minimax_h3_imgvid_cond_noise_aug_rows, typically sourced from sampler config or request parameters.

Common situations: Copying a sigma-style noise schedule value (unbounded) into noise_aug, exposing noise_aug as a user-facing sampling parameter without clamping, or a config default changed between versions.

Related errors


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