10-quantize-progress.diff 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. diff --git a/llama.cpp b/llama.cpp
  2. index 61948751..2c683ef6 100644
  3. --- a/llama.cpp
  4. +++ b/llama.cpp
  5. @@ -15586,6 +15586,15 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
  6. const auto tn = LLM_TN(model.arch);
  7. new_ofstream(0);
  8. for (int i = 0; i < ml.n_tensors; ++i) {
  9. +
  10. + if (params->quantize_callback){
  11. + LLAMA_LOG_INFO("ENTERED CALLBACK\n");
  12. + if (!params->quantize_callback(i, params->quantize_callback_data)) {
  13. + return;
  14. + }
  15. + LLAMA_LOG_INFO("CURRENTLY AT ", i/ml.n_tensors * 100);
  16. + }
  17. +
  18. auto weight = ml.get_weight(i);
  19. struct ggml_tensor * tensor = weight->tensor;
  20. if (weight->idx != cur_split && params->keep_split) {
  21. @@ -16119,6 +16128,8 @@ struct llama_model_quantize_params llama_model_quantize_default_params() {
  22. /*.keep_split =*/ false,
  23. /*.imatrix =*/ nullptr,
  24. /*.kv_overrides =*/ nullptr,
  25. + /*.quantize_callback =*/ nullptr,
  26. + /*.quantize_callback_data =*/ nullptr,
  27. };
  28. return result;
  29. diff --git a/llama.h b/llama.h
  30. index da310ffa..9b48d889 100644
  31. --- a/llama.h
  32. +++ b/llama.h
  33. @@ -337,6 +337,9 @@ extern "C" {
  34. bool keep_split; // quantize to the same number of shards
  35. void * imatrix; // pointer to importance matrix data
  36. void * kv_overrides; // pointer to vector containing overrides
  37. +
  38. + llama_progress_callback quantize_callback;
  39. + void * quantize_callback_data;
  40. } llama_model_quantize_params;
  41. // grammar types