From 60c41543469ca59dae5ee9be03d8b05264e84f86 Mon Sep 17 00:00:00 2001 From: Awni Hannun Date: Mon, 7 Apr 2025 10:47:51 -0700 Subject: [PATCH] Only request residency once (#2051) --- mlx/backend/metal/resident.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mlx/backend/metal/resident.cpp b/mlx/backend/metal/resident.cpp index 545f67e49..0a9e1b861 100644 --- a/mlx/backend/metal/resident.cpp +++ b/mlx/backend/metal/resident.cpp @@ -22,6 +22,7 @@ ResidencySet::ResidencySet(MTL::Device* d) { } throw std::runtime_error(msg.str()); } + wired_set_->requestResidency(); } } @@ -32,7 +33,6 @@ void ResidencySet::insert(MTL::Allocation* buf) { if (wired_set_->allocatedSize() + buf->allocatedSize() <= capacity_) { wired_set_->addAllocation(buf); wired_set_->commit(); - wired_set_->requestResidency(); } else { unwired_set_.insert(buf); } @@ -76,7 +76,6 @@ void ResidencySet::resize(size_t size) { } } wired_set_->commit(); - wired_set_->requestResidency(); } else if (current_size > size) { auto pool = new_scoped_memory_pool(); // Remove wired allocations until under capacity