{"record":{"id":"365fedebd9ac370b","repo":"sgl-project/sglang","slug":"length-mismatch-lora-nicknames-has-len-lora-nick-365fed","errorCode":null,"errorMessage":"Length mismatch: lora_nicknames has {len(lora_nicknames)} items, but strengths has {len(strengths)} items","messagePattern":"Length mismatch: lora_nicknames has (.+?) items, but strengths has (.+?) items","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/lora/pipeline.py","lineNumber":649,"sourceCode":"\n        Args:\n            lora_layers: The dictionary of LoRA layers to apply weights to.\n            lora_nicknames: The list of nicknames of the LoRA adapters.\n            lora_paths: The list of paths to the LoRA adapters. Must match length of lora_nicknames.\n            rank: The distributed rank (for logging).\n            strengths: The list of LoRA strengths for merge. Must match length of lora_nicknames.\n            clear_existing: If True, clear existing LoRA weights before adding new ones.\n\n        Returns:\n            The number of layers that had LoRA weights applied.\n        \"\"\"\n        if len(lora_paths) != len(lora_nicknames):\n            raise ValueError(\n                f\"Length mismatch: lora_nicknames has {len(lora_nicknames)} items, \"\n                f\"but lora_paths has {len(lora_paths)} items\"\n            )\n        if len(strengths) != len(lora_nicknames):\n            raise ValueError(\n                f\"Length mismatch: lora_nicknames has {len(lora_nicknames)} items, \"\n                f\"but strengths has {len(strengths)} items\"\n            )\n\n        adapted_count = 0\n        missing_layers_by_adapter = [[] for _ in lora_nicknames]\n        applied_count_by_adapter = [0 for _ in lora_nicknames]\n        for name, layer in lora_layers.items():\n            # Apply all LoRA adapters in order\n            for idx, (nickname, path, lora_strength) in enumerate(\n                zip(lora_nicknames, lora_paths, strengths)\n            ):\n                lora_A_name = name + \".lora_A\"\n                lora_B_name = name + \".lora_B\"\n                if (\n                    lora_A_name in self.lora_adapters[nickname]\n                    and lora_B_name in self.lora_adapters[nickname]\n                ):","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/lora/pipeline.py#L631-L667","documentation":"Same per-adapter list validation in _apply_lora_to_layers, but for strengths: the strengths list must match lora_nicknames in length so each adapter has a scaling factor.","triggerScenarios":"Calling set_lora(lora_nicknames=['a','b'], strengths=[1.0]) — fewer (or more) strength values than adapters.","commonSituations":"Passing a single scalar strength when multiple adapters are composed; strengths list built for an older adapter set after adding a new adapter.","solutions":["Provide one strength per nickname, e.g. strengths=[1.0]*len(lora_nicknames)","Omit strengths entirely if defaults are acceptable"],"exampleFix":"# before\npipeline.set_lora(lora_paths=paths, lora_nicknames=['a','b'], strengths=[0.8])\n# after\npipeline.set_lora(lora_paths=paths, lora_nicknames=['a','b'], strengths=[0.8, 0.8])","handlingStrategy":"validation","validationCode":"if strengths is not None: assert len(strengths) == len(lora_nicknames)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default strengths to [1.0]*len(lora_nicknames)","Zip all adapter lists together when constructing them"],"tags":["lora","argument-validation","length-mismatch"],"backgroundTag":"argument-length-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}