Repository navigation
Pass layers_to_transform, use_rslora and modules_to_save to LoraConfig on the SentenceTransformer fast encoder path - #14150
Conversation
…g on the SentenceTransformer fast encoder path The fast encoder branch of FastSentenceTransformer.get_peft_model built its LoraConfig without these arguments, so they were accepted and silently ignored.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ormer fast encoder path [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
FastSentenceTransformer.get_peft_modelon the fast encoder path (BERT/MPNet-style models) built itsLoraConfigwithoutlayers_to_transform,layers_pattern,use_rsloraormodules_to_save, so they were accepted and silently ignored.use_rslora=Truetrained with alpha/r scaling instead of alpha/sqrt(r), andlayers_to_transformstill adapted every layer.Fix: pass the four arguments through, as the other branch already does.
Test: new
tests/test_st_fast_encoder_lora_config.pyon a tiny BERT, CPU. On main it fails (use_rsloraFalse; 13 adapters, scaling 2.0). With the fix it passes (6 adapters on layer 1 only, scaling 4.0). The other sentence-transformer tests I ran still pass. Not run on GPU.Follow-up fix: with
modules_to_savenow honoured, a model loaded in float16 (T4, V100) kept its trainable copies in float16 while the LoRA weights were float32, so the first optimizer step raisedValueError: Attempting to unscale FP16 gradients.The fast encoder path now calls_unfreeze_modules_to_save, the same helper the FastModel path uses, which upcasts float16 copies to float32 (#1200). Addedtest_float16_modules_to_save_copy_trains_in_float32, which fails without the upcast.Verified on GPU with
sentence-transformers/all-MiniLM-L6-v2(r=8, alpha=16, layers [4, 5], rsLoRA, modules_to_save, 20 steps): base trains LoRA on every layer pluspooler.densewith 337920 trainable parameters at scaling 2.0; after this PR LoRA lands on layers 4 and 5 only, scaling is 16/sqrt(8), and the trainable count matches plain PEFT (111360). On a Colab T4 in float16 the original change crashed with the error above and the fixed head trains and saves a merged model.