Skip to content

Lift for_inference's tensor parallel helpers in the return-logits test - #15162

Merged
danielhanchen merged 1 commit into
mainfrom
ci-return-logits-tp-helper
Oct 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-return-logits-tp-helper

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

tests/test_return_logits_survives_for_training.py fails on main (8 of 9 tests) since #15137:

unsloth/models/vision.py:5506: in for_inference
    _refuse_tensor_parallel_for_inference(model)
E   TypeError: 'NoneType' object is not callable

The test pulls FastBaseModel.for_inference / for_training out of vision.py with ast and runs them in a namespace where unknown names resolve to None. It only lifts a hand-kept list of _utils.py helpers. #15137 added the tensor parallel refusal at the top of for_inference (_refuse_tensor_parallel_for_inference, which calls _is_unsloth_tensor_parallel). Neither helper is on that list, so the call hits None. The product code is correct: the refusal is intended, and the real import in vision.py resolves fine. This shows up on any PR whose Repo tests (CPU, rest) shard runs on current main, for example #15159.

Change

  • Keep the explicit list. Then follow the lifted functions into any other top-level _utils.py function they name, transitively. Today that adds exactly the two tensor parallel helpers. The next helper either method gains gets lifted automatically instead of turning into the same NoneType error.
  • test_lifted_for_inference_runs_its_real_helpers: a model carrying _unsloth_tp must make the lifted for_inference raise the real tensor parallel RuntimeError. This proves the harness runs the real guard, not a stand-in.

Verification

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T22:12:25.480105Z 625f689 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 added a commit that referenced this pull request Oct 24, 2026
## Summary


`tests/test_block_cudagraphs_clone.py::test_new_shapes_past_the_cap_skip_graphs`,
added by #15154, fails in the `Repo tests (CPU, rest)` shard (for
example #15162):

```
tests/test_block_cudagraphs_clone.py:108: in test_new_shapes_past_the_cap_skip_graphs
    assert step(16) == {"graphs"}
E   AssertionError: assert set() == {'graphs'}
```

That shard runs with `UNSLOTH_COMPILE_DISABLE=1`. The wrapped block's
`forward` checks `_enabled()` on every call and takes the eager path
when the kill switch is set. So the fake `torch.compile` the test
installs is never called, and it records no call. The product is right:
the kill switch is supposed to win. The test assumed compile was on. It
passes locally with the variable unset and fails with it set to `1`.

## Change

- Same autouse fixture as `tests/test_block_compile.py`: clear
`UNSLOTH_BLOCK_COMPILE`, `UNSLOTH_COMPILE_DISABLE` and
`UNSLOTH_FORCE_FLOAT32` for each test.
- The layer/step setup moved into `_cap_layer_step()`, so a second test
can use it.
- `test_compile_disable_still_bypasses_the_block`: sets the kill switch
after the block is wrapped and checks that the next call skips the
compiled path. This pins down the behaviour the old test tripped over.

## Verification

- `UNSLOTH_COMPILE_DISABLE=0` and `=1`: `6 passed` both ways. On main
the `=1` case is `1 failed, 4 passed`.
- Sabotage 1: with the fixture not autouse, under
`UNSLOTH_COMPILE_DISABLE=1`, `test_new_shapes_past_the_cap_skip_graphs`
fails again with the CI error.
- Sabotage 2: with the `_enabled()` check removed from the block's
`forward`, `test_compile_disable_still_bypasses_the_block` fails.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

The previous review has shown as running for 50 minutes.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 625f689e41

ℹ️ 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 38f52c6 into main Oct 24, 2026
19 of 20 checks passed
@danielhanchen
danielhanchen deleted the ci-return-logits-tp-helper branch October 24, 2026 22:13
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