Skip to content

fix(studio): stop false MTP/vision capability reports - #7332

Merged
danielhanchen merged 13 commits into
unslothai:mainfrom
Souravrajvi0:fix/7302-llama-cpp-vision-mtp-reporting
Jul 24, 2026
Merged

danielhanchen merged 13 commits into
unslothai:mainfrom
Souravrajvi0:fix/7302-llama-cpp-vision-mtp-reporting

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7302 — Studio could warn that the llama.cpp prebuilt “lacks MTP support” and report vision loads as “Vision projector incompatible…” even when those conclusions were wrong.

MTP false warning

probe_server_capabilities only inspected the first physical --help line containing --spec-type. Builds that put the enum on the indented description line were treated as missing MTP. Empty/--help crashes were also treated as “lacks MTP” instead of inconclusive.

Fix: parse the full --spec-type help block; only claim missing MTP when that enum is clearly present without mtp/draft-mtp; fail open (supports_mtp=True, mtp_probe_inconclusive=True) when the probe is inconclusive so the startup banner does not fire.

Vision misreport

A bare llama-server crash with --mmproj (common on some ROCm/driver paths) still correctly retries text-only, but if that retry also failed the user was told the projector format was incompatible.

Fix: keep the historical wording only for confirmed projector-format errors; otherwise report a crash-with---mmproj failure.

Test plan

  • tests/test_llama_cpp_mtp_detection.py (multiline help, empty/crash fail-open, outdated still reports false, real b10069 probe)
  • tests/test_llama_cpp_mmproj_fallback.py (retry messaging contract)
  • tests/test_llama_cpp_props_readback.py
  • Manual: Studio startup on a capable llama-server should not print the MTP lacks-support WARNING
    • Verified against /root/.unsloth/llama.cpp/llama-server (version: 10069, mtp_token=draft-mtp); _run_llama_cpp_startup_probes printed no MTP lacks-support WARNING
  • Manual: confirmed Unknown projector type abort still surfaces the historical projector message
    • _is_projector_incompatibility matches the Gemma-4 old-build abort; _mmproj_retry_failure_message(projector_confirmed=True) still starts with Vision projector incompatible with this llama.cpp build...

MTP probing only inspected the first physical --spec-type help line and
treated empty/crash --help output as "lacks MTP", which false-warned on
otherwise capable builds. Parse the full --spec-type help block, fail open
when the probe is inconclusive, and stop blaming bare mmproj crashes on a
projector-format mismatch when the text-only retry also fails.

Fixes unslothai#7302
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@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: 001091d9bd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if saw_spec_type:
supports_mtp = mtp_token is not None
else:
supports_mtp = True # fail open for UI/warning; mtp_token stays None

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 Don't mark successful no-spec probes as MTP-capable

When llama-server --help succeeds but the binary is old enough to have no --spec-type flag at all, this fail-open path returns supports_mtp=True and mtp_probe_inconclusive=True. /status uses supports_mtp directly for the llama_cpp_supports_mtp field, and startup warnings are now gated on not mtp_probe_inconclusive, so genuinely pre-MTP builds stop recommending unsloth studio update until a model load later falls back. Empty/crashed probes should fail open, but a nonempty successful help dump with no --spec-type is a definitive lack of MTP support.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed both Codex items on fix/7302-llama-cpp-vision-mtp-reporting:

P1 — No-spec successful probes (supports_mtp accuracy)
Probe now has three outcomes: (1) --spec-type block present → supports_mtp = (mtp_token is not None), (2) nonempty --help with no --spec-type → definitive supports_mtp=False, mtp_probe_inconclusive=False, (3) empty/crash → supports_mtp=False, mtp_probe_inconclusive=True (startup banner still suppressed via inconclusive flag).

P2 — Inconclusive probe at MTP load
_emit_mtp() checks mtp_probe_inconclusive: inconclusive probes load with --spec-default but do not set spec_fallback_reason=binary_no_mtp or emit the false "lacks MTP" warning.

/status no longer fail-opens to supports_mtp=True on probe exceptions.

pytest studio/backend/tests/test_llama_cpp_mtp_detection.py — 252 passed.

"mtp_token": mtp_token,
"supports_mtp": mtp_token is not None,
"supports_mtp": supports_mtp,
"mtp_probe_inconclusive": not saw_spec_type,

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 Preserve inconclusive state when MTP is requested

For an empty or crashing --help probe this new field records the probe as inconclusive, but the MTP launch path still checks only caps.get("mtp_token"); with mtp_token=None it logs that llama-server "lacks --spec-type mtp/draft-mtp", sets binary_no_mtp, and disables speculative decoding. That means the startup banner no longer fires, but the same false lack-of-MTP report still appears as soon as an MTP model is loaded under exactly the inconclusive-probe scenario this change is trying to handle.

Useful? React with 👍 / 👎.

…7302)

Treat nonempty --help without --spec-type as definitive no-MTP, keep only
empty/crash probes inconclusive, skip binary_no_mtp UI hint on inconclusive
loads, and stop reporting supports_mtp=True in /status for unknown probes.

@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: b252a1c7dd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +2861 to +2863
elif help_nonempty:
supports_mtp = False
mtp_probe_inconclusive = False

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 Treat failed help probes as inconclusive

