sgl-project/sglang · error · ValueError
SANA-WM refiner requires batch.latents from stage 1.
Error message
SANA-WM refiner requires batch.latents from stage 1.
What it means
The refiner's forward() requires batch.latents to be set by the preceding stage-1 generation stage. If batch.latents is None the refiner has nothing to refine, so it fails fast with this ValueError rather than producing garbage.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/refiner.py:711
height=noisy.shape[3],
width=noisy.shape[4],
patch_size=patch_size,
patch_size_t=patch_size_t,
)
log_sana_wm_tensor_stats(
f"refiner.step_{step_idx}.velocity_current",
velocity_5d.to(self.dtype),
)
log_sana_wm_tensor_stats(f"refiner.step_{step_idx}.current_latent", noisy)
refined = torch.cat([sink, noisy], dim=2)
log_sana_wm_tensor_stats("refiner.output_latent", refined)
return refined
@torch.inference_mode()
def forward(self, batch: Req, server_args: ServerArgs) -> Req:
if batch.latents is None:
raise ValueError("SANA-WM refiner requires batch.latents from stage 1.")
if batch.latents.ndim != 5:
raise ValueError(
"SANA-WM refiner expects 5D latents shaped (B, C, T, H, W), "
f"got {tuple(batch.latents.shape)}."
)
if sana_wm_skip_refiner_enabled(batch):
if batch.extra is None:
batch.extra = {}
batch.extra["sana_wm_refiner_applied"] = False
self.log_info(
"SANA-WM LTX-2 refiner skipped by SGLANG_SANA_WM_SKIP_REFINER."
)
return batch
batch_size = int(batch.latents.shape[0])
prompts = self._prompts_for_batch(batch, batch_size)
fps = float(getattr(batch, "fps", 16) or 16)View on GitHub (pinned to 0132848349)
Solutions
- Ensure the stage-1 SANA-WM denoising stage runs before the refiner and sets batch.latents
- Verify pipeline stage ordering in pipeline_config
- When unit-testing the refiner, construct batch.latents explicitly (5D tensor)
Example fix
# before batch.latents = None refiner.forward(batch, server_args) # after batch.latents = stage1_denoiser.forward(batch, server_args).latents refiner.forward(batch, server_args)
Defensive patterns
Strategy: validation
Validate before calling
if batch.latents is None:
raise RuntimeError("stage-1 did not produce latents; check pipeline order") Type guard
null
Try / catch
try:
out = refiner.forward(batch, server_args)
except ValueError as e:
if "batch.latents" in str(e):
batch = stage1.forward(batch, server_args)
out = refiner.forward(batch, server_args)
else:
raise Prevention
- Assert required Req fields between pipeline stages in tests
- Keep a canonical pipeline builder rather than assembling stages ad hoc
- Log batch.latents presence at stage boundaries when debugging
When it happens
Trigger: Running the SANA-WM refiner stage without a prior denoising stage in the pipeline, or the stage-1 output failing to write latents onto the Req (skip flag, serialization drop, or wrong pipeline wiring).
Common situations: Building a custom pipeline that omits the stage-1 denoiser; a conditioning/skip path that returns the batch before latents are assigned; debugging the refiner in isolation with a hand-built Req.
Related errors
- SANA-WM refiner requires a string prompt or one prompt per b
- Stage-1 latent has {z.shape[2]} frames but sink_size={sink_s
- SANA-WM refiner expects 5D latents shaped (B, C, T, H, W), g
- SANA-WM refiner decoding expects decoded video shaped (B, C,
- SANA-WM refiner decoding expected a sink frame plus refined
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/962b288bb2d98c17.
Report an issue: GitHub.