Skip to content

Precision conflict test: lift mapper.py helpers (red since #18061) - #18096

Merged
danielhanchen merged 1 commit into
mainfrom
ci-precision-test-lift-mapper
Nov 17, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-precision-test-lift-mapper

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

tests/test_optimized_precision_conflicts.py has been red on main (19 failed, both the rest and studio CPU shards) since #18061 (c0ef23b).

Cause

The loader fixture runs the real FastLanguageModel.from_pretrained body in a stub namespace. It lifts the loader.py helpers and the .loader_utils functions the method calls, but nothing from other sibling modules. #18061 made from_pretrained call bf16_repo_loads_16bit, imported from .mapper, so every case now dies with NameError: name 'bf16_repo_loads_16bit' is not defined before reaching the precision checks.

The loader change is correct; the harness just did not know about .mapper.

Fix

_loader_utils_functions takes the module name, and the fixture lifts real definitions from each module in _LIFTED_MODULES = ("loader_utils", "mapper"). Only functions that from_pretrained both imports and calls are lifted, and explicit stubs still win, as before. A later helper added to mapper.py is picked up without touching the test.

Verification

  • main: 19 failed (NameError).
  • this branch: 19 passed.
  • Sabotage: with _LIFTED_MODULES = ("loader_utils",) the file goes back to 19 failed.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T06:45:13.572484Z e76fd29 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. Nice work!

Reviewed commit: e76fd29be9

ℹ️ 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 2ebf057 into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the ci-precision-test-lift-mapper branch November 17, 2026 06:51
danielhanchen added a commit that referenced this pull request Nov 17, 2026
… -bf16 check by its new call (10 failures since #18061) (#18110)

`tests/python/test_loader_resolution_reporting.py` has 10 failures on
main in the CPU `studio` shard since #18061 (seen on the staging runs of
#18084 and #18087):

```
unsloth/models/loader.py:1555: in <module>
    if bf16_repo_loads_16bit(model_name, load_in_16bit):
E   NameError: name 'bf16_repo_loads_16bit' is not defined
test_adapter_base_resolution_updates_report_before_base_config_load[*]
E   StopIteration
```

This is the same root cause as #18096, in a second harness that test did
not cover.

## Cause

The test runs slices of the real `from_pretrained` bodies in a
hand-built scope. #18061 moved the inline
`model_name.lower().endswith("-bf16") and (...)` check into
`mapper.bf16_repo_loads_16bit`, which is correct, but:

- the scopes do not define `bf16_repo_loads_16bit`, so 8 cases die with
`NameError`;
- the adapter test found the end of its slice by the `if
model_name.lower().endswith(...)` statement in the `is_peft` block,
which no longer exists, so `next()` raises `StopIteration`.

## Fix

- `_mapper_function` lifts the real `bf16_repo_loads_16bit` out of
`mapper.py` by AST (the file deliberately avoids importing unsloth), and
each scope gets it, so the check runs for real instead of being stubbed.
- `_is_bf16_check` finds the slice end by either form (the helper call
or the old inline check).

## Verification

- main: 10 failed, 2 passed.
- this branch: 12 passed.
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