Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(studio): use --reasoning for launch defaults - #8521

Open
ousamabenyounes wants to merge 6 commits into
unslothai:mainfrom
ousamabenyounes:fix/issue-7526
Open

fix(studio): use --reasoning for launch defaults#8521
ousamabenyounes wants to merge 6 commits into
unslothai:mainfrom
ousamabenyounes:fix/issue-7526

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detect whether the installed llama-server exposes --reasoning
  • use --reasoning on|off for enable_thinking on modern builds
  • retain --chat-template-kwargs for older builds, independent preserve_thinking state, and reasoning_effort-style templates
  • preserve inherited LLAMA_ARG_REASONING overrides from unsloth start

Fixes #7526

Test verification (RED → GREEN)

Rebased PR head with the original regression test only:

FAILED test_modern_launch_honors_reasoning_env_override[True-off]
assert '--reasoning' not in ['llama-server', '--reasoning', 'on']

Patched branch:

4 passed in 1.50s
review-fix diff coverage: 3/3 changed executable lines covered

Follow-up test-only guards from Apoze's reviewed commit were cherry-picked and kept credited. After rebasing onto current main, the rebased baseline needed the launch test double updated for current keyworded GPU/health probes before the file could run:

baseline ./run-ci.sh: 1 failed, 3 passed
final ./run-ci.sh: 6 passed

One current-main Python 3.13 sentinel drift was then corrected test-only after CI exposed it:

test_non_gguf_reload_settings.py::TestNonGgufStatusReportsWhatTheLoadAskedFor::test_the_non_gguf_status_branch_publishes_them
1 passed

One current-main repo CPU sentinel drift was also corrected test-only after CI exposed the model picker's centralized selectMeta load-id shape:

tests/studio/test_model_picker_contracts.py::test_a_pinned_cached_row_loads_from_the_id_the_backend_pinned
1 passed

Validation

  • ./run-ci.sh upstream baseline: 296 backend tests + 6 CLI reasoning tests passed
  • ./run-ci.sh patched branch: 300 backend tests + 6 CLI reasoning tests passed
  • ./run-ci.sh after this follow-up commit: git diff --check, Ruff, and tests/test_launch_reasoning_args.py passed (6 passed)
  • selected adjacent launch/reasoning backend tests plus the Python 3.13 and repo CPU sentinel failures passed (545 passed)
  • Ruff and git diff --check: passed

@mahiatlinux

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 94baeb68f7

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

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

ℹ️ 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 thread studio/backend/core/inference/llama_cpp.py Outdated
@Apoze

Apoze commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Thank you for updating this PR. GitHub now reports the branch as mergeable on current main, and the implementation correctly covers the native flag, the old-binary fallback, the #9096 preserve default, and the inherited environment override.

A separately validated current-main implementation remains available as one commit here:

Apoze@502668e

It keeps the change generic and avoids regressions introduced since this PR was opened:

  • uses native --reasoning on|off when the installed llama-server supports it;
  • preserves the separately calculated _preserve_thinking_default added by Default preserve thinking on for Qwen3.8 #9096;
  • retains the existing --chat-template-kwargs fallback for older binaries;
  • leaves an inherited LLAMA_ARG_REASONING operator override in control.

Current-main validation: 9 focused launch-reasoning tests passed; 1,659 adjacent capability, placement, and launch tests passed; Ruff, the repository format script, and git diff --check passed. Five additional local Windows failures were platform-only (resource is Unix-only and one simulated Metal case reads the Windows host-memory guard), not reasoning failures.

Two regression guards from that commit are still worth carrying into this PR before merge:

  • set _preserve_thinking_default = True in a modern-path test and assert {"preserve_thinking": true} remains in --chat-template-kwargs; the current fixture always sets it to False, so it would not catch the original Default preserve thinking on for Qwen3.8 #9096 regression;
  • use reasoning_effort style with a modern-capable binary and assert it stays in --chat-template-kwargs rather than being translated to the boolean --reasoning flag.

I am intentionally not opening a competing PR while this one remains active.

@ousamabenyounes
ousamabenyounes force-pushed the fix/issue-7526 branch 2 times, most recently from a71f987 to 148c8e5 Compare August 23, 2026 22:53
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Addressed the inherited reasoning override on 148c8e5: modern launches now leave LLAMA_ARG_REASONING in control, preserve the separately computed preserve-thinking default, and retain the legacy kwargs fallback. Validation reproduced RED (1 failed, 2 passed), then focused GREEN (3 passed), full baseline/final 296 → 299 passed, 100% diff coverage, and final CI completed with 39 successes and 0 failures. Co-authored with Apoze; attribution is recorded in the commit trailer.

