[Bugfix][LoRA] Guard None group members in expand_packed_lora (partial LoRA on Qwen3.5/3.6 GatedDeltaNet) (#47640)

Signed-off-by: Eilam C <eilamc14@gmail.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
This commit is contained in:
Eilam
2026-08-19 13:24:26 +00:00
committed by GitHub
co-authored by Jee Jee Li
parent 92bdee05cb
commit c2e7242ab7
+25 -6
View File
@@ -265,17 +265,36 @@ class MergedColumnParallelLinearWithLoRA(ColumnParallelLinearWithLoRA):
def expand_packed_lora(
self,
lora_a: list[torch.Tensor],
lora_b: list[torch.Tensor],
) -> tuple[list[torch.Tensor], list[torch.Tensor]]:
lora_a: list[torch.Tensor | None],
lora_b: list[torch.Tensor | None],
) -> tuple[list[torch.Tensor | None], list[torch.Tensor | None]]:
"""
Expand packed adapter groups when they don't match n_slices.
E.g. in_proj_qkv (covers Q+K+V) + in_proj_z
E.g. in_proj_qkv (covers Q+K+V) + in_proj_z.
A None group member means that member was not adapted; the slice(s)
it covers are emitted as None placeholders so subsequent groups stay
aligned and those slices are left at base weights. This matches the
None-tolerance already present in slice_lora_b() and the set_lora()
stacking loop.
"""
expanded_a: list[torch.Tensor] = []
expanded_b: list[torch.Tensor] = []
expanded_a: list[torch.Tensor | None] = []
expanded_b: list[torch.Tensor | None] = []
start_idx = 0
for a_i, b_i in zip(lora_a, lora_b):
if b_i is None:
# Unadapted group member: its row count is unknown (the tensor
# is missing), so infer its coverage as the remaining slices.
# This is exact for the only layout that reaches this path,
# the fused GDN in_proj_qkvz group, whose sole multi-slice
# member (in_proj_qkv, Q+K+V) leads and whose only optional
# member (in_proj_z) trails.
covered = self.n_slices - start_idx
for _ in range(covered):
expanded_a.append(None)
expanded_b.append(None)
start_idx += covered
continue
# Determine which output slices this b_i covers.
b_rows, cu_rows, covered = b_i.shape[0], 0, 0
for i in range(start_idx, self.n_slices):