Skip to content

Studio: cap Qwen3.8 NPU context at 8192 - #13525

Merged
shimmyshimmer merged 2 commits into
unslothai:mainfrom
oobabooga:studio-npu-qwen38-context-cap
Oct 13, 2026
Merged

shimmyshimmer merged 2 commits into
unslothai:mainfrom
oobabooga:studio-npu-qwen38-context-cap

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The NPU catalog advertises 262,144 tokens for Qwen3.8-27B (qwen3.8-mtp:27b, FastFlowLM 1.0.7). Loading it at 16,384 reports success and the NPU status says ready, but every reply then fails with "The NPU model stopped before finishing its reply." (HTTP 502 on the API) until the model is reloaded at 8,192 or less. Reproduced on Linux and Windows.

Screenshots

Main vs this change on the Linux NPU runner, Qwen3.8 loaded at 16,384 from the model picker, then asked "What is 2 plus 2?". The context counter reads 16.4k on main and 8.2k here.

pr-npu-qwen38-context-cap-before-after

Root cause

  • Lemonade reports a FastFlowLM model's max_context_window from the checkpoint's config.json max_position_embeddings (read_flm_max_context_window), which is 262,144 for Qwen3.8. Lemonade main still does this.
  • FastFlowLM's Qwen3.8 engine supports 8k (model card), and FastFlowLM passes --ctx-len to the engine without checking it. Run directly, flm serve loads at 8192, while 8193 through 16384 all fail with attn_layout: max_len 16512 ... max_len is at most 16384 (MAX_L_LIMIT): any length above 8192 is rounded up past the engine's buffer limit (bisect).
  • The failed load happens inside flm serve after its server is up, so lemond and Studio report the model loaded.

Fix

  • The NPU catalog caps max_context_length with a per-checkpoint table of FastFlowLM engine limits, currently {"qwen3.8-mtp:27b": 8192}. LemonadeNpuBackend.load() already clamps a requested context to max_context_length, and the settings panel and load response read the same field, so a 16,384 request now loads at 8,192.
  • The Hub's NPU Run passes contextLength: model.max_context_length into the handoff, as the picker's NPU rows already do, so the settings panel opened from the Hub has the same bound. On main that panel is dismissed before it can be used (Studio: keep Hub Run settings open on a first Chat visit #13524), so this line shows only once that fix is in.

Behavior that stays as on main:

  • Every other NPU model keeps the context Lemonade reports. Qwen3-0.6B, whose 40,960 is above FastFlowLM's documented 32k, loads and answers at 40,960 on both OSes.
  • An oversized request is clamped, not rejected, which is how load() already treats every NPU model.

Testing

Live A/B on the Strix Halo NPU, Linux and Windows, main at 0f7bdbb against this change, each downloading the 18.1 GB model on a fresh runner and driven by Playwright (run, which also had #13524 applied):

Both OSes Main This PR
16,384 typed into the context field Accepted 8,192
Load, then "What is 2 plus 2?" in the UI Ready at 16,384, then "The NPU model stopped before finishing its reply." Ready at 8,192, answers 4
POST /api/inference/load at 16,384, then /v1/chat/completions 200 at 16,384, chat 502, status still ready 200 at 8,192, chat 200
Reload at 4,096 and chat Answers 7 Answers 7

At 8,192 the model also recalled a code from an 8,177-token prompt on both OSes (run).

  • test_npu_backend.py and test_npu_chat_route.py: 148 passed. The new catalog and load tests fail on main.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T06:51:14.363757Z 538f6cf Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T04:19:47.308412Z 9dfcb5a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member

pre-commit.ci run

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 538f6cf126

ℹ️ 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".

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#363.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants