by vadansky · 3y ago · 0 comments
Obviously if you're swapping because you don't have enough memory to hold the model in RAM, the mmap version is going to be much faster, since you don't need to swap anything out to disk but just discard the page and re-read from disk if you need it again later.
The issue is typically that that initial load involves some sort of transformation - parsing, instantiating structures, etc. If you can arrange it so that the data is stored in the format you actually need it in memory, then you can skip that entire transformation phase.
I don’t know if that’s what’s been done with llama.cop though.
Edit: except embedding weights but those are not the problem.
Not necessarily memory savings, but the improvements here are that it will run on computers with less ram because it can page to disk.
Not necessarily the number reported (since you do need to load chunks into ram), but still lower.
One persons "paging the same memory requirement from disk to RAM" can be someone elses "requiring less memory/RAM".
file (DISK) to process active pages (RAM) to paged out virtual memory if saturated (elsewhere on DISK)
Using mmap typically goes something like:
file (DISK) to process active pages (RAM) to released and cached (RAM) to uncached if evicted (back to same place on DISK) OR back to process active pages from cache (RAM)
For the cost of fixing up some process page tables, the physical memory pages necessary can be brought back from the cache rather than read from disk. It's an orders-of-magnitude performance savings.
It's part of the program's working set but measuring that is a completely different story.