{"record":{"id":"7db9ce0abbde999d","repo":"sgl-project/sglang","slug":"audio-out-channels-must-be-divisible-by-tp-size-fo","errorCode":null,"errorMessage":"audio_out_channels must be divisible by tp_size for TP-sharded output projection, got {arch.audio_out_channels=} {tp_size=}.","messagePattern":"audio_out_channels must be divisible by tp_size for TP-sharded output projection, got (.+?) (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py","lineNumber":1637,"sourceCode":"                f\"{self.audio_num_attention_heads=} {tp_size=}.\"\n            )\n        if self.hidden_size % tp_size != 0:\n            raise ValueError(\n                \"hidden_size must be divisible by tp_size for TP-sharded projections, got \"\n                f\"{self.hidden_size=} {tp_size=}.\"\n            )\n        if self.audio_hidden_size % tp_size != 0:\n            raise ValueError(\n                \"audio_hidden_size must be divisible by tp_size for TP-sharded projections, got \"\n                f\"{self.audio_hidden_size=} {tp_size=}.\"\n            )\n        if int(arch.out_channels) % tp_size != 0:\n            raise ValueError(\n                \"out_channels must be divisible by tp_size for TP-sharded output projection, got \"\n                f\"{arch.out_channels=} {tp_size=}.\"\n            )\n        if int(arch.audio_out_channels) % tp_size != 0:\n            raise ValueError(\n                \"audio_out_channels must be divisible by tp_size for TP-sharded output projection, got \"\n                f\"{arch.audio_out_channels=} {tp_size=}.\"\n            )\n\n    def __init__(\n        self,\n        config: LTX2Config,\n        hf_config: dict[str, Any],\n        quant_config: QuantizationConfig | None = None,\n    ) -> None:\n        super().__init__(config=config, hf_config=hf_config)\n\n        arch = self.config\n        # Checkpoint naming is arch-config metadata, not a runtime capability.\n        self.param_names_mapping = arch.param_names_mapping\n        self.reverse_param_names_mapping = arch.reverse_param_names_mapping\n        self.lora_param_names_mapping = arch.lora_param_names_mapping\n        self.hidden_size = arch.hidden_size","sourceCodeStart":1619,"sourceCodeEnd":1655,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py#L1619-L1655","documentation":"LTX-2's audio output projection is also TP-sharded, so arch.audio_out_channels must be divisible by tp_size at model construction. The check mirrors the video out_channels check and fails fast with both values in the message.","triggerScenarios":"Building the LTX-2 model with a tp_size that divides out_channels but not audio_out_channels (e.g. video channels divisible by 8 but audio channels divisible only by 2), common with mixed audio/video architectures.","commonSituations":"Audio-enabled LTX-2 checkpoints where audio_out_channels is smaller or differently factored than video out_channels; scaling TP to many GPUs; misreading the config and passing a clap/audio dim instead of audio_out_channels.","solutions":["Choose tp_size that divides both out_channels and audio_out_channels (compute gcd of the two and use a divisor of it)","Check the checkpoint config's audio_out_channels value and factorize it before selecting TP degree","Fall back to tp_size=1 or a lower TP degree if no common divisor >= desired parallelism exists"],"exampleFix":"# before\nimport math\ntp_size = 8  # audio_out_channels=12 -> fails\n\n# after\ntp_size = math.gcd(arch.out_channels, int(arch.audio_out_channels))\n# or explicitly: tp_size = 2","handlingStrategy":"validation","validationCode":"import math\ncommon = math.gcd(int(arch.out_channels), int(arch.audio_out_channels))\nassert tp_size <= common and common % tp_size == 0, 'tp must divide both channel counts'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check gcd of all sharded dimensions when audio and video branches coexist","Log arch values at startup for debugging TP choices"],"tags":["tp-sharding","audio","divisibility","ltx-2","config-validation"],"backgroundTag":"tensor-parallel-size-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}