Skip to content

Commit cecdd67

Browse files
committed
tooling(probe): optional CPPMEGA_MLX_MEMORY_LIMIT_GB cap to bound MLX cache pool
1 parent 32aa7a0 commit cecdd67

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

scripts/probe_real_step_mem_20260601.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def main() -> None:
6969
torch = None
7070
have_torch = False
7171

72+
# Optional MLX memory-limit cap (GB). Caps the MLX cache pool so the unified
73+
# footprint tracks the live high-water instead of MLX's reservation
74+
# headroom.
75+
cap_gb = os.environ.get("CPPMEGA_MLX_MEMORY_LIMIT_GB", "").strip()
76+
if cap_gb and hasattr(mx, "set_memory_limit"):
77+
mx.set_memory_limit(int(float(cap_gb) * (1024**3)))
78+
7279
t0 = time.time()
7380
model = local_gb10_quarter(dtype=mx.bfloat16, grad_checkpoint=args.grad_checkpoint)
7481
mx.eval(model.parameters())

0 commit comments

Comments
 (0)