Repository navigation
[Feature] AMD NPU: power mode, prefill chunk length and image pre-resize in model settings - #17510
Conversation
…size run settings FastFlowLM tuning for AMD NPU models under Advanced settings, sent to Lemonade as the flm_args recipe option. Each persists like any run setting (saved sets, Always load, the server-shared override) and a change makes /load reload instead of answering already_loaded.
…ops below it FastFlowLM loads with min(chunk, context) and the status echoes that, so a saved chunk above a lowered context never matched the load: the panel stayed dirty and Apply answered already_loaded. The context edit now clamps the chunk in the same patch. The prefill placeholder reads "default" like the hint.
…ts them An older client's save left the three NPU keys out, they defaulted to None and the replacement row dropped the saved NPU tuning. The route now keeps a stored NPU setting the payload omits, like the MLX offload knobs, and the client sends them as null when unset so clearing one still clears it.
|
Screenshots of this PR's change: Run settings for an NPU model with Advanced settings on: Power Mode and Prefill Chunk Length (Image pre-resize shows only for vision models). The placeholder reads "auto" here; the head now says "default".
|
…ad response POST /api/inference/load returned the three NPU run settings as null even when the resident load applied them, so a client reading the load response saw the wrong settings. The NPU load response now reads them from the resident flm_args, as the status endpoint does.
# Conflicts: # studio/backend/core/inference/npu_backend.py
…ng the resident process
…el's saved FastFlowLM flags
|
Measured on a real NPU: AMD Strix Halo (DevLab runner, Linux), FastFlowLM 1.0.12, Lemonade 2026.44.1, fork phase 5 Power mode changes nothing measurable on Strix Halo (all within 2%). FastFlowLM's default chunk is already the fast one. A 512 chunk makes a 1,764-token prompt take 2.4x longer on Qwen3.6-35B-A3B-NPU2 (25.6 vs 10.5 s) and 1.2x longer on Qwen3.5-9B-NPU2, and 2048 matches the default. So the defaults stay as they are. These settings are for hardware or prompts where they help; image pre-resize wasn't measured. |
…ema v16 after main's v15 engramPrecision
…amPrecision holds v15 [skip ci]
…ore them on a failed switch, and read them from the resident snapshot
Codex Review Summary: ✅ CompletedThis 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. Breezy! 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". |
# Conflicts: # studio/backend/core/inference/npu_backend.py # studio/backend/routes/inference.py # studio/backend/tests/test_gguf_load_cache_reuse.py # studio/frontend/src/features/model-picker/components/model-config-page.tsx [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3345c207d5
ℹ️ 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".
| replaced = True | ||
| self._raise_if_load_cancelled(model_id) | ||
| # Held to the context this load resolved, which only the load knows under Auto. | ||
| flm_args = clamp_prefill_chunk(flm_args, ctx) |
There was a problem hiding this comment.
Preserve the requested prefill chunk across Auto-context loads
When an Auto-context preset's saved chunk exceeds the RAM-fit context on a later load—for example, 8192 saved but 4096 resolved—this overwrites the requested chunk, so _Loaded.flm_args and /status retain only 4096. useActiveModelConfig then uses 4096 as the configuration value, while ModelConfigPage compares it exactly against the saved 8192. For a pinned set, reopening settings consequently shows “Unsaved changes” immediately after loading that set, and saving writes the transient RAM-fit value back into the preset. Preserve requested and effective chunk values separately, or normalize both sides of the frontend preset comparison to the resolved context.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6be93cc: the resident now keeps the requested chunk (what settings saved), lemond still gets it clamped to the resolved context, and the already-loaded check clamps both sides to the resident context.
… gets it held to the context [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". |
# Conflicts: # studio/frontend/src/features/npu/index.ts [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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". |



Advanced run settings for NPU (FastFlowLM via Lemonade) models: Power Mode, Prefill Chunk Length (clamped to context) and Image Pre-resize (vision only, Lemonade levels 0 to 4), sent as
flm_argson/v1/load; Default sends nothing. A change reloads instead of answeringalready_loaded;/statusreports what the resident asked for; bad values get a 400 before anything unloads.Tested on Windows 11, Ryzen 9 9950X + 2x R9700, no NPU: 24 new backend tests, 6 new frontend tests, related suites green (3 symlink failures also fail on main). Not run on a Ryzen AI NPU.
Screenshots
NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. Before | after: fork phase stack, phase 1
ac3e06e| phase 2945ba98. Shot at945ba98; this PR's head has since moved tob45bf6c(prefill chunk now held to the resolved context, backend and tests only). Light mode, mint theme, glass on, same on both sides.Before | after: NPU Run settings gain an Advanced section with Power Mode, Prefill Chunk Length and Image Pre-resize.

Also checked by building Unsloth Studio from this PR's merge base (left) and head (right), on the same spoofed AMD NPU:
Chat > run settings of an NPU model: Advanced settings now offer Power Mode and Prefill Chunk Length (Image Pre-resize appears for vision models).