Repository navigation
MLX backend tests: answer zoo's _fusion_modules in the inference stub - #12783
Conversation
unsloth_zoo #1565 made mlx/generate.py import _fusion_modules from mlx.inference and call tuple(_fusion_modules(model, None)). The stub refuses private names, so the guard added in #12700 failed on Linux (the stub cannot answer _fusion_modules) and every macOS vision test raised ImportError in the dispatch job (#12778). It is a plain function, not a scope, so the stub carries zoo's three-line body in PLAIN_HELPERS, the call-shape replay calls it instead of entering it, and a new test fails if the copy drifts from zoo's body.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32b61e9ddc
ℹ️ 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".
| continue | ||
| ours = ast.parse(textwrap.dedent(inspect.getsource(helper))).body[0] | ||
| ours_body, zoo_body = ( | ||
| [ast.dump(n) for n in f.body if not isinstance(n, ast.Expr)] for f in (ours, zoo[name]) |
There was a problem hiding this comment.
Compare non-docstring expression statements
If the upstream helper gains a bare call or other expression statement, this filter removes that statement from both AST bodies, so the new drift guard can pass even though the local copy omits upstream behavior. Ignore only the leading string-literal docstring rather than every ast.Expr, so changes such as validation, cache priming, or logging calls are detected.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. Fixed in a9820a9: only a leading string-literal docstring is dropped. Adding a bare logger.debug(...) call to zoo's _fusion_modules now fails the body check.
Filtering every ast.Expr also hid bare calls, so zoo adding a log line or other call to _fusion_modules would have passed. Only a leading string literal is ignored now.
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
The macOS MLX
dispatchjob fails on #12778 and on any PR running it against current zoo main:The second line is the guard #12700 added, which caught this on Linux too.
Cause
unslothai/unsloth-zoo#1565 (reuse module discovery across generation fusion scopes) made
mlx/generate.pyimport_fusion_modulesfrommlx.inferenceand calltuple(_fusion_modules(model, None)). That is correct in zoo. The test file replacesunsloth_zoo.mlx.inferencewith a stub whose__getattr__answers public helpers with a neutral scope and refuses private names, so the realgenerate.pycannot import it._fusion_modulesis also not a scope but a plain function that returns modules, so the neutral scope would be the wrong stand-in even if it were allowed.Change
PLAIN_HELPERS = {"_fusion_modules": ...}carries zoo's three-line body, and the stub sets each one explicitly. Private names stay refused otherwise.test_the_stub_accepts_every_call_zoo_makes_to_an_inference_helper) calls a plain helper with the call's argument shape instead of entering it as a context manager.test_each_plain_helper_stub_matches_zoos_bodycompares the stub's body to zoo's by AST, so the copy cannot silently drift.Verification
ce57159on the path,test_mlx_inference_backend.pyon main has 2 failures (the guard and the replay); this branch: 289 passed, 111 skipped.named_modulestomodules) fails the new body-match test.