Skip to content
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

fix a bug when calculating neuron_cap before invoking the solver #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3076,10 +3076,10 @@ static bool llm_load_gpu_split_with_budget(llama_model_loader & ml, llama_model
// Calculate solver parameters
ggml_tensor * ffn_up = model.layers[0].ffn_up;
ggml_tensor * ffn_gate = model.layers[0].ffn_gate;
int slice_size = ffn_up->ne[1] * ggml_type_size(ffn_up->type) / ggml_blck_size(ffn_up->type);
int slice_size = ffn_up->ne[0] * ggml_type_size(ffn_up->type) / ggml_blck_size(ffn_up->type);
// For model arch with FFN gate, the gate is also sliced, otherwise only the up and down matrices are sliced
int vram_bytes_per_slice = slice_size * (ffn_gate ? 4.5 : 2); // TODO: why 4.5, not 3?
int neuron_cap = floor((double)vram_allocatable_bytes / vram_bytes_per_slice) * 4;
int vram_bytes_per_slice = slice_size * (ffn_gate ? 3 : 2);
int neuron_cap = floor((double)vram_allocatable_bytes / vram_bytes_per_slice);

LLAMA_LOG_INFO("invoking powerinfer Python module to generate gpu split for %.2f MiB of VRAM\n", vram_allocatable_bytes / 1024.0 / 1024.0);

Expand Down