fix(lora): preserve alpha warmup across EMA lifecycle - #177
Merged
Conversation
SidKC
marked this pull request as ready for review
July 27, 2026 04:17
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
这个改动接着 #170 往下做。#170 处理了 fallback RS-LoRA 的 scaling 和保存加载;alpha warmup 还涉及 EMA、验证和断点恢复,所以当时单独拆了出来。
目前 fallback LoRA wrapper 的
lora_A是 barenn.Parameter,现有 warmup 发现逻辑不会识别它。配置lora_alpha_warmup后,fallback adapter 实际上仍会直接使用完整 scaling。同时,fallback wrapper 的
scaling是普通 Python 属性,不在state_dict中。online model 更新 scaling 后,EMA model 不会自动同步,验证、保存 checkpoint 和恢复训练时可能使用不同的 scaling。修改内容
use_rslora、rank 和 alpha 是否一致;这里只同步 fallback wrapper 的
scaling,EMA 原有的参数和 buffer 更新方式保持不变。测试
新增 9 个测试,覆盖:
ManualLoRAConv和FewShotLoRAConv;同一组测试在未修改的
main上为8 failed, 1 passed,应用修复后为9 passed。相关 LoRA、adapter、EMA、recovery 和 planner 测试为
159 passed, 1 deselected。Ruff、py_compile和git diff --check也已通过。说明
这次没有改 fallback adapter 的 merge 逻辑,也没有调整 EMA 对参数和 buffer 的正常更新方式。