Call MLX linalg ops directly on batched inputs instead of mx.vmap - #2425
Merged
jessegrabowski merged 4 commits intoSep 18, 2026
Merged
Conversation
ricardoV94
approved these changes
Sep 18, 2026
ricardoV94
left a comment
Member
There was a problem hiding this comment.
Can we open an issue with them to implement the vmap rules for these on MLX. Silly to have to patch around it.
Member
|
Add other PR as co-author? |
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
Co-authored-by: guillaume-osmo <guillaume@osmo.ai>
jessegrabowski
force-pushed
the
mlx-natively-batched-linalg
branch
from
September 18, 2026 09:14
efa6548 to
4362114
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
funcify_Blockwiseon MLX now calls a core function directly when that function setsnatively_batched = True, after broadcasting the inputs to the common batch shape. Before, everyBlockwisewent through nestedmx.vmap. Everymx.linalgdispatch sets the flag, the same way numba's core functions sethandles_out.mx.vmaphas no rule for theLUFandQRFprimitives, so batchedsolve,lu,lu_factor,qr,detandslogdetraised. Its rule forsolve_triangularcallslinalg::invwith the triangular flags dropped, so a batchedsolve_triangularorcho_solvereturned the full solve with nothing raised.The solve dispatches expand a vector
bto a column and squeeze it back.mx.linalg.solveonly special-cases a 1-db, and a batched vector rhs is 2-d.PivotToPermutationsstays onmx.vmap. It is a hand-written scatter loop with nomx.linalgequivalent.The two
test_mlx_eighfailures on this branch are the MLX 0.32.2 eigenvector sign flip that #2424 fixes.Closes #2385. Supersedes and closes #2399.