Repository navigation
Studio: keep the custom chat template when applying a chat preset - #19154
Conversation
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
… saves A preset's load config now starts from the current model's settings instead of the defaults, so the custom chat template, the Transformers 4-bit choice, the vLLM/SGLang engine settings, the MLX drafter and the tensor split are no longer reset by applying a preset. The drafter and the split are still cleared when the preset's speculative mode or Auto GPU layers rule them out, as the settings controls do.
|
Pushed 9ea10d3 on top of the original commit (plus a merge of main). The PR's root cause is wider than the chat template:
Checked live in Unsloth Studio with a GGUF and a custom template: on main, applying a preset and reloading starts llama-server without |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
|
Codex converged on CI (upstream jobs were stuck in queue, so it ran on a fork staging PR with the same head against current main, Lyxot#281): 38 pass, 6 fail, none from this PR.
Changed during this round: one commit on top of the original ( |
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Applying a preset now changes only the load settings it saves; Codex converged and CI checked on staging.
#19230) ## Problem `studio/backend/tests/test_diffusion_rocm_tag_detect.py::test_no_diffusion_or_video_gate_reads_version_hip_directly` fails on main in the backend `(Python 3.13, diffusion)` shard, so open PRs such as #19154 inherit it: ``` AssertionError: use core.inference.rocm_bf16.is_rocm_torch(torch): AMD SDK / Radeon wheels leave torch.version.hip unset. Raw reads: {'diffusion_krea2_prefix_kv.py': [170]} ``` ## Cause #19208 (Krea 2 valid key prefix without a mask) added a gate that can swap auto's cuDNN pin for CUDA native flash on the mask-free prefix call. It decided "not ROCm" with `getattr(torch.version, "hip", None) is None`. AMD SDK / Radeon ROCm wheels leave `torch.version.hip` unset and carry the tag in `torch.__version__` instead. On those builds, the gate could treat a ROCm card as CUDA and force the CUDA flash backend. The guard is right and this is a real bug in the new gate, not a stale test. ## Fix - The gate now uses `core.inference.rocm_bf16.is_rocm_torch(torch)`, like every other diffusion and video gate. - New test `test_a_rocm_build_keeps_the_pin` checks that a ROCm build keeps the pin for both spellings: `torch.version.hip` set, and only a `+rocm` tag in `torch.__version__`. ## Verification - `test_diffusion_rocm_tag_detect.py` and `test_diffusion_krea2_prefix_kv.py`: 32 passed. - Main's `diffusion_krea2_prefix_kv.py` with this branch's tests fails both the guard and `test_a_rocm_build_keeps_the_pin[None-2.9.0+rocm7.1]`. The `version.hip` case passes on both, because main already handled it. I could not run this on real ROCm hardware. The check is the version-tag detection, simulated by patching `torch.__version__`.
## Problem `tests/studio/test_chat_preset_load_config.py::test_apply_skips_missing_load_config` fails on main in `Repo tests (CPU, studio)`. Open PRs inherit it, for example #19141, which only touches the CLI: ``` assert 'selectedGpuIds: store.selectedGpuIds' in '// SPDX-License-Identifier: ... ``` ## Cause #19154 (keep the custom chat template when applying a chat preset) is correct. `applyPresetLoadConfig` used to start from `DEFAULT_PER_MODEL_CONFIG` and list the store fields a preset keeps (`selectedGpuIds: store.selectedGpuIds`, the MLX and engram knobs). It now starts from `currentRuntimePerModelConfig()`, so a preset changes only its own fields. That config returns `selectedGpuIds: s.selectedGpuIds`, so the GPU selection is still kept. The test pinned the old spelling rather than the behavior. The frontend test #19154 added, `preset-keeps-chat-template.test.ts`, has a gap of its own. It checks that every non-preset field is unchanged, but it sets `selectedGpuIds: null`, which is the default. A preset that cleared the GPU selection still passed it. ## Fix - `test_apply_skips_missing_load_config` now checks the mechanism: - `applyPresetLoadConfig` spreads `currentRuntimePerModelConfig()`; - that config carries the store's `selectedGpuIds`; - the preset body never names `selectedGpuIds` itself. - `preset-keeps-chat-template.test.ts` sets a real selection (`[1, 0]`, physical indexes), so its unchanged-fields loop actually covers the GPU selection. ## Verification - `test_chat_preset_load_config.py`: fails on main, 16 passed here. - `preset-keeps-chat-template.test.ts`: 6 pass. - Sabotage, both tests fail in each case: - starting the preset from `DEFAULT_PER_MODEL_CONFIG` again; - adding `selectedGpuIds: null` to the preset. - With that second sabotage, the original frontend test still passes (6 pass, 0 fail). That shows the gap this closes.
Applying a custom chat preset cleared the custom chat template, so the next GGUF reload started llama-server without it and the model went back to its default template. Presets never save a chat template, so applying one now keeps the current template, the same way it already keeps the engram, MLX and GPU settings. Picking the Default preset and the preset's other settings behave as before.
Before
After