quant_ops.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "quant_ops.h"
  2. #include <torch/extension.h>
  3. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  4. // Aphrodite quantization ops
  5. pybind11::module quant_ops = m.def_submodule("quant_ops", "Aphrodite custom quant operators");
  6. #ifndef USE_ROCM
  7. // AQLM
  8. quant_ops.def("aqlm_gemm", &aqlm_gemm, "Quantized GEMM for AQLM");
  9. quant_ops.def("aqlm_dequant", &aqlm_dequant, "Dequantization for AQLM");
  10. // AWQ
  11. quant_ops.def("awq_gemm", &awq_gemm, "Quantized GEMM for AWQ");
  12. quant_ops.def("awq_dequantize", &awq_dequantize, "Dequantization for AWQ");
  13. quant_ops.def("awq_group_gemm", &awq_group_gemm, "Grouped Quantized GEMM for AWQ");
  14. // GGUF
  15. quant_ops.def("ggml_dequantize", &ggml_dequantize, "ggml_dequantize");
  16. quant_ops.def("ggml_mul_mat_vec", &ggml_mul_mat_vec, "ggml_mul_mat_vec");
  17. quant_ops.def("ggml_mul_mat_vec_a8", &ggml_mul_mat_vec_a8, "ggml_mul_mat_vec_a8");
  18. quant_ops.def("ggml_mul_mat_a8", &ggml_mul_mat_a8, "ggml_mul_mat_a8");
  19. // Marlin
  20. quant_ops.def("marlin_gemm", &marlin_gemm, "Marlin Optimized Quantized GEMM for GPTQ");
  21. quant_ops.def("gptq_marlin_gemm", &gptq_marlin_gemm, "gptq_marlin Optimized Quantized GEMM for GPTQ");
  22. quant_ops.def("gptq_marlin_repack", &gptq_marlin_repack, "gptq_marlin repack from GPTQ");
  23. quant_ops.def("autoquant_convert_s4_k_m8", &autoquant_convert_s4_k_m8, "convert kernel.");
  24. quant_ops.def("autoquant_s4_f16_gemm", &autoquant_s4_f16_gemm, "weight int4 activation float16 gemm kernel.");
  25. quant_ops.def("quip_decompress", &decompress_e8p_origorder, "decompress_packed_e8p");
  26. quant_ops.def("quip_gemv", &e8p_mm_origorder, "e8p_mm_origorder");
  27. #endif
  28. quant_ops.def("gptq_gemm", &gptq_gemm, "Quantized GEMM for GPTQ");
  29. quant_ops.def("gptq_shuffle", &gptq_shuffle, "Post processing for GPTQ");
  30. quant_ops.def("group_gptq_gemm", &group_gptq_gemm, "Grouped Quantized GEMM for GPTQ");
  31. quant_ops.def("dequant_gptq", &dequant_gptq, "Dequantize gptq weight to half");
  32. quant_ops.def("squeezellm_gemm", &squeezellm_gemm, "Quantized GEMM for SqueezeLLM");
  33. quant_ops.def("exl2_make_q_matrix",&make_q_matrix, "preprocess for exl2");
  34. quant_ops.def("exl2_gemm", &exl2_gemm, "exl2 gemm");
  35. quant_ops.def("static_scaled_fp8_quant", &static_scaled_fp8_quant, "Compute FP8 quantized tensor for given scaling factor");
  36. quant_ops.def("dynamic_scaled_fp8_quant", &dynamic_scaled_fp8_quant, "Compute FP8 quantized tensor and scaling factor");
  37. }