mirror of
				https://github.com/ml-explore/mlx.git
				synced 2025-11-04 10:38:10 +08:00 
			
		
		
		
	Wired (#1510)
* expose residency sets as wire/unwire * returns wired size * fix * runtime support check * fix os check * fix test * fix no metal build * docs * nit * nits in docs * nits
This commit is contained in:
		@@ -6,6 +6,7 @@
 | 
			
		||||
#include <nanobind/stl/string.h>
 | 
			
		||||
#include <nanobind/stl/unordered_map.h>
 | 
			
		||||
#include <nanobind/stl/variant.h>
 | 
			
		||||
#include <nanobind/stl/vector.h>
 | 
			
		||||
 | 
			
		||||
namespace nb = nanobind;
 | 
			
		||||
using namespace nb::literals;
 | 
			
		||||
@@ -98,6 +99,38 @@ void init_metal(nb::module_& m) {
 | 
			
		||||
      Returns:
 | 
			
		||||
        int: The previous cache limit in bytes.
 | 
			
		||||
      )pbdoc");
 | 
			
		||||
  metal.def(
 | 
			
		||||
      "set_wired_limit",
 | 
			
		||||
      &metal::set_wired_limit,
 | 
			
		||||
      "limit"_a,
 | 
			
		||||
      R"pbdoc(
 | 
			
		||||
      Set the wired size limit.
 | 
			
		||||
 | 
			
		||||
      .. note::
 | 
			
		||||
         * This function is only useful on macOS 15.0 or higher.
 | 
			
		||||
         * The wired limit should remain strictly less than the total
 | 
			
		||||
           memory size.
 | 
			
		||||
 | 
			
		||||
      The wired limit is the total size in bytes of memory that will be kept
 | 
			
		||||
      resident. The default value is ``0``.
 | 
			
		||||
 | 
			
		||||
      Setting a wired limit larger than system wired limit is an error. You can
 | 
			
		||||
      increase the system wired limit with:
 | 
			
		||||
 | 
			
		||||
      .. code-block::
 | 
			
		||||
 | 
			
		||||
        sudo sysctl iogpu.wired_limit_mb=<size_in_megabytes>
 | 
			
		||||
 | 
			
		||||
      Use :func:`device_info` to query the system wired limit
 | 
			
		||||
      (``"max_recommended_working_set_size"``) and the total memory size
 | 
			
		||||
      (``"memory_size"``).
 | 
			
		||||
 | 
			
		||||
      Args:
 | 
			
		||||
        limit (int): The wired limit in bytes.
 | 
			
		||||
 | 
			
		||||
      Returns:
 | 
			
		||||
        int: The previous wired limit in bytes.
 | 
			
		||||
      )pbdoc");
 | 
			
		||||
  metal.def(
 | 
			
		||||
      "clear_cache",
 | 
			
		||||
      &metal::clear_cache,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user