You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GLM loader: F_NOCACHE does not evict checkpoint pages an earlier download left in the file cache #583
glm/weights.zig's runCopies opens the shards with F_NOCACHE, so the reads don't fill the file cache. That doesn't evict pages that are already cached, though. Right after tensorfold pull, or after any earlier read of the checkpoint, much of it is still in the cache. On a 256 GB M5 Ultra, measured with mincore over GLM-5.3-Flash-MLX-4bit-MTP's shards, 69.6 GiB of the 169 GiB checkpoint was cached before a load.
The load then needs that cached copy and about 168 GiB of fresh GPU buffers at the same time. macOS kept the clean file pages and compressed the new buffers instead. It reached critical pressure, with 145 GiB in the compressor and 0.3 GiB of truly free pages, while the clean cache stayed put. (This was with the one-Mac limit raised, #498 / #580. The wiring in #581 addresses the compressor side.)
Suggestion
Before runCopies, drop each shard's cached pages: mmap it read-only shared, msync(addr, len, MS_INVALIDATE), munmap. That needs no root, unlike purge. On the same machine, dropping the 69.6 GiB took 0.5 s, and mincore reported 0.0 GiB cached afterwards. File-backed memory went from 107 to 39.6 GiB.
Thanks, this matches the code, and it's been on our minds: the loader's own reads went through the page cache despite F_NOCACHE (they weren't aligned), and a 160 GB load on a Mac we test on ran out of free memory that way. Main's e82ab69 reads the checkpoint through aligned buffers around the page cache and waits while free memory is under 3% of RAM. Pages a pull cached before the load still stay, as you found. Up to 70% of RAM that leaves enough room; past it, which will take an explicit GLM_LOAD_LIMIT_GB (see #580), dropping a shard's cached pages first, with msync and MS_INVALIDATE as you measured, makes sense, and we'd take it as a small change to that path, measured with and without it on the same Mac. Closing this as answered; the cached-page drop can come as that small change.
Activity
ashhart commentedon Oct 10, 2026
Thanks, this matches the code, and it's been on our minds: the loader's own reads went through the page cache despite
F_NOCACHE(they weren't aligned), and a 160 GB load on a Mac we test on ran out of free memory that way. Main's e82ab69 reads the checkpoint through aligned buffers around the page cache and waits while free memory is under 3% of RAM. Pages a pull cached before the load still stay, as you found. Up to 70% of RAM that leaves enough room; past it, which will take an explicitGLM_LOAD_LIMIT_GB(see #580), dropping a shard's cached pages first, withmsyncandMS_INVALIDATEas you measured, makes sense, and we'd take it as a small change to that path, measured with and without it on the same Mac. Closing this as answered; the cached-page drop can come as that small change.