Skip to content

Merge upstream mlx-swift main into prism (15 commits; mlx-c fork retired)#5

Merged
bri-prism merged 16 commits into
prismfrom
merge/upstream-main-2026-06-11
Jun 11, 2026
Merged

Merge upstream mlx-swift main into prism (15 commits; mlx-c fork retired)#5
bri-prism merged 16 commits into
prismfrom
merge/upstream-main-2026-06-11

Conversation

@bri-prism

Copy link
Copy Markdown

What

Merges upstream ml-explore/mlx-swift main into prism (15 commits): compile() overloads
up to arity 8, AdamW bias-correction parameter, linalg nuclear norm, evalLock fixes around
tostring/save_safetensors, l2-normalized array extension, fmt 12.1.0, doc-verification CI.

Done as a merge, not a rebase — deliberately: a cherry-pick/rebase replay of the prism
stack silently lost the 1-bit kernel content in the regenerated mlx-generated/* mirrors
(verified: 17 bits == 1 sites dropped to 0 after a clean-looking pick). The 3-way merge
keeps the regenerated files correct, preserves history, and advances prism by fast-forward.

Resolution policy

  • Source/Cmlx/mlxstays on the PrismML fork (d90771c): the 1/2-bit Metal kernel
    stack lives there, and it is already a strict superset of upstream's pin (ce45c52,
    54 ahead / 0 behind).
  • Source/Cmlx/mlx-cmoves to upstream 0.6.0 and the PrismML mlx-c fork is retired:
    upstream now passes std::nullopt for global_scale natively, so the one-patch fork and
    patches/mlx-c-global-scale-nullopt.patch are superseded (patch removed, .gitmodules
    back to ml-explore/mlx-c).
  • include-framework vendored headers — upstream (0.31.1): every prism hand-edit
    (global_scale, global_scale_x/w) now exists natively; ours were stale 0.30.7.
  • NAX generated files — upstream (toolchain-path comment churn only).
  • 1/2-bit kernel content in mlx-generated/quantized.* verified intact post-merge
    (17 one-bit sites in both the JIT source and the metal mirror).

Deferred

.github/workflows/pull_request.yml is kept at the current prism version (upstream's CI
tweak deferred) — pushing workflow-file changes needs a workflow-scoped token; can follow
as a trivial commit once pushed from a scoped session.

Verification (M5, xcodebuild → real metallib)

  • Full package test suite: 518/518 passed, 0 failures (quantization suites executed on
    Metal, not stubbed)
  • swift build clean (known FMT_CONSTEVAL warning only)

davidkoski and others added 16 commits March 6, 2026 09:05
* break init order dependency

- fix ml-explore#224
- lazily built _items and _setters after init is complete
* update for mlx 0.31.1

- clean up some build settings (c++ version, warnings)
- set mlx version (see ml-explore#370 and ml-explore#373)
- fixes xcode 26.4 build issue
- fixes ml-explore#375
* Implement L2 normalization extension for MLXArray

Adds an extension method to MLXArray for L2 normalization.
- fix ml-explore#378
- save functions call eval internally and must be run under evalLock
* Add doc comment verification script and CI step
* Fix doc comments
* Discover doc verification targets dynamically and report all failures
…xplore#384)

QuantizedLinear.init(weight:...) called MLX.quantized() without
forwarding the mode parameter, so weights were always quantized
as affine regardless of the specified mode. This produced spurious
biases for non-affine modes like mxfp4.

Fix: pass mode: mode to MLX.quantized(), matching QuantizedEmbedding
which already does this correctly.

Note: no updateMissing() override is needed — when biases is nil,
Module.build(value:) wraps it as .value(.other(...)), and the
(.value(.other(_)), .none) case in update() already breaks silently.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ml-explore#394)

- this should cover _most_ cases
- there is still ([MLXArray]) -> [MLXArray] as a fallback
* add missing functions

- eig - eigenvalues and eigenvectors
- eigh - eigenvalues/eigenvectors of symmetric/Hermitian matrix
- eigvals - eigenvalues only
- eigvalsh - eigenvalues of symmetric/Hermitian matrix
- pinv - pseudo-inverse

* add remaining functions:

- logcumsumexp
- segmentedMm (segmented_mm)
- permutation
- fftshift
- ifftshift
…-explore#398)

mlx_detail_compile and mlx_closure_apply both return int (0=success,
1=failure) but their return values were silently ignored. When an error
fires inside a withError scope the MLX error handler stores the error in
an ErrorBox instead of calling fatalError; execution then continues past
the failed call, innerCall returns an empty result vector, and the
single/two/three-array compile overloads crash with a Swift 'Index out
of range' trap — bypassing withError entirely.

Fix: capture both return values and early-return [] from innerCall on
failure. The placeholder return from the compile overloads is never
observed by the caller because withError throws before the value is
used.

Adds three regression tests covering the single-array, two-array, and
[MLXArray]->[MLXArray] compile overloads.
* hold evalLock while computing tostring

- tostring internally calls eval, which is not thread safe

* remove show-sdk-version -- ci breakage
Brings in 15 upstream commits (compile overloads up to arity 8, AdamW bias
correction, linalg nuclear norm, evalLock fixes, l2-normalized extension,
fmt 12.1.0, doc CI).

Resolution notes:
- Source/Cmlx/mlx stays on the PrismML fork (1/2-bit Metal kernel stack).
- Source/Cmlx/mlx-c moves to upstream 0.6.0 and the PrismML mlx-c fork is
  retired: upstream now passes std::nullopt for global_scale natively, so
  the one-patch fork and patches/mlx-c-global-scale-nullopt.patch are
  superseded (patch file removed).
- include-framework vendored headers taken from upstream (0.31.1): every
  prism-side hand-edit (global_scale, global_scale_x/w) now exists natively.
- NAX generated files taken from upstream (toolchain-path comment churn only).
- 1/2-bit kernel content in mlx-generated/quantized.* verified intact
  (17 one-bit sites in both the JIT source and the metal mirror).
@bri-prism
bri-prism requested a review from khosravipasha June 11, 2026 03:25

@khosravipasha khosravipasha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Okay to merge for now.

Later on if our 1-bit kernels merge in mlx need to clean up this branch (and usually they make changes on mlx first and just pick up form that)

@bri-prism
bri-prism merged commit e40e0a5 into prism Jun 11, 2026
8 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.

9 participants