sgl-project/sglang · error · ValueError
MiniMax H3 initial_audio_rows must be a rank-2 tensor
Error message
MiniMax H3 initial_audio_rows must be a rank-2 tensor
What it means
Twin of the video rows check: the stage requires state['initial_audio_rows'] to be a torch.Tensor with exactly 2 dimensions (expected shape [audio_rows_n, 32]). The error fires when the audio noise entry is missing, not a tensor, or rank != 2.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/latent_preparation.py:55
) -> list[Req]:
"""Preserve H3's independent per-modality RNG streams per request."""
return [self(batch, server_args) for batch in batches]
@staticmethod
def _publish_native_latent_state(batch: Req) -> None:
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minimax_h3.constants import (
MINIMAX_H3_DENOISE_STATE_EXTRA_KEY,
)
state = batch.extra.get(MINIMAX_H3_DENOISE_STATE_EXTRA_KEY)
if not isinstance(state, dict):
raise ValueError("MiniMax H3 denoise state must be a mapping")
video_rows = state.get("initial_video_rows")
audio_rows = state.get("initial_audio_rows")
if not isinstance(video_rows, torch.Tensor) or video_rows.ndim != 2:
raise ValueError("MiniMax H3 initial_video_rows must be a rank-2 tensor")
if not isinstance(audio_rows, torch.Tensor) or audio_rows.ndim != 2:
raise ValueError("MiniMax H3 initial_audio_rows must be a rank-2 tensor")
latent_t = int(state["latent_t"])
latent_h = int(state["latent_h"])
latent_w = int(state["latent_w"])
audio_t = int(state["audio_t"])
batch.latents = video_rows
batch.audio_latents = audio_rows
batch.raw_latent_shape = (1, 24, latent_t, latent_h, latent_w)
batch.raw_audio_latent_shape = (2, 32, audio_t)
def _prepare_denoise_state_from_plan(self, batch: Req, plan) -> None:
"""Direct initial-noise materialization (t2va recipe):
torch.Generator().manual_seed(seed); video rows drawn first,
then audio rows, CPU fp32. Every task consumes the final latent grid
frozen by the pre-queue shape resolver."""
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minimax_h3.constants import (
MINIMAX_H3_DENOISE_STATE_EXTRA_KEY,
)View on GitHub (pinned to 0132848349)
Solutions
- Provide initial_audio_rows as a rank-2 tensor of shape [audio_rows_n, 32]
- Fix rank by squeezing/reshaping or converting via torch.as_tensor before publishing
- Let the stage build the state from the plan (video_latent_t/audio_latent_t) rather than manual injection
Example fix
// before state["initial_audio_rows"] = np_audio # numpy, not tensor // after state["initial_audio_rows"] = torch.as_tensor(np_audio, dtype=torch.float32) # [N, 32]
Defensive patterns
Strategy: type-guard
Validate before calling
rows = state.get("initial_audio_rows")
assert isinstance(rows, torch.Tensor) and rows.ndim == 2 and rows.shape[1] == 32, rows.shape if isinstance(rows, torch.Tensor) else type(rows) Type guard
def is_valid_audio_rows(x) -> bool:
return isinstance(x, torch.Tensor) and x.ndim == 2 and x.shape[-1] == 32 Prevention
- Convert numpy audio noise via torch.as_tensor before publishing
- Keep audio noise unbatched: [rows, 32], never [1, rows, 32]
When it happens
Trigger: _publish_native_latent_state runs with initial_audio_rows set to None, a non-tensor, or a wrongly-ranked tensor (e.g. [1, N, 32]) in batch.extra[MINIMAX_H3_DENOISE_STATE_EXTRA_KEY].
Common situations: Injecting or deserializing denoise state where audio noise was transposed, stacked, or converted; omitting the audio branch for audio-capable requests.
Related errors
- MiniMax H3 initial_video_rows must be a rank-2 tensor
- MiniMax-H3 adaln_t_table must have shape [N, D] with N >= 2,
- {name} must be rank {rank}, got shape={list(tensor.shape)}
- video latent spatial/time dims must be divisible by patch_si
- video token dim {int(rows.shape[-1])} != patch volume * chan
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/8b9e268572b5d3b2.
Report an issue: GitHub.