{"record":{"id":"446b14f104d2eb73","repo":"sgl-project/sglang","slug":"audio-num-frames-must-be-provided-for-rope-coordin","errorCode":null,"errorMessage":"audio_num_frames must be provided for RoPE coordinate generation.","messagePattern":"audio_num_frames must be provided for RoPE coordinate generation\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py","lineNumber":1995,"sourceCode":"        skip_video_self_attn_blocks: Optional[tuple[int, ...]] = None,\n        skip_audio_self_attn_blocks: Optional[tuple[int, ...]] = None,\n        disable_a2v_cross_attn: bool = False,\n        disable_v2a_cross_attn: bool = False,\n        audio_replicated_for_sp: bool = False,\n        video_memory_prefix_len: int = 0,\n        late_layer_ratio: float = 1.0,\n        late_audio_self_attention_mask: Optional[torch.Tensor] = None,\n        **kwargs,\n    ) -> tuple[torch.Tensor | None, torch.Tensor | None]:\n        batch_size = hidden_states.size(0)\n        audio_timestep = audio_timestep if audio_timestep is not None else timestep\n\n        if num_frames is None or height is None or width is None:\n            raise ValueError(\n                \"num_frames/height/width must be provided for RoPE coordinate generation.\"\n            )\n        if audio_num_frames is None:\n            raise ValueError(\n                \"audio_num_frames must be provided for RoPE coordinate generation.\"\n            )\n        perturbation_configs = kwargs.get(\"perturbation_configs\")\n        if perturbation_configs is not None and len(perturbation_configs) != batch_size:\n            raise ValueError(\n                \"perturbation_configs length must match batch size, got \"\n                f\"{len(perturbation_configs)=} {batch_size=}.\"\n            )\n\n        if video_coords is None:\n            # Wan-style SP-RoPE: when SP is enabled, each rank runs on its local\n            # time shard but RoPE positions must be offset to global time.\n            #\n            # We assume equal time sharding across SP ranks.\n            if model_parallel_is_initialized():\n                sp_world_size = get_sp_world_size()\n                sp_rank = get_sp_parallel_rank()\n            else:","sourceCodeStart":1977,"sourceCodeEnd":2013,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py#L1977-L2013","documentation":"LTX-2's audio branch also needs RoPE coordinates, which are derived from audio_num_frames. If it is None, forward raises immediately after the video-dimension checks.","triggerScenarios":"Calling forward with video dims supplied but audio_num_frames omitted or None — e.g. an audio-capable checkpoint invoked from a pipeline that only tracks video shape.","commonSituations":"Audio-conditioned video generation where the wrapper computes video dims but not audio frame count; refactors dropping the audio kwargs on non-audio code paths; passing audio_timestep but forgetting audio_num_frames.","solutions":["Pass audio_num_frames derived from the audio latent's temporal length (e.g. audio_latent.shape[-1] or the mel-frame count per the model's audio compression)","Propagate audio shape metadata through the scheduler/wrapper alongside video dims","Guard upstream: reject requests that enable audio conditioning without audio length info"],"exampleFix":"# before\nout = model(hidden_states, t, num_frames=f, height=h, width=w)\n\n# after\nout = model(hidden_states, t, num_frames=f, height=h, width=w,\n            audio_num_frames=audio_latent_frames)","handlingStrategy":"validation","validationCode":"if audio_num_frames is None:\n    audio_num_frames = audio_latent.shape[-1]  # per model audio compression\nassert audio_num_frames is not None","typeGuard":"def has_audio_dims(kw: dict) -> bool:\n    return kw.get('audio_num_frames') is not None","tryCatchPattern":"try: out = model(...)\\nexcept ValueError as e: fail_request(str(e))","preventionTips":["Track audio length alongside video dims in the pipeline","Reject audio-conditioned requests lacking audio metadata"],"tags":["rope","audio","missing-argument","ltx-2","forward"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}