diff --git a/MLX_VERSION b/MLX_VERSION index 36bc0faa3..0bbe3060c 100644 --- a/MLX_VERSION +++ b/MLX_VERSION @@ -1 +1 @@ -264c14fe650e1dd9bb0c3902dc06b08033d8f89c \ No newline at end of file +a59cc23190f1e26fabcba8693607bb4c34b2ac2b \ No newline at end of file diff --git a/mlx/compat/mlx/0001-metal-residency-refresh.patch b/mlx/compat/mlx/0001-metal-residency-refresh.patch deleted file mode 100644 index 42ce52999..000000000 --- a/mlx/compat/mlx/0001-metal-residency-refresh.patch +++ /dev/null @@ -1,84 +0,0 @@ -diff --git a/mlx/backend/metal/resident.cpp b/mlx/backend/metal/resident.cpp ---- a/mlx/backend/metal/resident.cpp -+++ b/mlx/backend/metal/resident.cpp -@@ -1,7 +1,8 @@ --// Copyright © 2024 Apple Inc. -+// Copyright © 2024-2026 Apple Inc. - - #include - #include -+#include - #include - #include - #include -@@ -43,10 +44,38 @@ - } - throw std::runtime_error(msg.str()); - } -- } --} -- --ResidencySets::~ResidencySets() = default; -+ if (int interval = -+ env::get_var("MLX_METAL_RESIDENCY_REFRESH_INTERVAL_MS", 0); -+ interval > 0) { -+ refresh_thread_ = std::thread([this, interval] { -+ std::unique_lock lock(mtx_); -+ while (!refresh_cv_.wait_for( -+ lock, std::chrono::milliseconds(interval), [this] { -+ return stop_refresh_; -+ })) { -+ auto pool = new_scoped_memory_pool(); -+ // macOS can drop residency after GPU idle despite a standing request. -+ for (auto& s : sets_) { -+ if (s.size != 0) { -+ s.set->requestResidency(); -+ } -+ } -+ } -+ }); -+ } -+ } -+} -+ -+ResidencySets::~ResidencySets() { -+ if (refresh_thread_.joinable()) { -+ { -+ std::lock_guard lock(mtx_); -+ stop_refresh_ = true; -+ } -+ refresh_cv_.notify_one(); -+ refresh_thread_.join(); -+ } -+} - - bool ResidencySets::add_set_locked(std::string* error_out) { - NS::SharedPtr set; -diff --git a/mlx/backend/metal/resident.h b/mlx/backend/metal/resident.h ---- a/mlx/backend/metal/resident.h -+++ b/mlx/backend/metal/resident.h -@@ -1,11 +1,13 @@ --// Copyright © 2024 Apple Inc. -+// Copyright © 2024-2026 Apple Inc. - - #pragma once - - #include -+#include - #include - #include - #include -+#include - #include - #include - -@@ -119,6 +121,9 @@ - // taking the lock. - std::atomic num_sets_{0}; - mutable std::mutex mtx_; -+ std::condition_variable refresh_cv_; -+ bool stop_refresh_{false}; -+ std::thread refresh_thread_; - }; - - } // namespace mlx::core::metal