Skip to content

Resolve MLX integer arguments to Python ints for MLX 0.32.2 - #2424

Merged
jessegrabowski merged 8 commits into
pymc-devs:mainfrom
jessegrabowski:mlx-static-int-args
Sep 18, 2026
Merged

jessegrabowski merged 8 commits into
pymc-devs:mainfrom
jessegrabowski:mlx-static-int-args

Conversation

@jessegrabowski

Copy link
Copy Markdown
Member

The MLX Reshape, Sort/ArgSort and Pad dispatches now pass their shape, axis and pad_width arguments as Python ints. MLX 0.32.2 upgraded nanobind and stopped accepting mx.array where its API takes int or Sequence[int], so every reshape, sort and pad raised TypeError on that version. Constant arguments are resolved once at funcify time, and symbolic ones are converted at call time through the existing coerce_to_int path from the Alloc dispatch.

A symbolic shape, axis or pad_width still cannot be used under mx.compile, which is the default linker setting. That case raises the same MLX compilation limitation error Alloc already raises, now worded for all of these arguments.

ArgSort on MLX now returns int64. mx.argsort returns uint32 while the Op declares int64.

CI no longer pins mlx<0.32. The eigh test compares eigenvectors up to column sign, since 0.32.2 flips them relative to numpy.

Closes #2386. Closes #2391. Closes #2392. Supersedes #2395, #2398 and #2400.

jessegrabowski and others added 6 commits September 18, 2026 16:38
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
mx.argsort returns uint32 while the Op declares int64.
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
@ricardoV94

Copy link
Copy Markdown
Member

ArgSort on MLX now returns int64. mx.argsort returns uint32 while the Op declares int64.

Cast at the end in the dispatch?



@mlx_funcify.register(SortOp)
def mlx_funcify_Sort(op, node, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort is still like old join with symbolic axis? We should open an issue to make it static in the Op

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessegrabowski
jessegrabowski merged commit 6ac49d8 into pymc-devs:main Sep 18, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mlx

Projects

None yet

2 participants