Skip to content

Fix Studio preferring MTP sidecars over embedded heads - #10181

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
wasimysaid:issue-10169
Sep 2, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
wasimysaid:issue-10169

Conversation

@wasimysaid

@wasimysaid wasimysaid commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • treat a positive architecture-scoped nextn_predict_layers value as authoritative proof that the selected GGUF embeds its MTP head
  • suppress Studio-discovered MTP sidecars consistently across local resolution, launch construction, and memory estimates
  • keep Hub-planned sidecars until the downloaded header can be inspected, preserving offline fallback for headless, zero-valued, or unreadable GGUFs

Why

Some repositories publish both a main GGUF with an embedded NextN/MTP head and a root mtp-*.gguf compatibility artifact. Studio currently passes that artifact as --model-draft; llama.cpp then replaces the embedded head and can reject the load, silently disabling speculative decoding.

This keeps the behavior automatic and metadata-driven. Raw user-owned llama.cpp arguments and DSpark/DFlash modes remain unchanged.

Verification

  • exact head ad61f96c3a0e9456c99daaa027ab7379903f6043: targeted suites passed on Ubuntu (699), macOS (699), and Windows (666 passed, 33 OS-specific skips)
  • hermetic issue probe: draft-mtp remains enabled and --model-draft is absent
  • real reported GGUF header: qwen35.nextn_predict_layers = 1
  • live issue-specific Studio E2E on the exact reported revision (RVN-Q6_K-mtp.gguf, 20.99 GiB) with the 1.69 GiB mtp-RVN.gguf sidecar present: Playwright loaded the model and completed a real chat; llama-server launched with --spec-type draft-mtp --spec-draft-n-max 2 and no --model-draft; runtime metrics recorded 36 drafted / 35 accepted tokens across 18 speculative verification steps
  • focused pre-commit hooks, deterministic worktree checks, and pre-push gate pass
  • latest Codex review: no major issues

CI note

Backend CI has two pre-existing merge-base failures:

  • Python 3.13: base and PR both fail only test_non_gguf_reload_settings.py::TestNonGgufStatusReportsWhatTheLoadAskedFor; this PR changes neither that test nor routes/inference.py.
  • Repo tests (CPU): base and PR both fail only test_model_picker_contracts.py::test_a_pinned_cached_row_loads_from_the_id_the_backend_pinned; this PR changes neither that test nor the frontend.

Closes #10169

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-09-02T09:59:40.755003Z ad61f96 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56f8c9b373

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

Comment thread studio/backend/hub/utils/gguf_plan.py Outdated
Comment on lines +294 to +297
variant_mtp_expected = (
None
if any(has_embedded_mtp_name_hint(file.path) for file in kept_main)
else mtp_expected

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the MTP sidecar until header metadata is available

When a headless GGUF happens to contain an MTP token adjacent to its quant, this filename-only hint removes the drafter from the variant's download plan even though no header has been inspected. If the user downloads the variant for later offline use, launch-time metadata can determine that nextn_predict_layers is zero or absent, but _download_mtp then has no cached sidecar to recover and speculative decoding is disabled. Keep the companion in the plan unless embedded-head metadata has actually been verified, or otherwise provide an offline-safe way to fetch it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ad61f96. The Hub planner no longer treats an MTP filename token as authoritative: it keeps the root companion until the downloaded main GGUF can be inspected, while launch-time positive nextn_predict_layers metadata still suppresses --model-draft. Added an offline-safety regression. Verification: 699 affected tests passed; focused pre-commit hooks passed; hermetic issue probe still emits embedded draft-mtp with no model drafter.

wasimysaid added a commit to wasimysaid/unsloth that referenced this pull request Sep 2, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ad61f96c3a

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

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the path in studio/backend/core/inference/llama_cpp.py where an embedded nextn_predict_layers head still gets a root mtp-*.gguf handed to --model-draft, and the Hub planner keeping the sidecar until the header is readable looks like the right split. Will get this reviewed.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

Follow-up: I ran the issue-specific live test on exact head ad61f96c3a0e9456c99daaa027ab7379903f6043, not just the hermetic command probe.

  • Studio loaded immutable model revision 20b94f0613b632b4848bbe3b1e05d9ee0c2b1608 with the 20.99 GiB RVN-Q6_K-mtp.gguf and the conflicting 1.69 GiB mtp-RVN.gguf present in the same snapshot.
  • The Playwright browser flow got HTTP 200 from the real load endpoint, showed the loaded Q6_K model, sent a chat prompt, and received the expected model response.
  • The live llama-server command contained --spec-type draft-mtp --spec-draft-n-max 2 and did not contain --model-draft.
  • llama.cpp metrics prove the speculative loop ran: 36 draft tokens, 35 accepted tokens, 18 verification steps.
  • Visual check at 1440×900 passed; the loaded-model and response states were fully rendered without clipping or obvious regressions.

This closes the remaining gap between launch-construction coverage and real model inference for #10169.

@danielhanchen
danielhanchen merged commit 368e1cb into unslothai:main Sep 2, 2026
49 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Studio passes repo-root mtp-*.gguf as --model-draft when the main GGUF embeds MTP

2 participants