Skip to content

Commit

Permalink
llama : fix Metal KV cache sync (close #1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Jun 5, 2023
1 parent 827f5ed commit d1f563a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,14 @@ static bool llama_eval_internal(
// When we implement Matrix x Matrix Metal multiplication, we can avoid this branch.
// But for now, we have focused only on Matrix x Vector Metal multiplication.
//
// TODO: avoid these syncs via shared memory (ref #1696)
//
if (lctx.ctx_metal) {
// We need to sync the GPU KV cache with the CPU KV cache
ggml_metal_get_tensor(lctx.ctx_metal, kv_self.k);
ggml_metal_get_tensor(lctx.ctx_metal, kv_self.v);
}

ggml_graph_compute(ctx0, &gf);

if (lctx.ctx_metal) {
Expand Down

0 comments on commit d1f563a

Please sign in to comment.