-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Async DirectIO model loading on Linux #18012
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
Merged
ggerganov
merged 10 commits into
ggml-org:master
from
JTischbein:direct_io_model_read_linux
Dec 18, 2025
+184
−42
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3074b50
Uncached model read
JTischbein 26cc75f
Removing additional --mmap arg
JTischbein ceccfb9
Removing trailing whitespaces
JTischbein d2acc3a
Adding fallback when O_DIRECT is not supported
JTischbein f6d79fe
Remove branching in llama-model-loader.cpp and reduce code duplicatio…
JTischbein 0879d22
Adding maybe unused keyword for Mac and Windows.
JTischbein fff1157
File seek aligned
JTischbein d73ff6a
Removing all branches for direct_io in llama-model-loader.cpp
JTischbein 99fde72
Always use alignment from llama_file
JTischbein 921d7c9
use_mmap=true
JTischbein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Changing this to
falseby default, results in a huge slowdown on MacOS with default arguments:Not sure what is the best way to handle this. If we keep it
true, then linux users would not get the benefit of Direct IO. If we switch tofalse, Mac users will take the hit.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.
Would it be OK to set mmap depending on the platform?
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.
We don't have such precedent atm for any of the parameters in
common, so I would say it's not ideal.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.
I have on M4 Pro with GPT-OSS-20B on cold load
--no-mmap: 4.168s--mmap: 6.3s. The warm load however takes with--mmap2.1s (--no-mmapstill ~4.1s).Measured using
time ./llama-cli -m /Users/jtischbein/Documents/models/openai_gpt-oss-20b-MXFP4.gguf --no-mmap -p "bla" -n 0 --single-turnand filesystem cache cleared usingpurge.So the cold load time is still faster using
--mmap, but unfortunately not as fast as on Linux.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.
We can do the following:
--direct-io, -diouse_mmap == trueanduse_direct_io == trueMight want to do it in a separate PR as it would require changes in
libllamaAPI. This PR should keepuse_mmap == trueby default.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.
Sounds good