Add stats and limit to common allocator and enable tests (#1988)

* add stats to common allocator and enable tests

* linux memory and default

* fix
This commit is contained in:
Awni Hannun
2025-03-21 12:28:36 -07:00
committed by GitHub
parent d343782c8b
commit 2a980a76ce
13 changed files with 151 additions and 68 deletions

View File

@@ -745,11 +745,8 @@ class TestAutograd(mlx_tests.MLXTestCase):
mx.custom_function,
mx.checkpoint,
]:
if mx.metal.is_available():
mx.synchronize(mx.default_stream(mx.default_device()))
mem_pre = mx.get_active_memory()
else:
mem_pre = 0
mx.synchronize()
mem_pre = mx.get_active_memory()
def outer():
d = {}
@@ -763,12 +760,7 @@ class TestAutograd(mlx_tests.MLXTestCase):
for _ in range(5):
outer()
gc.collect()
if mx.metal.is_available():
mem_post = mx.get_active_memory()
else:
mem_post = 0
mem_post = mx.get_active_memory()
self.assertEqual(mem_pre, mem_post)
def test_grad_with_copies(self):