Skip to content

[BUGFIX] Validate save_method before decision push_to_hub_merged creates the repo - #19285

Open
DimitriChrysafis wants to merge 2 commits into
unslothai:mainfrom
DimitriChrysafis:fix-decision-push-validate-first
Open

DimitriChrysafis wants to merge 2 commits into
unslothai:mainfrom
DimitriChrysafis:fix-decision-push-validate-first

Conversation

@DimitriChrysafis

Copy link
Copy Markdown
Contributor

[BUGFIX] Validate save_method before decision push_to_hub_merged creates the repo

model.push_to_hub_merged("user/repo", save_method = "merged_4bit") on a decision model creates the Hub repo first and only then reaches save_pretrained_merged. That call rejects every method except merged_16bit, so you get a NotImplementedError and an empty repo you never asked for. It's the same ordering bug #18710 fixed on the main save path, and it's in both decision backends: push_to_hub_merged in decision.py (torch) and _decision_push_merged in decision_mlx.py (MLX).

The fix runs the same save_method != "merged_16bit" check at the top of both, before HfApi is even created.

Tests: one in tests/test_decision_model.py and one in tests/test_decision_mlx_guards.py. Each records create_repo calls. On main the repo is created before the error; with the fix it never is.

danielhanchen added a commit that referenced this pull request Nov 24, 2026
#19296)

## Problem

`studio/backend/tests/test_managed_engine_readiness_poll.py` fails on
main (6 of 9 tests) and on every PR based on it, for example #19284 and
#19285, which do not touch Studio:

```
>   child_env["WSL_UTF8"] = "1"
E   TypeError: 'NoneType' object does not support item assignment
```

## Cause

Two PRs merged within an hour of each other, each green on its own base:

- #19167 added `vllm` to `MANAGED_ENGINE_LOG_FAMILIES`, so a vLLM start
now captures logs and, on the WSL path, sets `child_env["WSL_UTF8"] =
"1"` on the environment `_wsl_command` returns (the SGLang half of this
came in #19166).
- #19242 added this test file. Its `_wsl_command` stub returned
`(command, None)`, and its base predated #19167, so vLLM did not capture
logs there and the `None` was never touched.

The code is right: the real `_wsl_command` always returns
`wsl_host.guest_command(...)`, whose second element is the `wsl.exe`
environment dict, and `test_managed_engine_logs.py` already stubs it
with `dict(os.environ)`. The stub was the part that did not match the
contract.

## Fix

- The stub returns `dict(os.environ)`, the same shape the real launcher
hands back.
- The fixture sets `UNSLOTH_STUDIO_HOME` to `tmp_path`, since the vLLM
start now opens a per-attempt log under the Studio home and the tests
should not write into the real one.

No product code changes.

## Verification

- `tests/test_managed_engine_readiness_poll.py`: 9 passed (6 failed on
main before the change).
- Reverting only the stub's return value back to `None` brings back the
same 6 failures.
- `test_managed_engine_logs.py`, `test_engine_ports.py` and this file
together: 50 passed; this file under `-n 4`, 3 repeats: 27 passed.

This branch has not been deployed

No deployments
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.

1 participant