←back to thread

1311 points msoad | 7 comments | | HN request time: 0.512s | source | bottom
1. w1nk ◴[] No.35394065[source]
Does anyone know how/why this change decreases memory consumption (and isn't a bug in the inference code)?

From my understanding of the issue, mmap'ing the file is showing that inference is only accessing a fraction of the weight data.

Doesn't the forward pass necessitate accessing all the weights and not a fraction of them?

replies(4): >>35394751 #>>35396440 #>>35396507 #>>35398499 #
2. matsemann ◴[] No.35394751[source]
Maybe lots of the data is embedding values or tokenizer stuff, where a single prompt uses a fraction of those values. And then the rest of the model is quite small.
replies(1): >>35394872 #
3. w1nk ◴[] No.35394872[source]
That shouldn't be the case. 30B is a number that directly represents the size of the model, not the size of the other components.
4. jhatemyjob ◴[] No.35396440[source]
If you read a file with malloc and memcpy, it copies the data from the kernel to userspace. With mmap there is no copying.
5. losteric ◴[] No.35396507[source]
yeah, I believe some readers are misinterpreting the report. The OS manages mmap, it won't show up as "regular" memory utilization because it's lazy-loaded and automatically managed. If the OS can keep the whole file in memory, it will, and it will also magically swap to disk prioritizing explicit memory allocation (malloc).

Sounds like the big win is load time from the optimizations. Also, maybe llama.cpp now supports low-memory systems through mmap swapping? ... at the end of the day, 30B quantized is still 19GB...

6. l33tman ◴[] No.35398499[source]
It's not a bug, but it's misreading the htop output as mmap doesn't show up as a resident set size there. The pages are RO and not dirty so it's "on the OS" to count it and the OP had lots of RAM on the computer so the model just resides in his page cache instead.
replies(1): >>35398845 #
7. w1nk ◴[] No.35398845[source]
Ahh, this would do it, thanks :).