{"record":{"id":"3fccec2347cec7af","repo":"sgl-project/sglang","slug":"height-and-width-must-be-provided","errorCode":null,"errorMessage":"Height and width must be provided","messagePattern":"Height and width must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/latent_preparation.py","lineNumber":135,"sourceCode":"        \"\"\"\n\n        # Adjust video length based on VAE version if needed\n        latent_num_frames = self.get_forward_latent_num_frames(batch, server_args)\n\n        batch_size = batch.batch_size\n\n        # Get required parameters\n        device = get_local_torch_device()\n        generator = batch.generator\n        latents = batch.latents\n        height = batch.height\n        width = batch.width\n\n        # TODO(will): remove this once we add input/output validation for stages\n        if self.requires_batch_height_width(batch, server_args) and (\n            height is None or width is None\n        ):\n            raise ValueError(\"Height and width must be provided\")\n\n        # Validate generator if it's a list\n        if isinstance(generator, list) and len(generator) != batch_size:\n            raise ValueError(\n                f\"You have passed a list of generators of length {len(generator)}, but requested an effective batch\"\n                f\" size of {batch_size}. Make sure the batch size matches the length of the generators.\"\n            )\n\n        # Generate or use provided latents\n        if latents is None:\n            spec = self.get_latent_preparation_spec(\n                batch, server_args, batch_size, latent_num_frames, device\n            )\n            latents = randn_tensor(\n                spec.shape,\n                generator=generator,\n                device=spec.device,\n                dtype=spec.dtype,","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/latent_preparation.py#L117-L153","documentation":"LatentPreparationStage needs the spatial dimensions (height and width) of the output latent for this model/pipeline configuration, but the batch carries None for one or both. Without them the stage cannot shape the initial noise latent, so it raises before generating latents.","triggerScenarios":"Calling the pipeline/stage without height/width when requires_batch_height_width(batch, server_args) returns True — typical for models whose latent shape is not inferred from inputs (no explicit resolution and no default), e.g. an LLM-only or DiT model without a config-provided resolution.","commonSituations":"Porting a diffusers script that always passed height/width explicitly; a new model integration that forgot to set per-request defaults in server_args or model config; multipart pipelines where a prior stage was expected to populate batch.width/height but was skipped or reordered.","solutions":["Pass explicit height and width in the request (e.g. height=1024, width=1024)","If the model has a canonical resolution, set it as the default in server_args/model config so the batch always carries values","Check that any upstream stage responsible for resolving resolution ran before LatentPreparationStage","If you maintain the stage, wire the height/width defaults into requires_batch_height_width's callers instead of relying on the request"],"exampleFix":"# before\nout = pipe(prompt=\"a cat\")\n# after\nout = pipe(prompt=\"a cat\", height=1024, width=1024)","handlingStrategy":"validation","validationCode":"if batch.height is None or batch.width is None:\n    raise ValueError(\"height/width required before running the pipeline\")","typeGuard":"def has_resolution(batch) -> bool:\n    return isinstance(batch.height, int) and isinstance(batch.width, int) and batch.height > 0 and batch.width > 0","tryCatchPattern":null,"preventionTips":["Always pass explicit height/width for resolution-requiring models","Set model-level default resolution in server args"],"tags":["latent-preparation","height-width","missing-dimensions","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}