Skip to content

Sync upstream ml-explore/mlx-swift main (35c10b4) - #26

Merged
solderzzc merged 4 commits into
mainfrom
sync/upstream-35c10b4-merge
Oct 17, 2026
Merged

solderzzc merged 4 commits into
mainfrom
sync/upstream-35c10b4-merge

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Real merge of upstream main (3 commits: ml-explore#501, ml-explore#502, ml-explore#486); no conflicts. Same content as the bot PR #25, but from a branch that runs CI.

🤖 Generated with Claude Code

ShankyShako and others added 4 commits October 16, 2026 09:42
…lore#501)

Fix leak when `_updateInternal` replaces an array with siblings

`_updateInternal` assigned the new array with `mlx_array_set`, a C++ copy assignment that skips `array::~array()`. That destructor breaks the cycle between sibling outputs of a multi-output primitive. As a result, `Module.update(parameters:)` orphaned the init graph on every model load. This happened, for example, with a freshly built `QuantizedLinear` whose unevaluated random init weight is an output of `Quantize`.

Now the code copies into a new handle and then frees the old one, so the destructor runs. Copying before freeing also keeps the contents intact when an array is passed to itself (`a._updateInternal(a)`), which the sharding path reaches.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fix asArray crash on zero-size arrays

An array with a logical size of 0 (e.g. an empty slice like a[128...]
on a shorter axis) has no backing data pointer, so asArray() crashed
by dereferencing nil.

physicalSize now returns 0 for empty arrays, so asArray, asData and
asDataCopy all return empty results from one place. The strided copy
and the two no-copy asData paths also skip the nil pointer, which a
transposed empty array or noCopy access would otherwise unwrap.
This matches Python's tolist() behaviour.

Adds tests for the empty-slice, empty-constructed, and scalar cases.

Fixes ml-explore#480

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Brings in ml-explore#501 (leak when _updateInternal replaces an array with siblings),
ml-explore#502 (enable JACCL) and ml-explore#486 (asArray crash on zero-size arrays). No conflicts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@solderzzc
solderzzc merged commit 3185383 into main Oct 17, 2026
9 checks passed
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.

4 participants