Skip to content

Keep the MLX inference test stub neutral for every helper zoo enters around a model - #12548

Merged
danielhanchen merged 1 commit into
mainfrom
studio/mlx-inference-stub-covers-zoo-helpers
Oct 2, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio/mlx-inference-stub-covers-zoo-helpers

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

unslothai/unsloth-zoo#1541 (merged 2026-10-02 13:15 UTC) added nax_quantized_linear to the helpers unsloth_zoo/mlx/generate.py imports from .inference and enters around the model during generation. Since then the macOS dispatch job fails on every unsloth PR that runs it (first seen on #12530):

FAILED tests/test_mlx_inference_backend.py::test_a_vision_reply_stopped_partway_reports_the_tokens_it_actually_used
ImportError: cannot import name 'nax_quantized_linear' from 'unsloth_zoo.mlx.inference' (unknown location)

studio/backend/tests/test_mlx_inference_backend.py has an autouse fixture that replaces unsloth_zoo.mlx.inference with a stub holding only the six fused_* helpers as contextlib.nullcontext, so the real-model tests generate without the fusions. Any helper zoo adds to that import list is missing from the stub. The product is fine; the stub was too narrow.

Change

  • The stub gets a module __getattr__ that answers any other public name with contextlib.nullcontext, the same neutral helper the fused_* names already get. Names starting with fused_ and private names are not answered, so test_mlx_missing_inference_export_keeps_native, which deletes a fused helper to simulate an older zoo, still sees it missing.
  • test_the_stub_answers_every_helper_zoo_imports_from_inference reads every from .inference import ... / from unsloth_zoo.mlx.inference import ... in the installed unsloth_zoo/mlx/*.py with ast (without importing zoo, which needs an accelerator) and asserts the stub answers each name. It skips when zoo's source is not available.
  • test_an_unknown_zoo_helper_is_neutral_but_a_deleted_fusion_stays_missing pins both halves of the fallback.

Verification

Linux, against unsloth-zoo main:

Variant Result
this PR, whole file 277 passed, 111 skipped (main: 275 passed, 111 skipped)
__getattr__ fallback removed both new tests fail
test_mlx_missing_inference_export_keeps_native (6 cases) pass

The failing real-model test only runs on Apple Silicon, so the macOS dispatch job on this PR is the end-to-end check.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 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-02T17:15:10.250427Z 1c6af79 Manual request
🔒 Security Review ⚠️ Failed 2026-10-02T17:11:56.024215Z 1c6af79 PR opened
ℹ️ 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. More of your lovely PRs please.

Reviewed commit: 1c6af7919f

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

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