quant_ops.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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("marlin_gemm", &marlin_gemm, "Marlin (Dense) Optimized Quantized GEMM for GPTQ");
  22. quant_ops.def("gptq_marlin_24_gemm", &gptq_marlin_24_gemm, "Marlin_24 (Sparse) Optimized Quantized GEMM for GPTQ");
  23. quant_ops.def("gptq_marlin_gemm", &gptq_marlin_gemm, "gptq_marlin Optimized Quantized GEMM for GPTQ");
  24. quant_ops.def("gptq_marlin_repack", &gptq_marlin_repack, "gptq_marlin repack from GPTQ");
  25. // SmoothQuant+
  26. quant_ops.def("autoquant_convert_s4_k_m8", &autoquant_convert_s4_k_m8, "convert kernel.");
  27. quant_ops.def("autoquant_s4_f16_gemm", &autoquant_s4_f16_gemm, "weight int4 activation float16 gemm kernel.");
  28. // QuIP#
  29. quant_ops.def("quip_decompress", &decompress_e8p_origorder, "decompress_packed_e8p");
  30. quant_ops.def("quip_gemv", &e8p_mm_origorder, "e8p_mm_origorder");
  31. // CUTLASS w8a8
  32. quant_ops.def("cutlass_scaled_mm_dq", &cutlass_scaled_mm_dq, "CUTLASS w8a8 GEMM, supporting symmetric per-tensor or per-row/column quantization.");
  33. #endif
  34. // GPTQ
  35. quant_ops.def("gptq_gemm", &gptq_gemm, "Quantized GEMM for GPTQ");
  36. quant_ops.def("gptq_shuffle", &gptq_shuffle, "Post processing for GPTQ");
  37. quant_ops.def("group_gptq_gemm", &group_gptq_gemm, "Grouped Quantized GEMM for GPTQ");
  38. quant_ops.def("dequant_gptq", &dequant_gptq, "Dequantize gptq weight to half");
  39. // SqueezeLLM
  40. quant_ops.def("squeezellm_gemm", &squeezellm_gemm, "Quantized GEMM for SqueezeLLM");
  41. // ExLlamaV2
  42. quant_ops.def("exl2_make_q_matrix",&make_q_matrix, "preprocess for exl2");
  43. quant_ops.def("exl2_gemm", &exl2_gemm, "exl2 gemm");
  44. // FP8
  45. quant_ops.def("static_scaled_fp8_quant", &static_scaled_fp8_quant, "Compute FP8 quantized tensor for given scaling factor");
  46. quant_ops.def("dynamic_scaled_fp8_quant", &dynamic_scaled_fp8_quant, "Compute FP8 quantized tensor and scaling factor");
  47. }