{"record":{"id":"2559a84332313635","repo":"sgl-project/sglang","slug":"latent-window-size-must-be-positive-got-latent-w","errorCode":null,"errorMessage":"latent_window_size must be positive, got {latent_window_size}","messagePattern":"latent_window_size must be positive, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/memory.py","lineNumber":43,"sourceCode":"    LTX2AVDecodingStage,\n)\nfrom sglang.multimodal_gen.runtime.server_args import ServerArgs\nfrom sglang.multimodal_gen.runtime.utils.logging_utils import init_logger\n\nlogger = init_logger(__name__)\n\n\n# --- Audio peak-window helpers ---\n\n\ndef latent_window_size_to_pixel_window_size(\n    latent_window_size: int,\n    *,\n    downsample_factor: int,\n    is_causal: bool = True,\n) -> int:\n    if latent_window_size <= 0:\n        raise ValueError(\n            f\"latent_window_size must be positive, got {latent_window_size}\"\n        )\n    if downsample_factor <= 0:\n        raise ValueError(f\"downsample_factor must be positive, got {downsample_factor}\")\n\n    pixel_window_size = int(latent_window_size) * int(downsample_factor)\n    if is_causal:\n        pixel_window_size = max(pixel_window_size - (int(downsample_factor) - 1), 1)\n    return pixel_window_size\n\n\ndef select_max_response_audio_window_with_bounds(\n    segment: Tensor,\n    window_size: int,\n) -> tuple[Tensor, Tensor, Tensor]:\n    if segment.dim() != 4:\n        raise ValueError(\n            f\"Expected segment shape [B, C, T, F], got {tuple(segment.shape)}\"","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/memory.py#L25-L61","documentation":"latent_window_size_to_pixel_window_size converts a latent-space window to pixel space by multiplying by downsample_factor; it validates both are positive integers first. A non-positive latent window would produce a zero/negative pixel window, which is meaningless for memory slotting, so it fails fast.","triggerScenarios":"Calling the helper with latent_window_size <= 0 (0 or negative), commonly from save_memory_slot with a computed window of 0 — e.g. an empty clip or miscomputed frame chunk.","commonSituations":"Computing the window as ceil(frames/threshold) which rounds to 0 for short clips; config files with latent_window_size: 0; off-by-one or inversion when deriving the window from pixel sizes.","solutions":["Fix the caller to compute a positive latent window (clamp to at least 1)","Correct the config value to a positive integer","Sanity-assert window sizes before saving memory slots"],"exampleFix":"# before\nlws = max(0, num_latent_frames - overlap)\nslot = save_memory_slot(latent_window_size_to_pixel_window_size(lws, downsample_factor=8))\n# after\nlws = max(1, num_latent_frames - overlap)\nslot = save_memory_slot(latent_window_size_to_pixel_window_size(lws, downsample_factor=8))","handlingStrategy":"validation","validationCode":"if latent_window_size <= 0:\n    latent_window_size = 1  # or reject with a clear message before calling","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed windows with max(1, value)","Validate memory-slot config values at load time"],"tags":["joyecho","memory","window-size","validation"],"backgroundTag":"non-positive-window-size","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}