1.. _mps_environment_variables: 2 3MPS Environment Variables 4========================== 5 6**PyTorch Environment Variables** 7 8.. list-table:: 9 :header-rows: 1 10 11 * - Variable 12 - Description 13 * - ``PYTORCH_DEBUG_MPS_ALLOCATOR`` 14 - If set to ``1``, set allocator logging level to verbose. 15 * - ``PYTORCH_MPS_LOG_PROFILE_INFO`` 16 - Set log options bitmask to ``MPSProfiler``. See ``LogOptions`` enum in `aten/src/ATen/mps/MPSProfiler.h` for available options. 17 * - ``PYTORCH_MPS_TRACE_SIGNPOSTS`` 18 - Set profile and signpost bitmasks to ``MPSProfiler``. See ``ProfileOptions`` and ``SignpostTypes`` enums in `aten/src/ATen/mps/MPSProfiler.h` for available options. 19 * - ``PYTORCH_MPS_HIGH_WATERMARK_RATIO`` 20 - High watermark ratio for MPS allocator. By default, it is set to 1.7. 21 * - ``PYTORCH_MPS_LOW_WATERMARK_RATIO`` 22 - Low watermark ratio for MPS allocator. By default, it is set to 1.4 if the memory is unified and set to 1.0 if the memory is discrete. 23 * - ``PYTORCH_MPS_FAST_MATH`` 24 - If set to ``1``, enable fast math for MPS metal kernels. See section 1.6.3 in https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf for precision implications. 25 * - ``PYTORCH_MPS_PREFER_METAL`` 26 - If set to ``1``, force using metal kernels instead of using MPS Graph APIs. For now this is only used for matmul op. 27 * - ``PYTORCH_ENABLE_MPS_FALLBACK`` 28 - If set to ``1``, full back operations to CPU when MPS does not support them. 29 30.. note:: 31 32 **high watermark ratio** is a hard limit for the total allowed allocations 33 34 - `0.0` : disables high watermark limit (may cause system failure if system-wide OOM occurs) 35 - `1.0` : recommended maximum allocation size (i.e., device.recommendedMaxWorkingSetSize) 36 - `>1.0`: allows limits beyond the device.recommendedMaxWorkingSetSize 37 38 e.g., value 0.95 means we allocate up to 95% of recommended maximum 39 allocation size; beyond that, the allocations would fail with OOM error. 40 41 **low watermark ratio** is a soft limit to attempt limiting memory allocations up to the lower watermark 42 level by garbage collection or committing command buffers more frequently (a.k.a, adaptive commit). 43 Value between 0 to m_high_watermark_ratio (setting 0.0 disables adaptive commit and garbage collection) 44 e.g., value 0.9 means we 'attempt' to limit allocations up to 90% of recommended maximum 45 allocation size.