[MPS] Improve memory usage and performance utilizing garbage collector and adaptive commit (#86119)
- Improve memory usage and performance utilizing garbage collector and adaptive commit
- Enable low watermark limit to detect memory pressure.
- Enable garbage collection and adaptive commit strategies when under memory pressure.
- More efficient resource management by splitting large heaps (instead of reusing oversized buffers for smaller allocation requests)
- Introduce Extra Large heaps to improve performance by avoiding numerous costly allocation of smaller heaps
- Fix purgeability when releasing the Metal heaps
- Fix the race condition when deferring the heap's size update
Fixes #79283
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86119
Approved by: https://github.com/kulinseth, https://github.com/malfet