Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
310 commits
Select commit Hold shift + click to select a range
1038679
Clean up main thread compile cache before python interpreter shuts do…
zcbenz Aug 22, 2026
c7a185a
chore: Check malformed jaccl hostfile that miss rdma in pairs (#4284)
erwinzhang7 Aug 22, 2026
02adf7b
Round mxfp8 block scales up to avoid saturation (#4353)
dhiltgen Aug 23, 2026
7789905
Add support for the __array_namespace_info__ (#4334)
aaishwarymishra Aug 23, 2026
ab3ef95
Stop a failed CUDA graph commit from poisoning the encoder (#4356)
strayberry Aug 23, 2026
7408e68
Fix quantized kernels in JIT build (#4372)
dwijenpatel Aug 23, 2026
d9077d8
Avoid zero work in stride-2 ConvTranspose3d (#4343)
ternaus Aug 23, 2026
451dc87
[CUDA] Ce fused kernel (#3947)
nastya236 Aug 23, 2026
29b61c0
Fix cpu exclusive scan for complex numbers (#4272)
ayaangazali Aug 24, 2026
9d173ff
Support Relocatable CUDA DLLs on Windows (#4382)
dhiltgen Aug 24, 2026
c793734
Use cast_to for fused AsType in compiled Metal kernels (#4351)
katlun-lgtm Aug 24, 2026
9d16475
python: Declare DLPackCompatible protocol members as methods (#4384)
Adityaj0 Aug 24, 2026
a9eed5a
Fix quantizing sliced arrays (#4381)
zcbenz Aug 24, 2026
43d2f06
Fix einsum dropping a trailing empty subscript (#4299)
Adityaj0 Aug 24, 2026
91ac005
Add script to run python tests (#4393)
zcbenz Aug 25, 2026
1f8e74e
Hold GIL in AttachedData destructor (#4391)
zcbenz Aug 25, 2026
bb360b7
Patch bump to 0.32.3 (#4406)
zcbenz Aug 26, 2026
3fbc3ec
Fix scan and sort for a zero-size axis (#4340)
eyupcanakman Aug 26, 2026
e1bb691
python: Add a correction parameter in std and var (#4348)
prady0t Aug 26, 2026
7f2c431
Fix tests/run.py stuck in macOS CI (#4410)
zcbenz Aug 26, 2026
c990a12
chore: Update extension example (#4412)
jagrit06 Aug 26, 2026
d73eb75
Fix sorted gather_qmm NAX row overflow above 32K (#3922)
PhilipJohnBasile Aug 26, 2026
1e2c0ca
Fix deadlock caused by mx.clear_streams() holding GIL (#4413)
aleroot Aug 27, 2026
4978d41
Fix integer pow zeroing a whole SIMD vector on a negative exponent (#…
ayaangazali Aug 27, 2026
5269ba9
Make concurrency cap on load adaptative so that I/O scales with the m…
aleroot Aug 27, 2026
4531b25
Fix pad with an axes subset and negative axes (#4364)
kapellirohith Aug 28, 2026
bbf8a7a
Use sdpa_vector_2pass_1_gqa for GQA size 12 and 16 (#4380)
dudududukim Aug 28, 2026
a3858ec
python: Make axis of put_along_axis optional (#4360)
ayaangazali Aug 28, 2026
94f7459
python: Make axis default to -1 in take_along_axis (#4368)
aaishwarymishra Aug 28, 2026
a124ac0
Propagate NaN in arg reductions (#4291)
atirna Aug 28, 2026
4f8d916
Fix mx.from_fp8 E4M3FN NaN decode with branchless carry (#4376)
saud5150 Aug 28, 2026
7442d5a
Update rules for PR limitation bypass list (#4415)
zcbenz Aug 28, 2026
4abe4eb
[CUDA] Use native events for GPU fence waits (#4401)
strayberry Aug 28, 2026
6782332
Validate GGUF tensor dimensions (#4378)
roshanoss Aug 28, 2026
99e45f7
Fix crash on ellipsis indexing with too many trailing indices (#4396)
Adityaj0 Aug 28, 2026
c899c5a
[CUDA] Cholesky via cuSOLVER (#4208)
sashko-zakharchuk Aug 28, 2026
2550122
python: Fix __setitem__ with negative index preceded by None (#4414)
Adityaj0 Aug 29, 2026
ab552d2
Update nanobind to 3.0.1 (#4417)
XXXXRT666 Aug 29, 2026
3f0bd54
chore: Use normalize_axis_index in scan ops (#4383)
Adityaj0 Aug 29, 2026
d1140e6
python: Add explicit index and bytes support (#4388)
aaishwarymishra Aug 29, 2026
052e77d
docs: fix typo recived -> received (#4424)
vaibhav8a Aug 29, 2026
e64d361
Fix Metal grid sizing for strided scans (#4420)
TheDarkchip Aug 30, 2026
37c26e5
Fix SGD and Adafactor weight decay mutating caller arrays (#4426)
2sumtech Aug 30, 2026
117188c
Widen float16/bfloat16 to float32 in cpu reduce (#4387)
Ved235 Sep 1, 2026
685dba9
Fix sdpa_vector_2pass_1_gqa kernel batch offset for K/V in gqa decode…
dudududukim Sep 2, 2026
f99e916
Make head-dim-256 prefill with array mask run fused NAX kernel (#4416)
dwijenpatel Sep 2, 2026
1c002a8
python: Make unstack return tuple instead of list (#4448)
JasonHonKL Sep 2, 2026
cdf297c
python: Make iter() throw TypeError for 0-dim array (#4425)
simeetnayan81 Sep 2, 2026
3316cbe
Fix save and save_safetensors corrupting a lazily loaded source file …
Cdimoy Sep 2, 2026
90846ad
[Metal] Use hypot for complex ops (#4345)
JasonHonKL Sep 2, 2026
b636898
Add get_array_buffer_size to query buffer size for arrays (#4436)
aleroot Sep 3, 2026
2d27ab0
Add M5 ultra tunings for non-quantized matmuls (#4447)
jagrit06 Sep 5, 2026
ce916db
[CUDA] Fix completion worker busy loop (#4452)
strayberry Sep 6, 2026
3854df9
Fix non transposed affine qmm dispatch logic (#4392)
RohanGautam Sep 7, 2026
fc67b1d
Fix sorted gather_qmm on ragged K (#4009)
erwinzhang7 Sep 7, 2026
27f23d1
Don't restore a thread-affine stream when StreamContext dies on anoth…
michalk8 Sep 7, 2026
bbb3ec2
Fix Pad vjp with an axes subset and negative axes (#4441)
nileshpatil6 Sep 8, 2026
e5e76dd
Fix integer div-by-zero crash in CPU backend (sort, scan, binary ops)…
MarcosAsh Sep 8, 2026
334cfdc
Use 64-bit file seeks on Windows (#4456)
dhiltgen Sep 8, 2026
365bd0f
Use precise::exp in Sigmoid so compiled and eager sigmoid agree (#4461)
pierre427 Sep 8, 2026
5778a97
Use NAX attention for long unmasked D72/D80 inputs (#4455)
wyanzhao Sep 8, 2026
d20319f
Add D512 support to Metal vector attention (#4459)
wyanzhao Sep 8, 2026
ec5f6ff
Add a scoped_env utility for tests (#4474)
zcbenz Sep 8, 2026
cbb4059
[Metal] global scale for qmm (#4458)
nastya236 Sep 8, 2026
e3fcecc
Fix re-entering the same stream context manager (#4478)
michalk8 Sep 9, 2026
24c699e
Leak global CommandEncoder on exit (#4480)
davidkoski Sep 9, 2026
81ba1c6
Update CONTRIBUTING.md (#4469)
zcbenz Sep 10, 2026
a3af4d1
python: Fix bytes() on non-contiguous arrays (#4449)
axiom-of-choice Sep 10, 2026
ae9df56
Break the sibling cycle when an array is released by assignment (#4453)
tudalex Sep 11, 2026
e0a92d9
win: Use DXGI for accurate WDDM VRAM memory budget (#4457)
dhiltgen Sep 11, 2026
ad274a8
Add type hints and docstrings for ALiBi layer (#4472)
Ritabanm Sep 11, 2026
dfe17ba
Fix fp quantized matmul corruption when the quantized dim is not a mu…
kapellirohith Sep 11, 2026
229f5b4
Fix CUDA test synchronization flake (#4490)
dhiltgen Sep 12, 2026
fe9e0f7
ci: Skip bypass list updates in forks (#4495)
XXXXRT666 Sep 14, 2026
3eb822c
Load global scales in qmm_t kernels (#4483)
dhiltgen Sep 14, 2026
8ab5b08
python: Release the GIL when copying Metal DLPack inputs (#4497)
WindChimeRan Sep 14, 2026
d9add9d
Use matrix kernels for global-scale gather_qqmm (#4481)
dhiltgen Sep 14, 2026
8f76a0a
Adding metal kernels for the gated delta nets. (#4020)
tpegolotti Sep 15, 2026
7241f12
Fix jaccl ring all_gather: direction 1 slice was not mirrored (#4443)
Drifter4242 Sep 15, 2026
c948334
Skip Metal-only gated delta kernel tests on other backends(fix CI) (#…
aleroot Sep 16, 2026
59d600b
[CUDA] Add global scale support to gather_qmm (#4507)
dhiltgen Sep 17, 2026
77e1cfb
[BUG][Metal] Deadlock in fence (#4552)
nastya236 Sep 24, 2026
0428241
Fix ordering of complex64 with NaNs (#4519)
louen Sep 25, 2026
84ea22f
Improve metal memory usage for SDPA D256 (#4505)
dhiltgen Sep 25, 2026
073d225
Add support for matrix transpose (#4402)
aaishwarymishra Sep 25, 2026
c0418f6
Improve metal memory usage for SDPA D512 (#4487)
dhiltgen Sep 26, 2026
465b7a5
Support shapeless compilation of scan operations (#4510)
keeeeenw Sep 26, 2026
a2a09fd
[Metal] Gather mm improvement (#4567)
nastya236 Sep 26, 2026
09e67c6
Fix perf regression for upsample `linear` mode align_corners=False (#…
sp4ss Sep 27, 2026
02ce1fb
Add fused Metal kernels for fast.cross_entropy (#4520)
zsun6 Sep 27, 2026
7181620
python: Add missing defaults to tri, tril, triu, gather_mm signatures…
rishabhsai Sep 27, 2026
351e59a
Add Metal SDPA support for D96/V64 (#4499)
wyanzhao Sep 28, 2026
a32f0c3
Raise IndexError for out of bounds axes (#4484)
devangpratap Sep 28, 2026
0a8e18e
Fix floor_divide for integers (#4515)
aaishwarymishra Sep 28, 2026
4fe4d1e
Fix cpu binary ops on large data (#4517)
Prudctual Sep 28, 2026
9eb3e3a
Do not throw from CUDA destructors and avoid implicit default streams…
aleroot Sep 28, 2026
9008944
[Metal] gather_qmm improvement (#4572)
nastya236 Sep 28, 2026
0780da5
Fix floating-point constant precision in compiled kernels (#4511)
Ryan11c Sep 28, 2026
42987b6
chore: Fix assertion in ReduceScatter::eval_cpu (#4557)
ronaldmannak Sep 28, 2026
64ea011
Leak thread local streams on exit in main thread (#4576)
zcbenz Sep 28, 2026
83b976e
Adding VJP for the scaled dot product attention. (#4563)
tpegolotti Sep 29, 2026
b3848e2
python: Add __pos__ support to array (#4488)
aaishwarymishra Sep 29, 2026
e5b4021
Add Python 3.15 and 3.15t support (#4555)
XXXXRT666 Sep 29, 2026
92db340
Add fixed size `unique` operation (#4501)
louen Sep 29, 2026
9b3df2c
Fix normalizing single-element slice with negative stride (#4446)
axiom-of-choice Sep 29, 2026
7916d8b
Patch bump to 0.32.4 (#4582)
zcbenz Sep 29, 2026
9295197
Adding VJP for gated delta net. (#4565)
tpegolotti Sep 29, 2026
ad00ea2
Fix `col_reduce_longcolumn` for negative-stride views (#4529)
mateuuszzzzz Sep 30, 2026
d63f0f9
Clear CUDA errors once reported and raise eval errors in buffer proto…
aleroot Sep 30, 2026
39a182f
Improve pre-M5 metal memory usage for SDPA D512 (#4518)
dhiltgen Sep 30, 2026
4079bec
Fix split data size span (#4540)
michalk8 Sep 30, 2026
adccac1
Re-introduce Array API Tests suite (#4433)
prady0t Sep 30, 2026
a76fbdd
Fix view inside of a vmap (#4586)
michalk8 Sep 30, 2026
174130d
Fix cumsum of a non-contiguous bool (#4590)
michalk8 Sep 30, 2026
238bca6
docs: contraction dtype requirements in matmul/einsum (#4550)
simeetnayan81 Sep 30, 2026
91c83d1
Fixing cooperative tensor build issues on Mac OS 27 (#4594)
tpegolotti Sep 30, 2026
ac8be42
Handle EOF and EINTR in ParallelFileReader::read (#4532)
Ritabanm Sep 30, 2026
9c3d355
Clamp slice bounds when a slice is combined with an array index (#4513)
IshaanPotle Sep 30, 2026
f663614
Fix grouped Conv1d/Conv2d init to use in_channels // groups (#4544)
CodeWithMoin Oct 1, 2026
9c5d569
Fix mx.view misaligned offset (#4585)
michalk8 Oct 1, 2026
2f11bac
[CUDA] Add fp_gather_qmv to optimize gather_qmm (#4508)
dhiltgen Oct 1, 2026
f5cffe9
Fix eval cleanup deadlock by committing GPU streams before waiting (#…
ronaldmannak Oct 1, 2026
aa4096a
Fix shared_buffer_reshape contiguity flags (#4589)
michalk8 Oct 1, 2026
f56ab23
Fix view last axis stride (#4587)
michalk8 Oct 1, 2026
49028fb
Fix empty unsigned sum/prod failing on Metal (#4546)
CodeWithMoin Oct 1, 2026
5c89fa1
[CUDA] Add gather_qmm_rhs_sm80 (#4554)
dhiltgen Oct 1, 2026
99133e9
python: Fix bare ellipsis __setitem__ by squeezing leading singleton …
shaeantoine Oct 1, 2026
6a1b7f7
Fix row/col contiguous flags in view (#4588)
michalk8 Oct 1, 2026
8803e52
Do not cache failed distributed backend initialization (#4558)
ronaldmannak Oct 1, 2026
0840c42
Fix reduction over large arrays (#4549)
nicoloangileri Oct 1, 2026
c63c49d
docs: Correct the export callback type in the guide (#4578)
ssmall256 Oct 2, 2026
10f1161
Fix MultiOptimizer crash when an optimizer's group is empty (#4570)
ishtihoss Oct 2, 2026
34635d4
Fix fft size one (#4591)
michalk8 Oct 2, 2026
908148e
Sanitize '-' in make_template_hash for metal kernel (#4584)
gokay-ai Oct 2, 2026
831164a
Fix as_strided contiguity (#4575)
sofinvalery Oct 2, 2026
2ae29a9
Reject non-aligned pointers when converting to mx.array (#4592)
michalk8 Oct 2, 2026
5ff1905
Fix conjugation in complex VJPs for inverse trig ops, cos, sqrt, and …
devYRPauli Oct 2, 2026
1bed2e2
Fix complex to bool (#4593)
michalk8 Oct 2, 2026
f4232c7
[jaccl] second cable for the mesh (#4607)
nastya236 Oct 2, 2026
2553287
Fix vmap of scatter placing the batch axis wrongly in the updates (#4…
Adityaj0 Oct 2, 2026
0e3ff36
Unroll TK=4 keys per iter in sdpa_vector_2pass_1 (#4596)
Stonesjtu Oct 3, 2026
8c56dd8
Fix CPU float16 SIMD comparison masks (#4602)
crabel99 Oct 4, 2026
d956ba2
Add jvp support for logcumsumexp (#4611)
navthings Oct 4, 2026
65be047
[CUDA] Export CommandEncoder and Device (#4619)
erwinzhang7 Oct 4, 2026
f8aaf49
Use the fast qmv kernel for outputs not divisible by 8 (#4516)
wyanzhao Oct 4, 2026
9503cb7
Fix ResidencySets reading autoreleased error object (#4623)
Brooooooklyn Oct 5, 2026
fa7b5b8
Use the small-channel implicit gemm loader for C_per_group = 8 (#4617)
zsun6 Oct 5, 2026
42c15fe
[CUDA] Reduce floor for fp_gather_qmv (#4620)
dhiltgen Oct 5, 2026
922bd35
Fix default.metallib lookup under swift test with Swift Build (#4527)
heckj Oct 5, 2026
08298bb
Fix metal validation error when passing empty vector (#4622)
aleroot Oct 5, 2026
264c14f
Replace Black formatter with ruff (#4600)
aaishwarymishra Oct 5, 2026
ea7e397
Tune M1 quantized matmul dispatch for six-row large shapes (#4629)
DeadByDawn101 Oct 6, 2026
a59cc23
[metal] Add env var based residency refresh interval (#4633)
dhiltgen Oct 6, 2026
2b2bb49
Promote integer inputs in logcumsumexp (#4625)
vijay-kapse Oct 6, 2026
017e1c3
Fix slicing's non contiguous start (#4599)
michalk8 Oct 7, 2026
f14e6d2
Fix float16 overflow in clip_grad_norm (#4626)
ishtihoss Oct 7, 2026
0b37b0c
Collapse the non sorted axes to pick the contiguous sort kernel (#4366)
kapellirohith Oct 7, 2026
9cb9c06
Fix 32 bit dispatch grid overflow in Metal reductions (#4437)
Lyxot Oct 7, 2026
34d14f9
Fix gpu boolean masking in 0 dim array (#4635)
aaishwarymishra Oct 7, 2026
9fcc72b
Fix vmap of an inverse real FFT to an odd length (#4637)
vijay-kapse Oct 7, 2026
53fbe56
Fix cross-process race in CPU compile cache (#4638)
MarcosAsh Oct 7, 2026
6553c47
Update acknowledgments for past pinv contribution (#4645)
adi-dhulipala Oct 7, 2026
5dbe999
Fix foreign buffer ownership (#4634)
michalk8 Oct 8, 2026
9702959
Add MLX_CONV_WINOGRAD switch to disable winograd for conv2d (#4639)
ishaanzee Oct 8, 2026
494c8a6
Keep split-K quantized matmul partials in float32 (#4641)
mattt Oct 8, 2026
3c40e8f
Thin N GEMM kernels (#4640)
Isalia20 Oct 8, 2026
e0408d4
Add 1-bit affine quantization support (Metal) (#3161)
khosravipasha Oct 9, 2026
4089fd5
Update Metal Complex division in numpy style to avoid overflow condit…
aaishwarymishra Oct 9, 2026
cd30780
Fix pickle bfloat16 strides (#4649)
michalk8 Oct 9, 2026
95f8533
Fix metal negative stride index in masked_scatter/scatter/SDPA mask/s…
michalk8 Oct 9, 2026
0d8236f
Fix missing break binary bool (#4651)
michalk8 Oct 9, 2026
8d5bdbc
Fix cpu binary_op_dispatch_dims on large data (#4648)
Prudctual Oct 9, 2026
2654664
Add FloorDivide primitive for integer floor division (#4642)
CodeAndCanvas728 Oct 9, 2026
789be76
[Metal] Fix SDPA max threadgroup for M1/M2 generation (#4643)
dhiltgen Oct 9, 2026
77bf1fa
Fix incorrect output mask computation in `mx.block_masked_mm` (#4652)
michalk8 Oct 9, 2026
a87691d
Add thin M GEMM dispatch (#4654)
Isalia20 Oct 9, 2026
43f5eaa
Fix Python dtpye -> mlx conversion narrowing (#4656)
michalk8 Oct 9, 2026
84a72e3
Fix input/output scalar merging in compile (#4658)
michalk8 Oct 9, 2026
99f109b
Validate .npy shape in mlx/io/load.cpp (#4657)
SounLabs Oct 9, 2026
c06ce82
Replace "pull_request_target" event with "pull_request" in update_byp…
zcbenz Oct 10, 2026
9ab7999
[CUDA] Only count consecutive misses in the LRUCache thrashing check …
ddalcu Oct 10, 2026
0ab821b
Fix conv input gradient shape with uneven or large padding (#4662)
MarcosAsh Oct 10, 2026
0fdcdc0
Fix missing stream in layer_norm and sdpa fallbacks (#4663)
AkshayShah03 Oct 10, 2026
af9a592
Fix direct CPU conv writing past output (#4668)
SashaMIT Oct 10, 2026
19ffe23
Add stft and istft to mlx.core.fft (#3639)
eyupcanakman Oct 10, 2026
06eb748
Fix lost rank output in the distributed launcher (#4615)
tc3oliver Oct 10, 2026
838d61c
Fix split-K test compatibility on M5, M6 (#4677)
magnuslundstedt Oct 12, 2026
c7bf1ca
Fix signedness warning in quantized Metal tail bounds check (#4675)
jrp2014 Oct 12, 2026
0512aa6
Fix batched row count mismatch in metal qvm_split_k (#4673)
Prudctual Oct 12, 2026
8295d5e
Fix metal conv bounds checks and integer overflows (#4672)
Prudctual Oct 12, 2026
388f227
python: Make arctan2/radians/degrees support scalar inputs (#4679)
SleepAviator Oct 12, 2026
243bdf0
Fix missing add_temporary in pad_gpu/fill_gpu (#4660)
ronaldmannak Oct 13, 2026
588553c
Enable non-transposed NAX gather_qmm_rhs (#4684)
Lyxot Oct 14, 2026
bb3e2d3
Add Metal extension build support (#4004)
XXXXRT666 Oct 14, 2026
70cbe18
Adding minmax method to MLX to follow Numpy/Jax API (#4674)
aaishwarymishra Oct 14, 2026
bebd642
Fix missing stream in gather matmul indices cast (#4687)
petrukha-ivan Oct 14, 2026
36969c0
[BUG] Metal fence deadlock (#4689)
nastya236 Oct 14, 2026
9cb7f77
Patch bump to 0.32.5 (#4707)
nastya236 Oct 16, 2026
7c8a411
docs: Publishing a New Release (#4691)
zcbenz Oct 16, 2026
10e0f83
ci: Run update_bypass_list on push instead of pull_request (#4671)
zcbenz Oct 16, 2026
a82b8fb
[CUDA] Run the vector SDPA kernels at head_dim 256 (#4698)
yanghaojin Oct 16, 2026
e4eaae2
[CUDA] Fix grouped gemm with large data (#4696)
yanghaojin Oct 16, 2026
5c582ab
Fix conv2d OOB reads for partial output-channel tiles (#4653)
navthings Oct 16, 2026
b6642e6
docs: MetalLibrary in custom extension guide (#4701)
XXXXRT666 Oct 16, 2026
c60afdd
[Metal] Fix SDPA f16/f32 d512 max threadgroup for M1/M2 generation (#…
dhiltgen Oct 19, 2026
0390bd8
Add float16 head_dim 256 TK=1 SDPA vector kernel for M1/M2 (#4719)
jmmarkiewicz Oct 19, 2026
9cb9282
Allow configuring the CPU JIT cache directory (#4714)
cerisier Oct 19, 2026
f93902c
Make `broadcast_arrays` return a tuple (#4713)
prady0t Oct 19, 2026
f41bec7
Fix unaligned scalar reads and oversized contiguous buffer views (#4721)
aleroot Oct 19, 2026
bff1022
[Metal] Add staged affine_qmm_t_nax kernels with split-k (#4682)
wyanzhao Oct 20, 2026
52a6c23
[Metal] Add fast route for dequantizing fp4 to half in fp_qmm_t (#4709)
dhiltgen Oct 21, 2026
c6abf0d
[Metal] Add qmv_mma/qmv_nax kernels for 6-16 rows with large N/K (#4712)
dhiltgen Oct 22, 2026
3c3750f
Merge upstream ml-explore/mlx main c6abf0dbb (2026-10-22)
davidtai Oct 22, 2026
6ddbfb8
docs(forkdiff): move the base to upstream c6abf0dbb after the merge
davidtai Oct 22, 2026
e5b6550
fix: repair the merge in the quantized kernels and the lint
davidtai Oct 22, 2026
780b57e
test: follow the upstream allocator and gather_qmm APIs in fork tests
davidtai Oct 22, 2026
dbf463f
fix(cpu): floor_divide of min by -1 must not trap
davidtai Oct 22, 2026
089acfe
Compute the JACCL ring wire offsets in 64 bits
davidtai Oct 22, 2026
4588237
Compute the vector SDPA query layout check in 64 bits
davidtai Oct 23, 2026
7cfbc6a
Fix `mx.take`'s negative indices (#4729)
michalk8 Oct 23, 2026
81770e8
Fix normal loc scale shape (#4730)
michalk8 Oct 23, 2026
59cf1ad
Fix zero-copy numpy arrays dtype mismatch (#4731)
michalk8 Oct 23, 2026
aaec1b6
ci: skip the 4 GiB reduce test where the runner cannot hold it
davidtai Oct 23, 2026
007478f
Widen affine qmv_wide row tiles to 8 (#4728)
Ambisphaeric Oct 23, 2026
8e88e50
Fix/padding jvp vjp (#4736)
michalk8 Oct 23, 2026
1f7e906
fix: qqmm refuses a global scale on the CPU; adapt GPU-path tests
davidtai Oct 23, 2026
7eb793d
ci: add a temporary diagnostic for the CPU NaN; reword the 4 GiB skip
davidtai Oct 23, 2026
5f76e11
ci: move the CPU NaN diagnostic to its own short job
davidtai Oct 23, 2026
11b8615
ci: install numpy for the temporary NaN diagnostic job
davidtai Oct 23, 2026
c9c8ed5
Fix data race in distributed ring on pending send/recv lists (#4737)
Shakhtar-Sankur Oct 23, 2026
06122f8
Use data_size for gather/scatter large-offset checks (#4724)
begcdn Oct 23, 2026
355dcff
fix(cpu): clear C before the BLAS matmul when beta is 0
davidtai Oct 23, 2026
cb73247
fix(cpu): clear C at every BLAS gemm call with beta 0
davidtai Oct 23, 2026
27f2a2c
ci: build once and run the Metal and CPU test passes in parallel
davidtai Oct 23, 2026
53c1870
[CUDA] Fix gather_qmm for experts past 2^32 weight elements (#4738)
IamCooller Oct 23, 2026
eda4d0c
ci: split the long CPU test files and skip cache saves with no misses
davidtai Oct 23, 2026
2268806
ci: key the build caches on compiler versions, not the runner image
davidtai Oct 23, 2026
699649d
Add array::is_uniquely_referenced for the fork C API
davidtai Oct 23, 2026
36f043e
fix: async_eval must not throw a stream task error
davidtai Oct 23, 2026
afc03c5
Fix GPU pad for outputs larger than 2^31 elements (#4744)
tivris Oct 23, 2026
ef2954d
ci: format python_shards.py with the pinned ruff
davidtai Oct 23, 2026
7448e09
Merge sync/upstream-2026-10-22 (36f043ec) into ci/parallel-tests
davidtai Oct 23, 2026
b72420d
ci: run the Python tests in 2 GPU and 3 CPU shards
davidtai Oct 23, 2026
a8c2635
ci: give the NAX kernels Metal cache hits and lighten CPU shard 0
davidtai Oct 23, 2026
249efa1
Merge #39: CI builds once and runs the tests in parallel shards
davidtai Oct 23, 2026
3f53ff3
Merge upstream ml-explore/mlx main afc03c511 (2026-10-23)
davidtai Oct 23, 2026
83dbdb0
docs(forkdiff): move the base to upstream afc03c511
davidtai Oct 23, 2026
7e044d9
test: floor_divide and divmod of float16/bfloat16 in the rounding window
davidtai Oct 23, 2026
790f01b
fix: compute float16 and bfloat16 floor divide in float32
davidtai Oct 23, 2026
842d49a
Merge main (squash of #38) into fix/half-floor-divide
davidtai Oct 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,27 @@ def:
- "mlx/scheduler.cpp"
- "mlx/transforms.cpp"
- "tests/scheduler_tests.cpp"
- title: "half and bfloat16 floor divide in float32"
description: |
Upstream computes float16 and bfloat16 `floor_divide`, and the `divmod` quotient, as
`floor(a / b)` in the half type. The quotient is rounded to the half type before the
floor, so a true quotient that is less than half an ulp below an integer n rounds
to n, and the result is n instead of n - 1. numpy's float16 divmod computes in
float32 from `fmod` (`npy_divmodf`) and gives n - 1. Upstream's unseeded
`test_divmod` fails for this reason in about 4% of runs per device. The fork now
computes these two operations for float16 and bfloat16 in float32 with the same
method as `npy_divmodf` (`mod = fmod(a, b)`, `div = (a - mod) / b`, then a floor
with the sign correction), and rounds the result once to the output type: in the
Metal `FloorDivide` (which `DivMod` uses), in the CPU scalar and SIMD
`floor_divide`, and in the CPU `DivMod`. float32, float64 and integer paths do not
change. `test_floor_divide_half_rounding_window` uses pairs in the rounding window
and compares with numpy on the CPU and the GPU. The CUDA kernels do not change; no
workflow in this fork builds CUDA.
globs:
- "mlx/backend/metal/kernels/binary_ops.h"
- "mlx/backend/cpu/simd/base_simd.h"
- "mlx/backend/cpu/simd/accelerate_simd.h"
- "mlx/backend/cpu/binary.cpp"
- title: "Fork tooling"
description: |
The fork deletes the upstream workflows that cannot run here: the PyPI release build,
Expand Down
20 changes: 16 additions & 4 deletions mlx/backend/cpu/binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,23 @@ void DivMod::eval_cpu(
return std::make_pair(q, r);
};
auto float_op = [](auto x, auto y) {
auto r = std::fmod(x, y);
if (r != 0 && (r < 0) != (y < 0)) {
r += y;
using T = decltype(x);
if constexpr (simd::is_half_v<T>) {
// Compute in float32 and round once. See exact_floor_divide.
float xf = static_cast<float>(x);
float yf = static_cast<float>(y);
float r = std::fmod(xf, yf);
if (r != 0 && (r < 0) != (yf < 0)) {
r += yf;
}
return std::make_pair(T(simd::exact_floor_divide(xf, yf)), T(r));
} else {
auto r = std::fmod(x, y);
if (r != 0 && (r < 0) != (y < 0)) {
r += y;
}
return std::make_pair(std::floor(x / y), r);
}
return std::make_pair(std::floor(x / y), r);
};

dispatch_all_types(out_a.dtype(), [&](auto type_tag) {
Expand Down
8 changes: 8 additions & 0 deletions mlx/backend/cpu/simd/accelerate_simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ Simd<T, N> floor_divide(Simd<T, N> a, Simd<T, N> b) {
return q;
} else if constexpr (is_complex<T>) {
return a / b;
} else if constexpr (is_half_v<T>) {
// See exact_floor_divide in base_simd.h.
Simd<T, N> q;
for (int i = 0; i < N; ++i) {
q[i] = T(exact_floor_divide(
static_cast<float>(a[i]), static_cast<float>(b[i])));
}
return q;
} else {
return floor(divide(a, b));
}
Expand Down
29 changes: 29 additions & 0 deletions mlx/backend/cpu/simd/base_simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,33 @@ Simd<T, 1> divide(Simd<T, 1> a_, Simd<T, 1> b_) {
return a / b;
}

// The floor of a / b, computed as numpy's npy_divmodf does: from fmod, so the
// quotient is not rounded before the floor. float16 and bfloat16 use it in
// float32: floor(a / b) in the half type rounds a quotient that is just below
// an integer up to that integer.
inline float exact_floor_divide(float a, float b) {
if (b == 0) {
return a / b;
}
float mod = std::fmod(a, b);
float div = (a - mod) / b;
if (mod != 0 && ((b < 0) != (mod < 0))) {
div -= 1.0f;
}
if (div == 0) {
return std::copysign(0.0f, a / b);
}
float floordiv = std::floor(div);
if (div - floordiv > 0.5f) {
floordiv += 1.0f;
}
return floordiv;
}

template <typename T>
constexpr bool is_half_v =
std::is_same_v<T, float16_t> || std::is_same_v<T, bfloat16_t>;

template <typename T>
Simd<T, 1> floor_divide(Simd<T, 1> a_, Simd<T, 1> b_) {
T a = a_.value;
Expand All @@ -243,6 +270,8 @@ Simd<T, 1> floor_divide(Simd<T, 1> a_, Simd<T, 1> b_) {
return q;
} else if constexpr (is_complex<T>) {
return a / b;
} else if constexpr (is_half_v<T>) {
return T(exact_floor_divide(static_cast<float>(a), static_cast<float>(b)));
} else {
return floor(divide(a_, b_));
}
Expand Down
30 changes: 29 additions & 1 deletion mlx/backend/metal/kernels/binary_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ struct Add {
}
};

// The floor of x / y, computed as numpy's npy_divmodf does: from fmod, so the
// quotient is not rounded before the floor. float16 and bfloat16 use it in
// float32: floor(x / y) in the half type rounds a quotient that is just below
// an integer up to that integer.
inline float exact_floor_divide(float x, float y) {
if (y == 0) {
return x / y;
}
float mod = metal::fmod(x, y);
float div = (x - mod) / y;
if (mod != 0 && ((y < 0) != (mod < 0))) {
div -= 1.0f;
}
if (div == 0) {
return metal::copysign(0.0f, x / y);
}
float floordiv = metal::floor(div);
if (div - floordiv > 0.5f) {
floordiv += 1.0f;
}
return floordiv;
}

struct FloorDivide {
template <typename T>
metal::enable_if_t<metal::is_integral_v<T> & !metal::is_signed_v<T>, T>
Expand All @@ -31,7 +54,12 @@ struct FloorDivide {
}
template <typename T>
metal::enable_if_t<!metal::is_integral_v<T>, T> operator()(T x, T y) thread {
return floor(x / y);
if constexpr (
metal::is_same_v<T, half> || metal::is_same_v<T, bfloat16_t>) {
return static_cast<T>(exact_floor_divide(float(x), float(y)));
} else {
return floor(x / y);
}
}
template <>
complex64_t operator()(complex64_t x, complex64_t y) thread {
Expand Down
66 changes: 66 additions & 0 deletions python/tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3960,6 +3960,72 @@ def test_outer(self):
np.outer,
)

def test_floor_divide_half_rounding_window(self):
# Pairs whose true quotient is just below an integer n. Rounded to
# float16 or bfloat16, that quotient becomes n, so floor(a / b) in the
# half type gives n. The floor of the exact quotient is n - 1, which
# is what numpy's float16 divmod gives.
def window_pairs(bits):
# bits: stored mantissa bits (10 for float16, 7 for bfloat16).
pairs = []
for k in range(1, 2**bits):
b = 1.0 + k * 2.0**-bits
for n in range(2, 24):
exact = n * b
if bits == 10:
a = float(np.float16(exact))
if a > exact:
a = float(np.nextafter(np.float16(a), np.float16(0)))
else:
# Keep the top 16 bits of the float32 value: the
# largest bfloat16 value at or below it.
f = np.array([exact], dtype=np.float32).view(np.uint32)
a = float((f & np.uint32(0xFFFF0000)).view(np.float32)[0])
if a == exact:
continue
q = a / b
ulp = 2.0 ** (math.floor(math.log2(q)) - bits)
if 0 < n - q < ulp / 4:
pairs.append((a, b))
if len(pairs) == 24:
return pairs
return pairs

devices = [mx.cpu]
if mx.metal.is_available():
devices.append(mx.gpu)
for dtype, bits in ((mx.float16, 10), (mx.bfloat16, 7)):
pairs = window_pairs(bits)
self.assertGreater(len(pairs), 8)
av = [a for a, _ in pairs]
bv = [b for _, b in pairs]
expected_q = np.floor_divide(np.array(av), np.array(bv))
if dtype == mx.float16:
np_q, np_r = np.divmod(
np.array(av, np.float16), np.array(bv, np.float16)
)
self.assertEqual(np_q.astype(np.float64).tolist(), expected_q.tolist())
for device in devices:
with self.subTest(dtype=dtype, device=device):
a = mx.array(av, dtype)
b = mx.array(bv, dtype)
self.assertEqual(a.astype(mx.float32).tolist(), av)
self.assertEqual(b.astype(mx.float32).tolist(), bv)
for q in (
mx.floor_divide(a, b, stream=device),
mx.divmod(a, b, stream=device)[0],
):
self.assertEqual(
q.astype(mx.float32).tolist(), expected_q.tolist()
)
q, r = mx.divmod(a, b, stream=device)
r = np.array(r.astype(mx.float32))
if dtype == mx.float16:
self.assertEqual(r.tolist(), np_r.astype(np.float32).tolist())
self.assertTrue(np.all((r >= 0) & (r < np.array(bv))))
q = np.array(q.astype(mx.float32), np.float64)
self.assertTrue(np.allclose(q * np.array(bv) + r, av))

def test_divmod(self):
# A few sizes for the inputs with and without broadcasting
sizes = [
Expand Down
Loading