Skip to content

Commit e8814a8

Browse files
committed
fix matched/wrapped counter bug
1 parent 6599d13 commit e8814a8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

training/finetune.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ def inject_lora(root: nn.Module, cfg: LoRAConfig) -> None:
195195
196196
inject_lora(model.embedding, cfg)
197197
"""
198+
matched_count = 0
198199
wrapped_count = 0
199200

200201
for name, module in list(root.named_modules()):
201202
if not _name_matches(name, cfg.target_patterns):
202203
continue
203204

205+
matched_count += 1
204206
parent = _get_parent(root, name)
205207
child_name = name.split(".")[-1]
206208
wrapped = None
@@ -240,7 +242,7 @@ def inject_lora(root: nn.Module, cfg: LoRAConfig) -> None:
240242

241243
logger.info("[LoRA] Wrapped %d modules (rank=%d)", wrapped_count, cfg.rank)
242244

243-
if wrapped_count == 0:
245+
if matched_count == 0:
244246
raise RuntimeError(
245247
"No modules matched LoRA target patterns. "
246248
"Verify module names with: list(model.named_modules())."

0 commit comments

Comments
 (0)