Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

mlx: drop carried metal residency patch now that it is upstream (#18854)

Daniel Hiltgencf2a313a2980
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 <algorithm>
- #include <cassert>
-+#include <chrono>
- #include <cstdio>
- #include <sstream>
- #include <stdexcept>
-@@ -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<std::mutex> 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<std::mutex> lock(mtx_);
-+ stop_refresh_ = true;
-+ }
-+ refresh_cv_.notify_one();
-+ refresh_thread_.join();
-+ }
-+}
-
- bool ResidencySets::add_set_locked(std::string* error_out) {
- NS::SharedPtr<MTL::ResidencySet> 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 <atomic>
-+#include <condition_variable>
- #include <cstdint>
- #include <mutex>
- #include <string>
-+#include <thread>
- #include <unordered_map>
- #include <vector>
-
-@@ -119,6 +121,9 @@
- // taking the lock.
- std::atomic<uint64_t> num_sets_{0};
- mutable std::mutex mtx_;
-+ std::condition_variable refresh_cv_;
-+ bool stop_refresh_{false};
-+ std::thread refresh_thread_;
- };
-
- } // namespace mlx::core::metal