huggingface / huggingface/candle
O_DIRECT when reading weight files
- Dominant language
- Rust
- Stars
- 21k
- Forks
- 1.8k
- Avg merge
- 16h 42m
- Merged PRs (30d)
- 25
Description
With shared memory setups like SM121, turns out we can OOM ourselves by reading the weight files into pagecache while trying to load them into hostmem (since there's no dedicated VRAM) as data. Suggest using O_DIRECT to read, or at least creating a flag/feature to read w/ O_DIRECT so as to avoid pagecache contention with model space. Even for systems which are not memory-constrained (or in worst case memory-sharing), a PCIE5 NVME direct read to a memory buffer tends to be faster than reading it to pagecache and copying to the buffer...
Similarly any mmaped data needs to be drained page-for-page from "hostmem" to "vmem" in the Spark situation as they are both just regions in the same space. Ideally this could be done through casting and pointer translation instead of actual "data movement" between RAM cells as that would remove a significant IO step from the process.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.