-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support using mmap when applying LoRA #2095
Conversation
Modify the code based on documentation. Needs testings. |
Based on documentation, on linux we probably need to set |
You are right. |
The intention behind this PR is that I want to futher refector loading code: llm_model_fil -> represent a file, it can be a model file or a lora file. offload_trait -> a set of class to represent how to offload for CUDA, OpenCL, CUDA_SPLIT, etc.. mmap and non-mmap makes code a bit complex. any suggestions on how we can further reduce the complexity? |
Are there any possible performance considerations or any other consequences of enabling copy-on-write with mmap by default? |
Based on my understanding, performance should be same. but I need to test. Didn't find a lora model yet. |
https://huggingface.co/tloen/alpaca-lora-7b |
The file doesn't have the correct magic in the header. Anyway, thank you. |
ohh, you dont know. There is a |
1e30512
to
2ab2da2
Compare
Tested on Windows on functionality. Also use md5hash to verify the original weights file is unchanged. |
I think you need to run 2 llama.cpp, with atleast 1 lora to see duplication in memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good, and the overhead of always mapping files as copy-on-write should be minimal unless the pages are actually modified, so I think we can try this.
No noticeable diff:
|
Has perf regression when mlock is used. This reverts commit 2347463.
On Linux, when mmap with MAP_PRIVATE, the modification to the mmap buffer will not write to disk.
On Windows, when MapViewOfFile with FILE_MAP_COPY, the modification will not write to disk.