Skip to content

Commit 5014f38

Browse files
committed
llama : assign unknown/unused tensors to host buffer type
ggml-ci
1 parent 586d5fe commit 5014f38

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/llama-model.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,15 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
14601460
GGML_ABORT("invalid layer %d for tensor %s", info.layer, tn.str().c_str());
14611461
}
14621462

1463-
ggml_backend_buffer_type_t buft = select_weight_buft(hparams, t_meta, op, *buft_list);
1463+
ggml_backend_buffer_type_t buft;
1464+
1465+
if (op == GGML_OP_NONE) {
1466+
LLAMA_LOG_WARN("tensor %s has no operation assigned, using host buffer\n", tn.str().c_str());
1467+
auto * cpu_dev = ggml_backend_dev_by_type(GGML_BACKEND_DEVICE_TYPE_CPU);
1468+
buft = ggml_backend_dev_buffer_type(cpu_dev);
1469+
} else {
1470+
buft = select_weight_buft(hparams, t_meta, op, *buft_list);
1471+
}
14641472
if (!buft) {
14651473
throw std::runtime_error(format("failed to find a compatible buffer type for tensor %s", tn.str().c_str()));
14661474
}

0 commit comments

Comments
 (0)