[LoRA] Gate all_gather on fully_sharded_loras inside _mcp_apply; rewrite regression test (#45715)

Signed-off-by: lcheng <lcheng321@gatech.edu>
Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai>
Co-authored-by: Jee Jee Li <jeejeelee@inferact.ai>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
lcheng
2026-06-23 07:08:33 -07:00
committed by GitHub
co-authored by Jee Jee Li Jee Jee Li
parent f59db63732
commit e51e700470
+5 -5
View File
@@ -22,10 +22,10 @@ from .utils import _fully_sharded_can_replace, _not_fully_sharded_can_replace
def _mcp_apply(x, bias, layer: "ColumnParallelLinearWithLoRA"):
"""
For `ColumnParallelLinearWithLoRA` or classes that inherit from
`ColumnParallelLinearWithLoRA`, they share the same `apply` logic.
"""
"""Fully-sharded (S-LoRA) apply path for column-parallel LoRA layers."""
assert layer.lora_config.fully_sharded_loras, (
"_mcp_apply is only used for fully sharded LoRA"
)
assert (
layer.n_slices
== len(layer.lora_a_stacked)
@@ -341,7 +341,7 @@ class MergedColumnParallelLinearWithLoRA(ColumnParallelLinearWithLoRA):
and base_forward is not merged_forward
):
return self._apply_base_forward(x)
return _mcp_apply(x, bias, self)
return super().apply(x, bias)
@classmethod
def can_replace_layer(