Skip to content

[BUGFIX] Preserve explicit UNSLOTH_COMPILE_DISABLE=1 in FastModel loader - #18773

Merged
shimmyshimmer merged 5 commits into
unslothai:mainfrom
DimitriChrysafis:fix-loader-compile-disable-overwrite
Nov 23, 2026
Merged

shimmyshimmer merged 5 commits into
unslothai:mainfrom
DimitriChrysafis:fix-loader-compile-disable-overwrite

Conversation

@DimitriChrysafis

Copy link
Copy Markdown
Contributor

Summary

  • Add _set_partial_compile_disable() in unsloth/models/loader.py and route all five model-specific "partial" compile-disable branches (gemma3 on RDNA, deepseek_v41, csm, DISABLE_COMPILE_MODEL_NAMES, and transformers 4.x T5) through it.
  • Prevents FastModel.from_pretrained from downgrading an explicit full compile-disable (UNSLOTH_COMPILE_DISABLE=1, including device_type.py's pre-Volta setdefault) to "partial", which silently re-enabled compile paths that only guard against "1".
  • Add CPU regression tests in tests/test_loader_compile_disable_preserve.py and update the source-scan regex in tests/test_deepseek_v41_lora_coverage.py.

Verification

  • pytest tests/test_loader_compile_disable_preserve.py tests/test_deepseek_v41_lora_coverage.py tests/test_ci_repo_cpu_shards.py (32 passed, 2 skipped; 13/13 new tests failed pre-fix)
  • pytest tests/test_compile_decode_selection.py tests/test_loader_glob_skip.py tests/test_pre_volta_compile_disable.py (all passed)
  • ruff check, py_compile, and scripts/lint_duplicate_definitions.py clean

@danielhanchen
danielhanchen marked this pull request as ready for review November 23, 2026 11:19
@danielhanchen
danielhanchen self-requested a review as a code owner November 23, 2026 11:19
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T11:23:41.758932Z 76862fd Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 76862fd861

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

@shimmyshimmer
shimmyshimmer merged commit 49dba1a into unslothai:main Nov 23, 2026
danielhanchen added a commit that referenced this pull request Nov 23, 2026
## Summary

`Repo tests (CPU, rest)` fails on `main`:

```
tests/test_loader_compile_disable_preserve.py::test_partial_is_written_only_inside_the_helper
E   assert False
E    +  where False = all(<generator object test_partial_is_written_only_inside_the_helper.<locals>.<genexpr> ...>)
```

## Root cause

The Inkling 2 branch, not the guard. #18773 added
`_set_partial_compile_disable()` to `unsloth/models/loader.py` and
routed every branch that partly disables compile through it, with a
guard that no other code writes `"partial"`. The Inkling 2 branch from
#18812 / #18959 landed alongside it with its own direct write:

```python
if os.environ.get("UNSLOTH_COMPILE_DISABLE", "0") == "0":
    os.environ["UNSLOTH_COMPILE_DISABLE"] = "partial"
```

Besides tripping the guard, that write keeps a value like `true` or
`yes` as it is, and unsloth_zoo only reads `"1"` and `"partial"` as off,
so `UNSLOTH_COMPILE_DISABLE=true` left Inkling 2 compiled. The helper
turns `1` / `true` / `yes` into `"1"` and everything else into
`"partial"`.

## Fix

- `unsloth/models/loader.py`: the Inkling 2 branch calls
`_set_partial_compile_disable()`. Unset or `0` still becomes `partial`,
and `1` still stays fully off.
- `tests/test_loader_compile_disable_preserve.py`: the helper-call count
goes from five branches to six, with Inkling 2 named.

## Testing

- `tests/test_loader_compile_disable_preserve.py` and
`tests/test_inkling2*.py`: 23 passed, 3 skipped.
- With `main`'s `loader.py`, the guard fails (both the direct write and
the helper count).
- Helper mapping checked directly: unset, `0`, `false` -> `partial`;
`1`, `true` -> `1`; `partial` -> `partial`.
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.

3 participants