Skip to content

llama : fix mlock with no-mmap with Metal #5025

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
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ struct llama_model {
std::unique_ptr<llama_mmap> mapping;

// objects representing data potentially being locked in memory
llama_mlock mlock_buf;
std::vector<std::unique_ptr<llama_mlock>> mlock_bufs;
llama_mlock mlock_mmap;

// for quantize-stats only
Expand Down Expand Up @@ -3815,8 +3815,10 @@ static bool llm_load_tensors(
else {
buf = ggml_backend_alloc_ctx_tensors_from_buft(ctx, buft);
if (buf != nullptr && use_mlock && ggml_backend_buffer_is_host(buf)) {
model.mlock_buf.init (ggml_backend_buffer_get_base(buf));
model.mlock_buf.grow_to(ggml_backend_buffer_get_size(buf));
model.mlock_bufs.emplace_back(new llama_mlock);
auto & mlock_buf = model.mlock_bufs.back();
mlock_buf->init (ggml_backend_buffer_get_base(buf));
mlock_buf->grow_to(ggml_backend_buffer_get_size(buf));
}
}
if (buf == nullptr) {
Expand Down