When llama-server --help exits nonzero but prints any stdout/stderr without --spec-type (for example a dynamic-loader error, illegal-instruction message, or crash diagnostic), subprocess.run(..., check=False) returns normally and help_nonempty is true, so this branch records mtp_probe_inconclusive=False and re-enables the false “lacks MTP/update llama.cpp” path for a probe that actually failed. Please gate the definitive no-MTP result on a successful help exit, or keep nonzero help outputs inconclusive.

Useful? React with 👍 / 👎.

Gate definitive no-MTP results on a zero exit code so crash diagnostics with
nonempty stderr do not re-enable the false lacks-MTP warning path.
@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Fixed in 29110ce.

P2 — Treat failed help probes as inconclusive: Valid. Definitive no-MTP results now require returncode == 0 from llama-server --help; nonzero exits with nonempty output stay inconclusive.

Tests: test_probe_server_capabilities_failed_help_with_output_is_inconclusive.

@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: 29110cea34

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +2868 to +2870
else:
supports_mtp = False
mtp_probe_inconclusive = True

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 Preserve inconclusive MTP status

When --help is empty, crashes, or times out, this branch records mtp_probe_inconclusive=True but still stores supports_mtp=False. The fresh evidence in this version is that /status still exposes only this boolean (llama_cpp_supports_mtp) without carrying the inconclusive bit, while the response schema documents False as a reason to recommend updating, so clients can still see a definitive “no MTP” result for exactly the inconclusive probe path this patch is trying not to report. Please either fail-open the exported boolean for inconclusive probes or add/pass through an explicit unknown state.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Valid but latent: the frontend drives the update affordance from spec_fallback_reason (correctly None when inconclusive) and does not read llama_cpp_supports_mtp. Threading the inconclusive bit into /status is a follow-up.

@Souravrajvi0
Souravrajvi0 marked this pull request as draft July 23, 2026 07:34
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 5a9bd0b0ed

ℹ️ 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 on lines +2868 to +2870
else:
supports_mtp = False
mtp_probe_inconclusive = True

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 Preserve fail-open MTP status for inconclusive probes

When --help crashes, times out, or produces no usable output, this marks the probe inconclusive but still returns supports_mtp=False. /status directly maps that field to llama_cpp_supports_mtp (routes/inference.py:5814), whose API contract treats False as a definitive lack of MTP and recommends an update. Thus a capable binary with an inconclusive probe continues to be falsely reported as lacking MTP—the case this change is intended to avoid. Keep the public capability status fail-open for this case, or expose and consume an explicit tri-state/inconclusive value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 20ec723: /status now reports llama_cpp_supports_mtp fail-open when the probe is inconclusive; only a definitive lacks-MTP probe or a missing binary reports False.

Resolve llama_cpp.py conflict: keep upstream signal-crash guard on
text-only mmproj retry and PR branch _retry_detail classification.
@Souravrajvi0
Souravrajvi0 marked this pull request as ready for review July 23, 2026 10:23
@Souravrajvi0 Souravrajvi0 reopened this Jul 23, 2026
@Souravrajvi0

Copy link
Copy Markdown
Contributor Author

Ready for review — undrafted after @danielhanchen's commits on ``. Maintainer changes incorporated; awaiting CI + review.

@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: fc837425ff

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 8573 to +8576
flags.append("--spec-default")
self._speculative_type = "default"
self._spec_fallback_reason = "binary_no_mtp"
if inconclusive:
self._spec_fallback_reason = None

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 Don't disable MTP after an inconclusive probe

When llama-server --help crashes, times out, or prints nothing, the probe now records mtp_probe_inconclusive=True, but this branch still appends --spec-default before suppressing the fallback reason. In that exact inconclusive-probe case on a capable binary with an MTP model, Studio silently launches without speculative decoding and also hides the update/fallback hint, so users lose MTP until a successful help probe. Please fail open here by attempting MTP and relying on the existing startup retry on real failure, or expose an explicit unknown state instead of forcing --spec-default.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cannot fail open here: an inconclusive probe means the accepted enum token (draft-mtp vs mtp) is unknown, and guessing a wrong --spec-type value makes llama-server fail to launch entirely, which is strictly worse than loading without speculation. --spec-default is required to override an inherited LLAMA_ARG_SPEC_TYPE.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 20ec723b0e

ℹ️ 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/routes/inference.py Outdated
Comment on lines +5820 to +5822
_supports_mtp = bool(
_caps.get("supports_mtp", False)
or _caps.get("mtp_probe_inconclusive", False)

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 Report a missing llama-server as lacking MTP

When binary discovery fails, probe_server_capabilities(None) returns found=False, supports_mtp=False, and mtp_probe_inconclusive=True; this or consequently reports llama_cpp_supports_mtp=True even though no server exists that could run MTP. The response model documents False as the update recommendation signal, and before this change the missing-binary case correctly produced False, so installations without llama.cpp now receive a false capability report.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 36f9612: fail-open now additionally requires found=True, so a missing binary reports False again.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 36f9612646

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

@codex review

@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: 081efab5e9

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

Reviewed and verified. llama.cpp based models were falsely reporting MTP and vision capability, which misled the UI. This detects capability from the actual spec help output and fails open safely when the probe cannot run. Ran the MTP detection and mmproj fallback suites (316 tests) and simulated the probe success, failure, and unknown spec paths. Codex review converged with no open items. Good to merge.

@danielhanchen
danielhanchen merged commit 0e800d2 into unslothai:main Jul 24, 2026
46 of 47 checks passed
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.

[Bug] llama.cpp vision and mtp support reporting missing

2 participants