Skip to content

Inkling 2: partly disable compile through the shared helper - #19073

Merged
danielhanchen merged 1 commit into
mainfrom
fix/inkling2-partial-compile-via-helper
Nov 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/inkling2-partial-compile-via-helper

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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:

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@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-23T13:37:44.100613Z 3ceaf8a 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3ceaf8ab3b

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

@danielhanchen
danielhanchen merged commit 892d9fb into main Nov 23, 2026
@danielhanchen
danielhanchen deleted the fix/inkling2-partial-compile-via-helper branch November 23, 2026 13:39
danielhanchen added a commit that referenced this pull request Nov 23, 2026
…le helper (#19133)

## Problem

Two tests are broken on `main`.

1.
**`tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding`**
is red in `Repo tests (CPU, rest-2)` for every PR based on `main`, for
example #19122:

   ```
Left contains one more item: 'tests/test_inkling2_support.py:633:
read_text()'
   ```

#19016 added `(_ROOT / "unsloth" / "save.py").read_text()`. It reads a
checked-in file with the platform default encoding, which breaks on
Windows as soon as `save.py` gains a non-ASCII byte. The guard is right
and the new line is wrong.

2.
**`tests/test_inkling2_support.py::test_fastmodel_keeps_inkling2_eager_unless_told_otherwise`**
fails wherever the file runs:

   ```
assert re.search('if os\\.environ\\.get\\("UNSLOTH_COMPILE_DISABLE",
"0"\\) == "0": ...', body)
   AssertionError: None
   ```

It still pins the inline assignment that #19073 replaced with the shared
`_set_partial_compile_disable()` helper. CI does not show it yet: the
file skips below transformers 5.24, and the HF=latest legs are held
below 5.24. It fails locally on 5.24.0, so it would turn red as soon as
that cap lifts.

## Fix

Tests only, in `tests/test_inkling2_support.py`:

- Both reads of checked-in source pass `encoding = "utf-8"`:
  - the `save.py` read the guard flags;
- the loader source read through `__file__`, which the guard does not
see.
- The eager-compile test now pins the current shape:
  - the Inkling 2 branch calls `_set_partial_compile_disable()`;
  - the helper sets `partial` from unset, `0` or `partial`;
- the helper keeps a full disable (`1`, `true`) as `1`, so an explicit
user choice is still left alone.

## Verification

| Check | Result |
| --- | --- |
| `test_source_read_encoding.py`, `main` | 1 failed |
| `test_source_read_encoding.py`, this branch | 16 passed |
| `test_inkling2_support.py`, transformers 5.24.0, `main` | 1 failed, 41
passed |
| `test_inkling2_support.py`, transformers 5.24.0, this branch | 42
passed |
| `test_inkling2_support.py`, transformers 5.17 | module skipped as
before |

Sabotage, each with only the product line changed:

- Drop the helper call from the Inkling 2 branch in `loader.py`: the
test fails on the call check.
- Make the helper always set `partial`: the test fails with `assert
'partial' == '1'` for a full disable.
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