Skip to content

Commit e434f89

Browse files
authored
Merge pull request #201 from ausimian/chore/bump-mlx-0.32.0
build: bump pinned MLX to 0.32.0
2 parents 0f614a4 + 9ff15db commit e434f89

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ HEADERS := $(shell find c_src \( -name '*.h' -o -name '*.hpp' \))
1010
OBJECTS := $(patsubst c_src/%.cpp,$(BUILD_DIR)/%.o,$(SOURCES))
1111

1212
# Flags
13-
CXXFLAGS := -std=c++17 -O3 -fPIC -fvisibility=hidden -Wall -Wextra
13+
#
14+
# C++20 to match MLX itself: as of 0.32.0 MLX sets `CMAKE_CXX_STANDARD 20`
15+
# (REQUIRED), so libmlx.a is compiled as C++20 and its public headers use
16+
# C++20 features (e.g. a defaulted `operator==` on `CompileOptions` in
17+
# mlx/backend/common/metal_kernel.h, reachable via <mlx/fast.h>). We include
18+
# those headers and statically link those objects, so we build the NIF at the
19+
# same language level to stay ABI/ODR-consistent with the library.
20+
CXXFLAGS := -std=c++20 -O3 -fPIC -fvisibility=hidden -Wall -Wextra
1421
CXXFLAGS += -I$(ERTS_INCLUDE_DIR) -Ic_src
1522
# Third-party headers: use -isystem so warnings inside them (e.g. MLX's
1623
# -Wdeprecated-copy on _MLX_BFloat16) don't clutter our builds or trip
@@ -57,8 +64,8 @@ BENCH_NATIVE_SRC := bench/native/compile_microbench.cpp
5764
BENCH_NATIVE_BIN := $(BUILD_DIR)/compile_microbench
5865
BENCH_NATIVE_METALLIB := $(BUILD_DIR)/mlx.metallib
5966

60-
$(BENCH_NATIVE_BIN): $(BENCH_NATIVE_SRC) | $(BUILD_DIR)
61-
$(CXX) -std=c++17 -O3 -Wall -Wextra \
67+
$(BENCH_NATIVE_BIN): $(BENCH_NATIVE_SRC) $(MLX_LIB_DIR)/libmlx.a Makefile | $(BUILD_DIR)
68+
$(CXX) -std=c++20 -O3 -Wall -Wextra \
6269
-isystem $(MLX_INCLUDE_DIR) \
6370
$(BENCH_NATIVE_SRC) \
6471
$(MLX_LIB_DIR)/libmlx.a \
@@ -81,11 +88,18 @@ $(BUILD_DIR):
8188
$(PRIV_DIR):
8289
@mkdir -p $(PRIV_DIR)
8390

84-
$(BUILD_DIR)/%.o: c_src/%.cpp $(HEADERS) | $(BUILD_DIR)
91+
# Objects and the linked NIF also depend on libmlx.a and this Makefile so an
92+
# existing checkout rebuilds when the MLX build changes (a version bump
93+
# repoints MLX_LIB_DIR at a freshly built, newer libmlx.a whose headers these
94+
# objects include) or when a compile/link flag here changes (e.g. the C++
95+
# standard). Without these, `make` can copy the new mlx.metallib while leaving
96+
# a stale NIF statically linked against the old MLX in place — a mismatched
97+
# binary until a manual clean.
98+
$(BUILD_DIR)/%.o: c_src/%.cpp $(HEADERS) $(MLX_LIB_DIR)/libmlx.a Makefile | $(BUILD_DIR)
8599
@mkdir -p $(dir $@)
86100
$(CXX) $(CXXFLAGS) -c $< -o $@
87101

88-
$(NIF_SO): $(OBJECTS) | $(PRIV_DIR)
102+
$(NIF_SO): $(OBJECTS) $(MLX_LIB_DIR)/libmlx.a Makefile | $(PRIV_DIR)
89103
$(CXX) $(OBJECTS) -o $(NIF_SO) $(LDFLAGS)
90104

91105
# MLX searches for mlx.metallib colocated with the loaded binary

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### Changed
22

3+
- Updated the pinned MLX to 0.32.0. This is a maintenance bump that also
4+
picks up faster small-batch quantized matvec (`qmv_wide`) — accelerating
5+
the fused quantized path — and broader fused SDPA coverage (asymmetric
6+
Q/V head dims), both transparently. No API changes.
37
- Quantized dense layers now use the fused `mx::quantized_matmul` kernel
48
instead of dequantizing the full weight to bf16 and running a dense
59
matmul. The packed low-bit weights are streamed directly, so a decode

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Emily.MixProject do
99
# `deps/0`) and the per-variant cache dir layout. Bump in lockstep with
1010
# the submodule ref; CI's `release-nif.yml` rebuilds the NIF against
1111
# whatever this resolves to.
12-
@mlx_version "0.31.2"
12+
@mlx_version "0.32.0"
1313

1414
# Precompiled NIF targets this `@version` ships. Used as an
1515
# early fail-fast guard in the hex-consumer fetch step (an

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
1818
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
1919
"makeup_erlang": {:hex, :makeup_erlang, "1.0.3", "4252d5d4098da7415c390e847c814bad3764c94a814a0b4245176215615e1035", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "953297c02582a33411ac6208f2c6e55f0e870df7f80da724ed613f10e6706afd"},
20-
"mlx_src": {:git, "https://github.com/ml-explore/mlx.git", "68cf2fddd8de5edd8ab3d926391772b2e2cedad8", [tag: "v0.31.2"]},
20+
"mlx_src": {:git, "https://github.com/ml-explore/mlx.git", "7a1d4f5c12ac82f4b4d0a6e71538d89ca0605247", [tag: "v0.32.0"]},
2121
"nimble_csv": {:hex, :nimble_csv, "1.3.0", "b7f998dc62b222bce9596e46f028c7a5af04cb5dde6df2ea197c583227c54971", [:mix], [], "hexpm", "41ccdc18f7c8f8bb06e84164fc51635321e80d5a3b450761c4997d620925d619"},
2222
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
2323
"nx": {:hex, :nx, "0.12.0", "32bc205bab5486d73892132d17a11ea113e97427a29bb70606a544724b95e193", [:mix], [{:complex, "~> 0.7", [hex: :complex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d022a33ea3c900eb6e2e91b4e0793759459c886f482be61978004b5e4843b5e"},

test/emily/native_test.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ defmodule Emily.NativeTest do
232232
test "power" do
233233
a = f32([2.0, 3.0], [2])
234234
b = f32([3.0, 2.0], [2])
235-
assert to_f32_list(Native.power(worker(), a, b)) == [8.0, 9.0]
235+
# `power` is computed via exp/log, so integer-valued results aren't
236+
# bit-exact (e.g. MLX's JIT Metal kernel yields 3**2 = 8.99999809);
237+
# compare within tolerance like the other transcendental ops here.
238+
assert_close(to_f32_list(Native.power(worker(), a, b)), [8.0, 9.0])
236239
end
237240

238241
test "maximum / minimum" do

0 commit comments

Comments
 (0)