Repository navigation
Fix Studio CPT overwriting LFM2 all-linear LoRA targets - #9870
Conversation
When switching to continued pretraining, preserve architecture-specific all-linear defaults instead of replacing them with Llama-style module names. Restore the pre-CPT target list when leaving CPT and expose all-linear in the CPT advanced-settings UI for models like LFM2. Fixes unslothai#9866
5d448ec to
c226fd7
Compare
Use `as const` for chatml so tsc -p tsconfig.test.json passes in CI.
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd03eff8b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| targetModulesBeforeCpt: | ||
| persistedState.trainingMethod === "cpt" && | ||
| Array.isArray(targetModulesBeforeCpt) && | ||
| targetModulesBeforeCpt.length > 0 | ||
| ? [...targetModulesBeforeCpt] | ||
| : null, |
There was a problem hiding this comment.
Recover pre-CPT targets when hydrating legacy sessions
For a persisted CPT session created before this change, targetModulesBeforeCpt is absent, so this normalization always stores null even when advancedSettingsBaseline.targetModules records the model's original all-linear default. Because the persistence version remains 21 and an already-applied model is reloaded without applying its defaults, switching such an LFM2 session away from CPT falls back to the hardcoded Llama targets; switching back to CPT then preserves those wrong targets, so existing users affected by the reported issue remain affected after upgrading. Recover the value from the persisted model baseline or add a migration that forces the model-specific targets to be reapplied.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9ecd6c5a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| {(isCpt ? getCptUiTargetModules() : TARGET_MODULES).map( | ||
| (module) => { | ||
| const active = isCpt | ||
| ? isCptTargetModuleActive(store.targetModules, module) | ||
| : store.targetModules.includes(module); |
There was a problem hiding this comment.
Handle all-linear in non-CPT target controls
When LFM2's new defaults are loaded in QLoRA/LoRA, or when the user leaves CPT and the new provenance logic restores ["all-linear"], this branch still renders only TARGET_MODULES, so every control appears inactive. Clicking one then appends it to the hidden sentinel, producing ["all-linear", "q_proj"]; trainer.py:1295-1300 explicitly removes all-linear from mixed lists, silently training only the clicked projection instead of every linear layer. Render and toggle the exclusive all-linear option for non-CPT adapter methods too, or normalize it away before named modules are edited.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
|
Final review update — converged at The CPT target-module change is now hardened across the full state lifecycle:
Validation on the exact pushed head:
Deterministic UI comparison using the same persisted state ( Initial state — the base has no active After turning off After turning off CI is not fully green. More than thirty exact-head jobs pass, including Studio parity, all Chat UI shards, source lint, Windows frontend tests, API/auth, wheel, Tauri, startup, GGUF, llama.cpp, Windows install, Rust, and pre-commit. The completed red checks reproduce on the merge base or are outside this PR's diff: workflow-trigger lint, frontend bundle smoke ( The branch is pushed and the PR-specific review is converged. I did not merge it; GitHub still reports unrelated failing or pending checks. |



Summary
Fixes #9866
When switching to Continued Pretraining (CPT) in Studio, the UI was replacing model-specific
all-linearLoRA defaults with hardcoded Llama-style target module names (q_proj,o_proj,gate_proj, etc.).For
LiquidAI/LFM2-1.2B, this silently attached LoRA to only 18 modules (q/k/v projections) instead of all 92 eligible linear layers, because LFM2 uses architecture-specific names likeout_proj,in_proj,w1,w2, andw3.Changes
resolveCptTargetModules()to preserveall-linearwhen entering CPTtargetModulesBeforeCptin training method provenanceall-linearin the CPT advanced-settings UI when applicableReproduction
Before fix (Studio CPT defaults on LFM2):
With
all-linear:Test plan
npm test -- tests/cpt-target-modules.test.ts tests/training-method-provenance.test.ts tests/training-config-persistence.test.tsall-linear+modules_to_save) covers all LFM2 linear modules