3 ms·
Any idea if madvise helps? Admittedly I have very limited experience and only on Linux
by nijave 3mo ago
Any idea if madvise helps? Admittedly I have very limited experience and only on Linux
- kees99 3mo agoMADV_SEQUENTIAL might help a bit, but not that much. Biggest problem here is throughput-vs-latency. With mmap()-ed file, for each pagefault, kernel will conservatively estimate block size to page in, so you'll have a ton of relatively small requests going to SSD. This would be IOPS-bound, and likely under-perform relative to maximum possible bytes/second throughput. With explicit read()/pread(), kernel & SSD can work with much larger chunks, so it's easier to hit maximum bytes/second throughput. Plus, with modern CPUs, IO-wait could be efficiently combined with number-crunching. So, if software knows in advance which data chunk (expert) it'll need for the next token, it can load that in parallel with computing current token.
- p0u4a 2mo ago> if software knows in advance which data chunk (expert) it'll need for the next token, it can load that in parallel with computing current token You could actually use the model's MTP head to make a ~decent prediction on what experts would be activate in future tokens and preload them
- nijave 2mo ago>So, if software knows in advance which data chunk (expert) it'll need for the next token, it can load that in parallel with computing current token. Yeah, I was thinking MADV_WILLNEED might work there but not sure
- gitpusher42 3mo agoI tried it. madvise didn't make mmap better than pread. I also tested F_RDADVISE, it helped on short decodes, but somehow got worse on longer decodes. Not very clear why, most likely problem somewhere at APFS and it is closed source and not much docs for it