Skip to content

feat(lora): per LoRA-model configurable weight range#9154

Open
lstein wants to merge 1 commit into
mainfrom
feat/lora-weight-range
Open

feat(lora): per LoRA-model configurable weight range#9154
lstein wants to merge 1 commit into
mainfrom
feat/lora-weight-range

Conversation

@lstein
Copy link
Copy Markdown
Collaborator

@lstein lstein commented May 11, 2026

Summary

  • The LoRA weight slider was previously hard-coded to a -1.0..+2.0 range. Slider-style LoRAs that operate at larger scales (e.g. -10..+10) couldn't be driven to their useful values from the UI.
  • This PR adds optional weight_min and weight_max fields to LoraModelDefaultSettings, exposes them in the model edit panel as toggleable spinners (alongside a re-labeled "Starting Weight" spinner), and makes the canvas LoRA card's slider honor whatever range the user saved on the model. The previous -1..+2 hard cap on weight is removed.

Setting the min and max weights from within the Model Manager:

image

The LoRA slider with custom min and max ranges

image

Changes

  • Backend (invokeai/backend/model_manager/configs/lora.py): LoraModelDefaultSettings gains weight_min and weight_max (both optional, default None); a model validator rejects weight_min >= weight_max. Removed the ge=-1, le=2 constraint on weight.
  • Model edit panel: Three spinners in a single row — Starting Weight / Min Weight / Max Weight — each independently toggleable. Client-side validation surfaces a toast if min >= max before the PATCH.
  • LoRA card (canvas): Slider/number-input bounds are pulled from loraConfig.default_settings.weight_min/max, falling back to the global defaults (-1..+2 slider, -10..+10 number input).
  • State: Relaxed the zLoRA.weight zod schema from .gte(-10).lte(10) to plain z.number() so persisted values within a user-set wide range aren't rejected on rehydration.
  • Regenerated services/api/schema.ts; added en locale strings.

Test plan

  • Edit a LoRA, set Min Weight = -10 and Max Weight = 10, save; reopen the panel and confirm values persist.
  • Try saving Min >= Max and confirm the toast prevents the request.
  • Add the LoRA to a generation and verify the canvas slider now spans the saved range.
  • Edit a LoRA and leave min/max disabled; confirm the canvas slider falls back to -1..+2.
  • pnpm lint:tsc, pnpm lint:eslint, pnpm lint:prettier, pnpm lint:knip, pnpm lint:dpdm
  • pnpm test:no-watch (1097 passed)
  • pytest tests/app/routers/test_model_manager.py tests/backend/model_manager/configs/ (45 passed)

🤖 Generated with Claude Code

Adds optional `weight_min` and `weight_max` to the LoRA model's default
settings so slider LoRAs that operate at non-standard scales (e.g.
-10..+10) can be tuned without bumping into the previously hard-coded
-1..+2 slider range. The model edit panel exposes them alongside the
starting weight, and the LoRA card slider in the canvas honors whatever
range the user saved on the model.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added python PRs that change python files backend PRs that change backend files frontend PRs that change frontend files labels May 11, 2026
@lstein lstein added the 6.14.x label May 11, 2026
@lstein lstein moved this to 6.14.x Theme: LIBRARY UPDATES in Invoke - Community Roadmap May 11, 2026
@lstein lstein changed the title feat(lora): per-model configurable weight range feat(lora): per LoRA-model configurable weight range May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.14.x backend PRs that change backend files frontend PRs that change frontend files python PRs that change python files

Projects

Status: 6.14.x Theme: USER EXPERIENCE

Development

Successfully merging this pull request may close these issues.

2 participants