Skip to content

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

Closed
ousamabenyounes wants to merge 10 commits into
unslothai:mainfrom
ousamabenyounes:fix/issue-7526
Closed

ousamabenyounes wants to merge 10 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
Contributor

@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".

@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".

@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".

@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 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main still builds the launch with --chat-template-kwargs in studio/backend/core/inference/llama_cpp.py, and the branch now only touches the launcher plus its own test file, so the sentinel split I asked for looks done. Will get this reviewed.

…args

Three launch paths disagreed with the reasoning default Studio recorded.

LLAMA_ARG_REASONING was read as on/off only, but llama-server's own parser
(common/arg.cpp is_truthy / is_falsey / is_autoy) also takes enabled/true/1,
disabled/false/0 and -1. An operator on any of those spellings was read as
"no override", so the launch appended its own --reasoning, and llama-server
prefers the command line over the environment ("LLAMA_ARG_REASONING
environment variable is set, but will be overwritten by command line
argument --reasoning"). Their choice was silently discarded.

The kwargs were also derived from the model's default and only then was the
operator's default recorded, so the two disagreed wherever the override could
not be expressed as --reasoning: a build whose --help lacks the flag ignores
LLAMA_ARG_REASONING as well and ran on the model default, and a
reasoning_effort template has no enable_thinking for the flag to carry, so
gpt-oss kept its "high" ladder under LLAMA_ARG_REASONING=off while Studio
reported thinking off. Resolving the override first fixes both.

Restores the launch log dropped with the old kwargs branch, now naming which
of the three channels carries the default, since unslothai#7526 was diagnosed from it.

An exhaustive sweep of supports_reasoning_flag x mtp_probe_inconclusive x 16
environment values x 3 reasoning styles x preserve support x thinking default
(1536 launches) goes from 264 contradictory launches to none. The 27 tests
here cover the new cells and no longer depend on the caller's environment: an
exported LLAMA_ARG_REASONING=on turned three of them red for reasons that had
nothing to do with the code under test.

Co-authored-by: ousamabenyounes <[email protected]>
Co-authored-by: Apoze <[email protected]>
@danielhanchen

Copy link
Copy Markdown
Member

Reviewed this properly and pushed the fixes to your branch in b9abb71. The approach is right and I want to merge it; the notes below are what the simulation turned up on top of it.

The premise checks out

The thing I most wanted to rule out was whether --reasoning off is a hard gate. Studio leans on the launch value being a per-key default that a request can override, and several places say so out loud (studio/backend/routes/inference.py:30194, :4187). If the native flag were a gate, the thinking toggle in chat would stop working the moment a modern llama-server was installed.

It is not a gate. Upstream, --reasoning on|off writes default_template_kwargs["enable_thinking"] (common/arg.cpp:3676-3693), which is the same map --chat-template-kwargs writes (arg.cpp:3534), and a request's chat_template_kwargs is merged over it per key and then re-read (tools/server/server-common.cpp:1321-1344). Confirmed on a real llama-server b10360 with Qwen3-0.6B, once on a B200 and once CPU-only with -ngl 0; both tables are identical:

launch args plain request enable_thinking=true request enable_thinking=false reasoning_effort=none
(none) THINKING THINKING no-thinking no-thinking
--reasoning off no-thinking THINKING no-thinking no-thinking
--reasoning on THINKING THINKING no-thinking THINKING
--chat-template-kwargs {"enable_thinking": false} no-thinking THINKING no-thinking no-thinking
--chat-template-kwargs {"enable_thinking": true} THINKING THINKING no-thinking THINKING
--reasoning off + {"preserve_thinking": false} no-thinking THINKING no-thinking no-thinking

flag_off and kwargs_off match row for row, so the substitution is exact.

What I changed

I swept the whole input space of _append_launch_reasoning_args: supports_reasoning_flag x mtp_probe_inconclusive x 16 LLAMA_ARG_REASONING values x 3 reasoning styles x preserve support x thinking default, 1536 launches, each judged against what llama-server actually does with the resulting argv. 264 of them launched a server that contradicted the reasoning default Studio recorded. Three causes:

  1. {"on", "off"} is narrower than llama-server's own parser. is_truthy / is_falsey / is_autoy (common/arg.cpp:1331-1341) also take enabled|true|1, disabled|false|0 and -1. I checked all of them against the binary: every one parses, and only bogus and "" are rejected. So LLAMA_ARG_REASONING=true read as "no override", we appended our own --reasoning, and the CLI beats the environment. llama-server even says so: LLAMA_ARG_REASONING environment variable is set, but will be overwritten by command line argument --reasoning. The operator's choice was dropped. Matched case-sensitively and unstripped now, exactly as upstream compares, since ON and " on " abort the server rather than meaning on.

  2. The kwargs were built before the override was resolved. That is fine wherever the override becomes --reasoning, and wrong everywhere else. A build whose --help lacks --reasoning ignores LLAMA_ARG_REASONING too, so unsloth start --reasoning off was silently dropped there while reasoning_default claimed otherwise. And a reasoning_effort template never reads enable_thinking at all, so gpt-oss kept its "high" ladder under LLAMA_ARG_REASONING=off while Studio reported thinking as off. Resolving the override first fixes both, and folds your inconclusive-probe branch down to one case instead of three.

  3. The tests depended on the caller's environment. With LLAMA_ARG_REASONING=on exported, test_launch_reasoning_args_use_modern_flag_with_old_binary_fallback, test_modern_launch_preserves_model_thinking_default and test_load_command_uses_reasoning_flag all fail, because the helper correctly stands aside. An autouse fixture clears it now; the file passes under all 13 values I tried, including unset and empty.

After the fix all 1536 cells agree. The sweep is not vacuous: reverting just the source change takes it back to 264.

I also restored the logger.info that went with the old kwargs branch, since #7526 was diagnosed from that exact log line. It now names which of the three channels carries the default.

Compatibility

  • Old binaries. No cell emits --reasoning to a build that lacks it, across every environment value and both probe outcomes. A pre-b20297 build gets byte-identical argv to main today when no override is set.
  • Platforms. The only platform-dependent surface this adds is the --help parse, so I ran it over Linux/Windows/macOS x LF/CRLF/CR x modern/old/prose-only/removal-stub/empty/nonzero-exit/stderr-only, 30 cells, all identical. Worth noting the parser tokenises rather than substring matching, so --reasoning-format, --reasoning-budget and --reasoning-preserve do not trigger a false positive, and neither does the flag being named inside another flag's description. LLAMA_ARG_* is still stripped from the probe environment on all three, and macOS still gets GGML_METAL_DEVICES=0.
  • Hardware. Nothing here reads the device. The end-to-end table above is identical on a B200 and on CPU with -ngl 0.
  • Upgrades. _capability_cache is an in-process dict keyed on binary path, mtime and size, never persisted, so the new capability key cannot be read stale from an older install. Every consumer uses .get(), so a cache dict without the key falls back to the kwargs path.
  • Selected suite: 4016 passed against 3998 on your head, with an identical set of pre-existing failures. unsloth_cli reasoning tests 19 passed. Ruff and git diff --check clean. Verified on your branch and again with current main merged in.

Two follow-ups, not for this PR

  • unsloth start also writes LLAMA_ARG_REASONING_EFFORT (unsloth_cli/commands/start.py:1277) which this helper never reads, so on a reasoning_effort model our --chat-template-kwargs still beats the operator's env. Pre-existing on main.
  • An invalid LLAMA_ARG_REASONING ("" or a typo) aborts llama-server at startup and no CLI flag can rescue it, because the environment is parsed first. Studio would have to scrub it. Also pre-existing.

Your branch is a fair way behind main; I merged main locally and everything above still holds, but please merge it up before we land this.

ousamabenyounes and others added 2 commits September 14, 2026 10:20
An inconclusive probe dropped enable_thinking from the launch whenever
LLAMA_ARG_REASONING was explicit, on the reasoning that a build new enough to
read the environment itself must not also be handed a kwarg contradicting it.

That kwarg can no longer contradict anything. It is now resolved from the same
environment value just above, so it sets enable_thinking to what the
environment already asked for, and both write the same
default_template_kwargs entry upstream. What the branch did cost was the case
it could not rule out: an inconclusive probe is precisely the state where we
do not know the binary is modern, and on one that is in fact old, ignoring
LLAMA_ARG_REASONING, the launch carried no reasoning instruction at all and
the operator's setting silently vanished.

Sending the kwarg is correct on both: the value matches the environment on a
modern build, and it is the only channel an old build understands.

Extends the launch sweep with that axis. Against the branch point, 344 of 1536
launches contradicted the reasoning default Studio recorded; none do now.
@danielhanchen

Copy link
Copy Markdown
Member

Follow-up on 2a9eaaec, plus a correction to my own numbers above.

Correction: I wrote that 264 of 1536 simulated launches contradicted the recorded reasoning default. That was measured before I added the last check to the sweep. The real figure against the branch point is 344 (96 environment-spelling, 40 legacy-desync, 128 effort-ladder, 80 inconclusive-probe). All 344 are clean now.

The inconclusive-probe branch

I had left this one alone, since it was a deliberate choice you made in response to review. Reading it again after the reorder, I think the reorder removed the reason it existed, so I have taken it out.

The branch dropped enable_thinking whenever the probe was inconclusive and LLAMA_ARG_REASONING was explicit, and the comment gave the reason: a build new enough to read the environment itself must not also be handed a kwarg contradicting it. That was right when the kwarg came from the model's own default. It no longer can contradict anything, because the kwarg is now resolved from that same environment value a few lines up, so it sets enable_thinking to what the environment already asked for, and upstream both land in the same default_template_kwargs entry.

What the branch did still cost is the case it could not rule out. An inconclusive probe is exactly the state where we do not know the binary is modern. On one that is in fact old, which ignores LLAMA_ARG_REASONING, the launch went out with no reasoning instruction at all and the operator's setting silently disappeared. Sending the kwarg is right on both: it matches the environment on a modern build, and it is the only channel an old build reads.

test_inconclusive_probe_preserves_explicit_reasoning_env changes with it, since it asserted the empty argv. The name is still accurate; it now preserves the override rather than the silence.

Verified on your merged head

Thanks for merging main up. Everything re-run on 2a9eaaec:

  • 1536-cell launch sweep: 0 contradictions, against 344 at the branch point. Reverting only the source change puts them back, so the sweep is not vacuous.
  • test_launch_reasoning_args.py: 27 passed, under LLAMA_ARG_REASONING unset, empty, on, off, true, 1, auto, -1 and bogus.
  • Selected backend suite: 4017 passed, with a failure set identical to your pre-fix head.
  • 30-cell probe parse over Linux/Windows/macOS x LF/CRLF/CR: identical everywhere.
  • Ruff and git diff --check: clean.

This looks good to merge from my side once CI is green.

The reasoning override matched its own frozensets of on/enabled/true/1 and
off/disabled/false/0 and auto/-1. This module already defines exactly those,
as _LLAMA_ARG_TRUE_VALUES / _LLAMA_ARG_FALSE_VALUES / _LLAMA_ARG_AUTO_VALUES,
and llama_server_args.py carries a documented second copy for the same
vocabulary. A third set meant the next time llama.cpp widens what is_truthy
accepts, one of them would be missed.

No behaviour change: the sets are identical member for member.
@danielhanchen

Copy link
Copy Markdown
Member

Third pass, closing the gaps I listed as untested. Pushed 7e92fd76, which is a refactor only.

One cleanup, no behaviour change

7e92fd76 deletes the three frozensets the override matching used. llama_cpp.py already defines exactly those sets, _LLAMA_ARG_TRUE_VALUES / _LLAMA_ARG_FALSE_VALUES / _LLAMA_ARG_AUTO_VALUES, and llama_server_args.py carries a documented second copy of the same vocabulary. A third would have gone stale the next time llama.cpp widens is_truthy. Member for member identical, so the 1536-cell sweep is unchanged at zero.

Simulations added since the last comment

  • [Windows, Linux, WSL, macOS] x [NVIDIA, AMD, CPU-only] x 5 launch scenarios, 60 cells. These drive the real load_model, not the helper, because the reasoning block is appended into the same cmd the placement code then adds -ngl, --device, --split-mode and tensor overrides to. Reasoning arguments are identical in all 60, with no duplicated flag. WSL is covered as its own cell, a .exe binary on a linux platform string, since Studio is routinely pointed at a Windows build across /mnt/c.
  • Upgrades and old installs, 13 checks. A capability dict from a Studio predating the key reads as unsupported and falls back to kwargs. An in-place llama.cpp upgrade, which is what the updater does, is re-probed rather than served from cache, so the launch switches to the native flag with no restart; a downgrade switches back. A missing binary is inconclusive rather than a confident "old". The capability cache is an in-process dict, never a file, so nothing stale can be read by the next Studio.
  • Precedence against user custom args, on the real server. Studio appends user extras after its own reasoning block, so I checked the user still wins. --reasoning on --reasoning off gives no-thinking, --reasoning off --reasoning on gives thinking, and --reasoning off plus a user --chat-template-kwargs {"enable_thinking": true} gives thinking. Anyone who today puts --chat-template-kwargs in custom server args keeps the behaviour they have.

Nothing else in Studio reads this

I checked every category that could have been coupled to the launch string. The argv is never persisted, never compared and never re-parsed. The relaunch decision is made from GgufLoadIntent and the user's extra_args, never from the built command, so swapping the flag cannot change whether a reload is triggered. /props is read only for modalities and n_ctx. vLLM, MLX, the Ollama-compatible routes, the diffusion/TTS runners, the MCP server and the tool loops have no reasoning launch state at all; everything else reads the in-process reasoning_default attribute.

Upstream, verified against current master

  • Nothing proposes removing --chat-template-kwargs or removing, renaming or re-speccing --reasoning. The deprecation is per-key inside the handler and the value is still applied unconditionally. Open items nearby are all additive.
  • --reasoning on|off still writes default_template_kwargs["enable_thinking"] on master, and the per-request merge still overrides it. Unchanged since it landed.
  • --reasoning first shipped in b8287, 2026-03-12. Anything older takes the kwargs path, which is what the probe already decides.
  • --reasoning-budget defaults to -1 and is not part of the enable condition, so it cannot defeat --reasoning on. Worth knowing that before b8287 it was coupled, and --reasoning-budget 0 forced thinking off; Unsloth never sets it either way.

One follow-up that matters, and is not this PR

llama.cpp PR #28174 (2026-09-02, around b10763) made llama-server default preserve_reasoning to "true" when it is not explicitly set. Studio sends preserve_thinking, which is a model-template-side kwarg that llama.cpp passes through to Jinja and never interprets; the flag that covers llama.cpp's own key is --reasoning-preserve / --no-reasoning-preserve. So on a new enough build, a Studio launch asking for preserve_thinking: false can sit alongside an injected preserve_reasoning: true, and on a template that understands both they disagree.

This is pre-existing on main and untouched by this PR, which is why I have not folded it in. It also is not reproducible on the bundled b10360, which predates that change, so I am reporting it from the upstream source rather than from a run here. Worth its own issue.

Separately, --chat-template-kwargs is in _TEMPLATE_FLAGS in llama_server_args.py:509, so an inherited user copy is stripped when a chat template override is applied, while --reasoning and -rea are in no strip group and survive:

['--chat-template-kwargs', '{"enable_thinking": false}']  -> []
['--reasoning', 'off']                                    -> ['--reasoning', 'off']

Same user intent, different outcome depending on spelling, and this PR is what makes the surviving spelling the recommended one. It is a one-line addition to that set, but it changes inherited-extras handling rather than the launcher, and you asked to keep this PR to the reasoning flag, so I have left it out and am noting it instead.

State

7e92fd76. Sweep 1536/1536 clean against 344 at the branch point; 30 platform-parse cells; 60 OS x device cells; 13 upgrade checks; 27 unit tests green under nine LLAMA_ARG_REASONING values including unset, empty and invalid; selected backend suite 4555 passed with a failure set identical to your pre-fix head; Ruff and git diff --check clean.

Still cannot answer from this host: real AMD and real Apple Silicon. Nothing in this path reads the device and the 60-cell sweep shows the arguments are invariant under it, but that is a simulation, not gfx1151 or an M-series Mac.

@danielhanchen

Copy link
Copy Markdown
Member

Thanks for the contribution! For now we'll default to using chat-template-kwargs since there can be many new args which needs injecting

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