@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Thank you @Apoze for taking the time to investigate this and share your fix.
I had been struggling to find a clean path forward on this PR, and your implementation was very helpful.
In particular, it identified the missing environment-override case and provided a clear, well-tested path to the final solution.

Incorporated the relevant fix and tests, and made sure your contribution was properly credited through the Co-authored-by trailer in commit 4348739.

@Apoze

Apoze commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

I added the two remaining test-only regression guards on top of the current head 148c8e5d43decbe780dd78f699fed769c52377d0:

  • Qwen3.8 preserve_thinking=True remains in --chat-template-kwargs on the modern --reasoning path.
  • reasoning_effort-style templates keep their launch default in --chat-template-kwargs and never convert it to --reasoning.

Commit: Apoze@e0d0066

Validation: 323 adjacent launch/llama-server reasoning tests passed; Ruff check and git diff --check passed. Independent review found no issues. The commit changes only studio/backend/tests/test_launch_reasoning_args.py and is ready to cherry-pick:

git cherry-pick e0d0066193353d5d5abbe796eb10f6eabcf07d5f

@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: 70a2843125

ℹ️ 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 thread studio/backend/core/inference/llama_cpp.py Outdated
Comment thread studio/backend/core/inference/llama_cpp.py Outdated

@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: 54142a3adf

ℹ️ 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 thread studio/backend/core/inference/llama_cpp.py Outdated
@ousamabenyounes

Copy link
Copy Markdown
Contributor Author

Follow-up pushed in e4c893eb081e493e6000621493b90f4e547474ff.

I verified Apoze's 2026-08-24 comment and test-only commit e0d0066193353d5d5abbe796eb10f6eabcf07d5f through the GitHub API, cherry-picked the two regression guards cleanly, and kept Apoze credited on that test commit with the requested co-author trailer.

CI then exposed two current-main source-sentinel drifts, both fixed as separate test-only commits. The latest push also addresses the three launcher review threads: explicit LLAMA_ARG_REASONING=on/off now updates the recorded reasoning_default, auto stays on the model-derived default path, and inconclusive probes no longer emit a conflicting fallback enable_thinking kwarg when an explicit env override is present.

Local validation:

  • RED for the new reviewer regressions: 3 failed, 5 passed before the launcher fix.
  • Final ./run-ci.sh: 8 passed.
  • Selected adjacent launch/reasoning/sentinel suite: 547 passed.

Remote PR checks are green on the latest SHA; the only non-pass rows are the expected skipped GPU/gate/file-edit/resume jobs.

@danielhanchen

Copy link
Copy Markdown
Member

The launcher change itself is contained, but this branch also rewrites the sentinels in studio/backend/tests/test_non_gguf_reload_settings.py and tests/studio/test_model_picker_contracts.py, which loosens guards unrelated to reasoning. Could you split those two into their own change and keep this one to the llama-server reasoning flag?

ousamabenyounes and others added 6 commits September 8, 2026 10:18
Add regression coverage for preserving model thinking defaults on modern --reasoning launches and keeping reasoning_effort-style templates in chat-template kwargs.

Adapt the launch test backend double to current main's keyworded health and GPU probes after rebasing.

Co-authored-by: Apoze <[email protected]>
Keep LLAMA_ARG_REASONING=auto on the model-derived launch default path, synchronize explicit on/off overrides with reasoning_default, and avoid emitting fallback enable_thinking kwargs when an inconclusive probe leaves an explicit environment override as the only trusted launch control.

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

ℹ️ 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 +7060 to +7061
if explicit_env_reasoning is not None:
self._reasoning_default = explicit_env_reasoning == _REASONING_ON

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 recorded default aligned on old binaries

When the capability probe conclusively identifies an older binary (supports_reasoning_flag=False and mtp_probe_inconclusive=False) and LLAMA_ARG_REASONING is explicitly on or off, this assignment records the environment value even though the fallback below still emits the model-derived enable_thinking kwarg. Older managed binaries intentionally ignore that environment variable (unsloth_cli/commands/start.py:1271-1274), so the running template uses thinking_default while omitted Anthropic requests consult the contradictory reasoning_default at routes/inference.py:4239, potentially leaking genuine reasoning or misclassifying literal think markup. Only synchronize this property when the environment override can actually control the selected binary.

Useful? React with 👍 / 👎.

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.

--chat-template-kwargs is deprecated, use instead --reasoning

4 participants