Skip to content

Commit

Permalink
llama_control_vector_load: let gguf_init_from_file allocate the ggml_…
Browse files Browse the repository at this point in the history
…context
  • Loading branch information
Anon authored and trollkotze committed Mar 26, 2024
1 parent 6e1fbf8 commit 181879f
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2650,12 +2650,7 @@ static llama_control_vector_data llama_control_vector_load_one(const llama_contr

// calculate size of ctx needed for tensors, ensure tensors are f32, and find max layer
{
struct ggml_init_params meta_params = {
/* .mem_size = */ ggml_tensor_overhead() * 128 + ggml_graph_overhead(),
/* .mem_buffer = */ nullptr,
/* .no_alloc = */ true,
};
ggml_context * meta_ctx = ggml_init(meta_params);
ggml_context * meta_ctx = nullptr;
struct gguf_init_params meta_gguf_params = {
/* .no_alloc = */ true,
/* .ctx = */ &meta_ctx,
Expand Down Expand Up @@ -2720,13 +2715,7 @@ static llama_control_vector_data llama_control_vector_load_one(const llama_contr
}

// load and scale tensors into final control vector context
struct ggml_init_params ggml_params = {
/* .mem_size = */ ggml_tensor_overhead() * n_tensors + n_bytes,
/* .mem_buffer = */ nullptr,
/* .no_alloc = */ false,
};
struct ggml_context * ctx = ggml_init(ggml_params);

struct ggml_context * ctx = nullptr;
struct gguf_init_params params = {
/*.no_alloc = */ false,
/*.ctx = */ &ctx,
Expand Down

0 comments on commit 181879f

Please sign in to comment.