MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / offload_ffn_split

Method offload_ffn_split

llama.cpp:2969–2997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2967 }
2968
2969 size_t offload_ffn_split(llama_model * model) {
2970 LLAMA_LOG_INFO("%s: applying augmentation to model - please wait ...\n", __func__);
2971 const int64_t t_start_aug_us = ggml_time_us();
2972 std::vector<uint8_t> work_buffer;
2973
2974 // Set sparsity threshold via global virables
2975 sparse_pred_threshold = model->hparams.sparse_pred_threshold;
2976#if defined (GGML_USE_CUBLAS)
2977 ggml_cuda_set_device_constants(model->hparams.sparse_pred_threshold);
2978#endif
2979
2980 // load gpu_idx and slice mat to gpu
2981 size_t offloaded_bytes = 0;
2982 for (llama_layer &model_layer : model -> layers) {
2983 // gpu_idx load
2984 if (model_layer.gpu_idx == NULL && model_layer.gpu_bucket == NULL) {
2985 ggml_tensor * gpu_idx = ggml_new_tensor_1d(aux_ctx, GGML_TYPE_I32, model_layer.mlp_pre_w2 -> ne[1]);
2986 ggml_set_zero(gpu_idx);
2987 model_layer.gpu_idx = gpu_idx;
2988 ggml_tensor * gpu_bucket = ggml_new_tensor_1d(aux_ctx, GGML_TYPE_I32, 0);
2989 model_layer.gpu_bucket = gpu_bucket;
2990 }
2991 offloaded_bytes += slice_ffn_mat_to_gpu(model_layer);
2992 LLAMA_LOG_INFO(".");
2993 }
2994
2995 LLAMA_LOG_INFO(" done (%.2f ms)\n", (ggml_time_us() - t_start_aug_us) / 1000.0);
2996 return offloaded_bytes;
2997 }
2998};
2999
3000struct buffered_tensor_allocator {

Callers 1

Calls 3

ggml_time_usFunction · 0.70
ggml_new_tensor_1dFunction · 0.70
ggml_set_zeroFunction · 0.70

Tested by

no test coverage detected