Repository navigation
Studio: fit reasoning_effort to a template's enforced allowlist - #16527
Conversation
An API request or a reasoning-off launch could still send a level the template's raise_exception guard rejects (Mistral Small 4 accepts only none and high), failing every render. llama-server requests, its launch default, and the shared transformers/MLX renderer now map such a level to the nearest accepted one, and thinking off to none when the template offers it.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bd340afb2
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Callers that borrow the reasoning-kwargs methods unbound on lightweight backend stand-ins have no _rendered_chat_template method, so the lookup raised AttributeError there.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Review and CI summary for
|
) ## Summary `Repo tests (CPU, studio-install)` is still red on main after #16532. That PR fixed the shared no-torch harness in `test_no_torch_filtering.py`. A second test class has the same problem: it runs `install_python_stack()` in no-torch mode with `subprocess.run` mocked. It failed on #16534 and #16527, both of which ran on top of #16532: ``` tests/studio/install/test_rocm_support.py::TestProgressStepCountMatchesTotal::test_progress_reaches_total_without_torch[linux-False] tests/studio/install/test_rocm_support.py::TestProgressStepCountMatchesTotal::test_progress_reaches_total_without_torch[windows-False] tests/studio/install/test_rocm_support.py::TestProgressStepCountMatchesTotal::test_progress_reaches_total_without_torch[macos_arm-False] E RuntimeError: Could not resolve a compatible unsloth / unsloth-zoo pair for no-torch mode ``` The cause is the same as in #16532. Since #16157, a no-torch install resolves a compatible Unsloth / Zoo pair from wheel metadata, and it refuses only when the feed has no such pair. That is right for users, since such an install would fail anyway. `_run_stack` mocks `subprocess.run` to return nothing, so the probe finds no metadata and the full-pass (`SKIP_STUDIO_BASE=0`) cases stop before they reach the progress count they check. ## Change `tests/studio/install/test_rocm_support.py`, `TestProgressStepCountMatchesTotal._run_stack` only: `_no_torch_pair` returns a compatible pair, which models a feed that serves one. This is the same model as #16532. `NO_TORCH` and the new patch share one `patch.multiple`. That `with` statement already holds 20 context managers, which is Python's limit on nested blocks: a 21st `patch.object` makes the whole file fail to import with `SyntaxError: too many statically nested blocks`. The patched values are otherwise unchanged. ## Testing `tests/studio/install/test_rocm_support.py`: - main: 3 failed, 686 passed (the three cases above); - this branch: 689 passed, 2 skipped. I also ran `tests/studio/install` plus `tests/python` on this branch. "Could not resolve a compatible" no longer appears anywhere. 22 other tests fail locally, in `test_dependency_pass_skips.py` and `test_e2e_no_torch_sandbox.py`, and they fail the same way on main here. CI passes them in the same shard, so the cause is this host's environment.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Reached Codex review convergence at oobabooga#453 ("Didn't find any major issues" on 7ad5012, the current head). |
|
#16502 made the chat UI clamp to the levels a template enforces, but API requests, the GGUF launch default and the transformers/MLX renderer still sent any level, so Mistral Small 4 and Mistral Medium 3.5 failed on Rendering the real
CI is clear at |
Follow-up to #16502. That PR publishes the reasoning levels a template enforces with a
raise_exceptionguard. For Mistral Small 4 and Mistral Medium 3.5 those levels arenoneandhigh, so the chat UI now moves Low or Medium to High. Other paths can still send a level the template rejects, and the render then fails on every request:minimal,low,medium,xhighormax. OpenAI-compatible clients that default tomediumfail against these models. On GGUF the error now quotes the template; on safetensors and MLX it is still "An internal error occurred".lowas the server default, which breaks every request that does not name a level.xhighandmaxon GGUF fall through and send no level, so the template's default (none) silently turns thinking off.Fix
_fit_reasoning_effort_to_templatemaps a level the template's enforced allowlist rejects to the nearest one it accepts. It uses the same clamp as the UI (_clamp_reasoning_effort_to_levels, mirrored inprovider-capabilities.ts). Thinking off maps tononewhen the template offers it. It is applied in:LlamaCppBackend._request_reasoning_kwargs(per-request kwargs for llama-server)LlamaCppBackend._reasoning_kwargs(launch default)apply_chat_template_for_generation(the shared transformers and MLX renderer)The template used is the active override if one is set, otherwise the embedded template. Templates without such a guard are untouched, including gpt-oss and every family whose levels come from scanning. This follows the existing precedents: the
enable_thinking_effortstyle already clamps requests to the template's levels, and Muse Spark coerces into its raising template's accepted set.Tradeoff: an explicit API level is substituted silently rather than rejected, which is how the
enable_thinking_effortclamp already treats it. The transformers/MLX renderer importscore.inference.llama_cpplazily on its first render with an effort.Validation
Rendered the real
chat_template.jinjaof Mistral Small 4 (also the template embedded in the GGUF), Mistral Medium 3.5 and gpt-oss with every combination ofenable_thinkingand effort, plus both launch defaults:pytest studio/backend/tests/test_reasoning_effort_allowlist.py studio/backend/tests/test_muse_spark.py \ studio/backend/tests/test_deepseek_v4_thinking_effort.py studio/backend/tests/test_kimi_k3_reasoning_defaults.py \ studio/backend/tests/test_chat_template_continuation.py studio/backend/tests/test_launch_reasoning_flag.py \ studio/backend/tests/test_thinking_parameter.py # 245 passedEach new test was mutation-checked: reverting each of the four call sites (request, launch, override preference, transformers/MLX renderer) or the thinking-off mapping makes it fail.