gptqmodel 1.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. gptqmodel-1.7.0/LICENSE +203 -0
  2. gptqmodel-1.7.0/MANIFEST.in +6 -0
  3. gptqmodel-1.7.0/PKG-INFO +318 -0
  4. gptqmodel-1.7.0/README.md +248 -0
  5. gptqmodel-1.7.0/gptqmodel/__init__.py +20 -0
  6. gptqmodel-1.7.0/gptqmodel/integration/__init__.py +17 -0
  7. gptqmodel-1.7.0/gptqmodel/integration/integration.py +119 -0
  8. gptqmodel-1.7.0/gptqmodel/integration/integration_vllm.py +83 -0
  9. gptqmodel-1.7.0/gptqmodel/integration/src/__init__.py +0 -0
  10. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/__init__.py +0 -0
  11. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/gptq/__init__.py +0 -0
  12. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/gptq/quantizer.py +922 -0
  13. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/gptq/utils.py +25 -0
  14. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/utils/__init__.py +0 -0
  15. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/utils/import_utils.py +495 -0
  16. gptqmodel-1.7.0/gptqmodel/integration/src/optimum/utils/testing_utils.py +198 -0
  17. gptqmodel-1.7.0/gptqmodel/integration/src/peft/__init__.py +0 -0
  18. gptqmodel-1.7.0/gptqmodel/integration/src/peft/import_utils.py +131 -0
  19. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/__init__.py +0 -0
  20. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/adalora/__init__.py +0 -0
  21. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/adalora/model.py +357 -0
  22. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/lora/__init__.py +0 -0
  23. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/lora/gptq.py +122 -0
  24. gptqmodel-1.7.0/gptqmodel/integration/src/peft/tuners/lora/model.py +926 -0
  25. gptqmodel-1.7.0/gptqmodel/integration/src/peft/utils/__init__.py +35 -0
  26. gptqmodel-1.7.0/gptqmodel/integration/src/peft/utils/other.py +740 -0
  27. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/__init__.py +0 -0
  28. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/quantizers/__init__.py +0 -0
  29. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/quantizers/quantizer_gptq.py +108 -0
  30. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/testing_utils.py +2680 -0
  31. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/utils/__init__.py +0 -0
  32. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/utils/import_utils.py +2216 -0
  33. gptqmodel-1.7.0/gptqmodel/integration/src/transformers/utils/quantization_config.py +1367 -0
  34. gptqmodel-1.7.0/gptqmodel/integration/src/vllm/__init__.py +0 -0
  35. gptqmodel-1.7.0/gptqmodel/integration/src/vllm/gptq_marlin.py +627 -0
  36. gptqmodel-1.7.0/gptqmodel/models/__init__.py +19 -0
  37. gptqmodel-1.7.0/gptqmodel/models/_const.py +174 -0
  38. gptqmodel-1.7.0/gptqmodel/models/auto.py +372 -0
  39. gptqmodel-1.7.0/gptqmodel/models/base.py +911 -0
  40. gptqmodel-1.7.0/gptqmodel/models/definitions/__init__.py +61 -0
  41. gptqmodel-1.7.0/gptqmodel/models/definitions/baichuan.py +31 -0
  42. gptqmodel-1.7.0/gptqmodel/models/definitions/bloom.py +35 -0
  43. gptqmodel-1.7.0/gptqmodel/models/definitions/chatglm.py +100 -0
  44. gptqmodel-1.7.0/gptqmodel/models/definitions/codegen.py +29 -0
  45. gptqmodel-1.7.0/gptqmodel/models/definitions/cohere.py +29 -0
  46. gptqmodel-1.7.0/gptqmodel/models/definitions/cohere2.py +30 -0
  47. gptqmodel-1.7.0/gptqmodel/models/definitions/dbrx.py +22 -0
  48. gptqmodel-1.7.0/gptqmodel/models/definitions/dbrx_converted.py +66 -0
  49. gptqmodel-1.7.0/gptqmodel/models/definitions/decilm.py +29 -0
  50. gptqmodel-1.7.0/gptqmodel/models/definitions/deepseek_v2.py +57 -0
  51. gptqmodel-1.7.0/gptqmodel/models/definitions/exaone.py +32 -0
  52. gptqmodel-1.7.0/gptqmodel/models/definitions/gemma.py +29 -0
  53. gptqmodel-1.7.0/gptqmodel/models/definitions/gemma2.py +63 -0
  54. gptqmodel-1.7.0/gptqmodel/models/definitions/glm.py +30 -0
  55. gptqmodel-1.7.0/gptqmodel/models/definitions/gpt2.py +29 -0
  56. gptqmodel-1.7.0/gptqmodel/models/definitions/gpt_bigcode.py +29 -0
  57. gptqmodel-1.7.0/gptqmodel/models/definitions/gpt_neox.py +31 -0
  58. gptqmodel-1.7.0/gptqmodel/models/definitions/gptj.py +29 -0
  59. gptqmodel-1.7.0/gptqmodel/models/definitions/granite.py +29 -0
  60. gptqmodel-1.7.0/gptqmodel/models/definitions/grinmoe.py +37 -0
  61. gptqmodel-1.7.0/gptqmodel/models/definitions/hymba.py +55 -0
  62. gptqmodel-1.7.0/gptqmodel/models/definitions/internlm.py +31 -0
  63. gptqmodel-1.7.0/gptqmodel/models/definitions/internlm2.py +32 -0
  64. gptqmodel-1.7.0/gptqmodel/models/definitions/llama.py +37 -0
  65. gptqmodel-1.7.0/gptqmodel/models/definitions/longllama.py +29 -0
  66. gptqmodel-1.7.0/gptqmodel/models/definitions/minicpm.py +31 -0
  67. gptqmodel-1.7.0/gptqmodel/models/definitions/minicpm3.py +30 -0
  68. gptqmodel-1.7.0/gptqmodel/models/definitions/mistral.py +29 -0
  69. gptqmodel-1.7.0/gptqmodel/models/definitions/mixtral.py +55 -0
  70. gptqmodel-1.7.0/gptqmodel/models/definitions/mllama.py +43 -0
  71. gptqmodel-1.7.0/gptqmodel/models/definitions/mobilellm.py +31 -0
  72. gptqmodel-1.7.0/gptqmodel/models/definitions/moss.py +29 -0
  73. gptqmodel-1.7.0/gptqmodel/models/definitions/mpt.py +29 -0
  74. gptqmodel-1.7.0/gptqmodel/models/definitions/olmo2.py +30 -0
  75. gptqmodel-1.7.0/gptqmodel/models/definitions/opt.py +35 -0
  76. gptqmodel-1.7.0/gptqmodel/models/definitions/ovis.py +106 -0
  77. gptqmodel-1.7.0/gptqmodel/models/definitions/phi.py +31 -0
  78. gptqmodel-1.7.0/gptqmodel/models/definitions/phi3.py +29 -0
  79. gptqmodel-1.7.0/gptqmodel/models/definitions/qwen.py +34 -0
  80. gptqmodel-1.7.0/gptqmodel/models/definitions/qwen2.py +29 -0
  81. gptqmodel-1.7.0/gptqmodel/models/definitions/qwen2_moe.py +38 -0
  82. gptqmodel-1.7.0/gptqmodel/models/definitions/qwen2_vl.py +131 -0
  83. gptqmodel-1.7.0/gptqmodel/models/definitions/rw.py +29 -0
  84. gptqmodel-1.7.0/gptqmodel/models/definitions/stablelmepoch.py +29 -0
  85. gptqmodel-1.7.0/gptqmodel/models/definitions/starcoder2.py +29 -0
  86. gptqmodel-1.7.0/gptqmodel/models/definitions/xverse.py +30 -0
  87. gptqmodel-1.7.0/gptqmodel/models/definitions/yi.py +29 -0
  88. gptqmodel-1.7.0/gptqmodel/models/loader.py +608 -0
  89. gptqmodel-1.7.0/gptqmodel/models/writer.py +387 -0
  90. gptqmodel-1.7.0/gptqmodel/nn_modules/__init__.py +0 -0
  91. gptqmodel-1.7.0/gptqmodel/nn_modules/hooked_linear.py +93 -0
  92. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/__init__.py +183 -0
  93. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/bitblas.py +408 -0
  94. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/bitblas_target_detector.py +87 -0
  95. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/dynamic_cuda.py +144 -0
  96. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/exllama.py +232 -0
  97. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/exllamav2.py +279 -0
  98. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/ipex.py +333 -0
  99. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/marlin.py +420 -0
  100. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/torch.py +293 -0
  101. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/tritonv2.py +206 -0
  102. gptqmodel-1.7.0/gptqmodel/nn_modules/qlinear/utils.py +38 -0
  103. gptqmodel-1.7.0/gptqmodel/nn_modules/triton_utils/__init__.py +0 -0
  104. gptqmodel-1.7.0/gptqmodel/nn_modules/triton_utils/custom_autotune.py +224 -0
  105. gptqmodel-1.7.0/gptqmodel/nn_modules/triton_utils/dequant.py +153 -0
  106. gptqmodel-1.7.0/gptqmodel/nn_modules/triton_utils/kernels.py +475 -0
  107. gptqmodel-1.7.0/gptqmodel/nn_modules/triton_utils/mixin.py +19 -0
  108. gptqmodel-1.7.0/gptqmodel/quantization/__init__.py +19 -0
  109. gptqmodel-1.7.0/gptqmodel/quantization/config.py +432 -0
  110. gptqmodel-1.7.0/gptqmodel/quantization/gptq.py +308 -0
  111. gptqmodel-1.7.0/gptqmodel/quantization/quantizer.py +154 -0
  112. gptqmodel-1.7.0/gptqmodel/utils/__init__.py +19 -0
  113. gptqmodel-1.7.0/gptqmodel/utils/backend.py +32 -0
  114. gptqmodel-1.7.0/gptqmodel/utils/bitblas.py +151 -0
  115. gptqmodel-1.7.0/gptqmodel/utils/calibration.py +27 -0
  116. gptqmodel-1.7.0/gptqmodel/utils/data.py +267 -0
  117. gptqmodel-1.7.0/gptqmodel/utils/device.py +28 -0
  118. gptqmodel-1.7.0/gptqmodel/utils/eval.py +230 -0
  119. gptqmodel-1.7.0/gptqmodel/utils/exllama.py +93 -0
  120. gptqmodel-1.7.0/gptqmodel/utils/image.py +62 -0
  121. gptqmodel-1.7.0/gptqmodel/utils/importer.py +235 -0
  122. gptqmodel-1.7.0/gptqmodel/utils/logger.py +32 -0
  123. gptqmodel-1.7.0/gptqmodel/utils/marlin.py +210 -0
  124. gptqmodel-1.7.0/gptqmodel/utils/mlx.py +124 -0
  125. gptqmodel-1.7.0/gptqmodel/utils/model.py +836 -0
  126. gptqmodel-1.7.0/gptqmodel/utils/openai_server.py +139 -0
  127. gptqmodel-1.7.0/gptqmodel/utils/perplexity.py +242 -0
  128. gptqmodel-1.7.0/gptqmodel/utils/plotly.py +33 -0
  129. gptqmodel-1.7.0/gptqmodel/utils/progress.py +135 -0
  130. gptqmodel-1.7.0/gptqmodel/utils/rocm.py +18 -0
  131. gptqmodel-1.7.0/gptqmodel/utils/sglang.py +71 -0
  132. gptqmodel-1.7.0/gptqmodel/utils/torch.py +72 -0
  133. gptqmodel-1.7.0/gptqmodel/utils/vllm.py +121 -0
  134. gptqmodel-1.7.0/gptqmodel/utils/vram.py +200 -0
  135. gptqmodel-1.7.0/gptqmodel/version.py +16 -0
  136. gptqmodel-1.7.0/gptqmodel.egg-info/PKG-INFO +318 -0
  137. gptqmodel-1.7.0/gptqmodel.egg-info/SOURCES.txt +223 -0
  138. gptqmodel-1.7.0/gptqmodel.egg-info/dependency_links.txt +1 -0
  139. gptqmodel-1.7.0/gptqmodel.egg-info/requires.txt +48 -0
  140. gptqmodel-1.7.0/gptqmodel.egg-info/top_level.txt +6 -0
  141. gptqmodel-1.7.0/gptqmodel_ext/cuda_256/gptqmodel_cuda_256.cpp +70 -0
  142. gptqmodel-1.7.0/gptqmodel_ext/cuda_256/gptqmodel_cuda_kernel_256.cu +554 -0
  143. gptqmodel-1.7.0/gptqmodel_ext/cuda_64/gptqmodel_cuda_64.cpp +70 -0
  144. gptqmodel-1.7.0/gptqmodel_ext/cuda_64/gptqmodel_cuda_kernel_64.cu +554 -0
  145. gptqmodel-1.7.0/gptqmodel_ext/exllama/cu_compat.cuh +58 -0
  146. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_buffers.cu +75 -0
  147. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_buffers.cuh +55 -0
  148. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/column_remap.cu +63 -0
  149. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/column_remap.cuh +19 -0
  150. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/q4_matmul.cu +260 -0
  151. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/q4_matmul.cuh +43 -0
  152. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/q4_matrix.cu +225 -0
  153. gptqmodel-1.7.0/gptqmodel_ext/exllama/cuda_func/q4_matrix.cuh +53 -0
  154. gptqmodel-1.7.0/gptqmodel_ext/exllama/exllama_ext.cpp +260 -0
  155. gptqmodel-1.7.0/gptqmodel_ext/exllama/hip_compat.cuh +53 -0
  156. gptqmodel-1.7.0/gptqmodel_ext/exllama/matrix.cuh +294 -0
  157. gptqmodel-1.7.0/gptqmodel_ext/exllama/tuning.h +13 -0
  158. gptqmodel-1.7.0/gptqmodel_ext/exllama/util.cuh +33 -0
  159. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/config.h +13 -0
  160. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cpp/util.h +12 -0
  161. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/compat.cuh +56 -0
  162. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/compat_gemm.cuh +38 -0
  163. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/matrix_view.cuh +121 -0
  164. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_gemm.cu +211 -0
  165. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_gemm.cuh +33 -0
  166. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_gemm_kernel.cuh +487 -0
  167. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_gemm_kernel_gptq.cuh +223 -0
  168. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_matrix.cu +627 -0
  169. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/q_matrix.cuh +73 -0
  170. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_2.cuh +103 -0
  171. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_3.cuh +169 -0
  172. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_4.cuh +227 -0
  173. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_5.cuh +207 -0
  174. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_6.cuh +44 -0
  175. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_8.cuh +38 -0
  176. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/quant/qdq_util.cuh +51 -0
  177. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/cuda/util.cuh +42 -0
  178. gptqmodel-1.7.0/gptqmodel_ext/exllamav2/ext.cpp +134 -0
  179. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin.cuh +90 -0
  180. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_cuda.cpp +20 -0
  181. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_cuda_kernel.cu +2185 -0
  182. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_cuda_kernel.cuh +8 -0
  183. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_dtypes.cuh +81 -0
  184. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_repack.cu +347 -0
  185. gptqmodel-1.7.0/gptqmodel_ext/marlin/marlin_repack.cuh +16 -0
  186. gptqmodel-1.7.0/requirements.txt +12 -0
  187. gptqmodel-1.7.0/setup.cfg +4 -0
  188. gptqmodel-1.7.0/setup.py +324 -0
  189. gptqmodel-1.7.0/tests/test_asym_gptq_v1.py +34 -0
  190. gptqmodel-1.7.0/tests/test_bits.py +171 -0
  191. gptqmodel-1.7.0/tests/test_dynamic.py +143 -0
  192. gptqmodel-1.7.0/tests/test_estimate_vram.py +48 -0
  193. gptqmodel-1.7.0/tests/test_eval.py +61 -0
  194. gptqmodel-1.7.0/tests/test_evalplus.py +40 -0
  195. gptqmodel-1.7.0/tests/test_flash_attention.py +46 -0
  196. gptqmodel-1.7.0/tests/test_group_size.py +144 -0
  197. gptqmodel-1.7.0/tests/test_ipex_xpu.py +54 -0
  198. gptqmodel-1.7.0/tests/test_lm_eval.py +60 -0
  199. gptqmodel-1.7.0/tests/test_lm_head.py +120 -0
  200. gptqmodel-1.7.0/tests/test_mlx.py +43 -0
  201. gptqmodel-1.7.0/tests/test_mlx_generate.py +33 -0
  202. gptqmodel-1.7.0/tests/test_openai_server.py +48 -0
  203. gptqmodel-1.7.0/tests/test_packing.py +120 -0
  204. gptqmodel-1.7.0/tests/test_perplexity.py +192 -0
  205. gptqmodel-1.7.0/tests/test_q4_bitblas.py +87 -0
  206. gptqmodel-1.7.0/tests/test_q4_cuda.py +84 -0
  207. gptqmodel-1.7.0/tests/test_q4_exllama_v1.py +1208 -0
  208. gptqmodel-1.7.0/tests/test_q4_exllama_v2.py +153 -0
  209. gptqmodel-1.7.0/tests/test_q4_ipex.py +44 -0
  210. gptqmodel-1.7.0/tests/test_q4_marlin.py +134 -0
  211. gptqmodel-1.7.0/tests/test_q4_torch.py +111 -0
  212. gptqmodel-1.7.0/tests/test_q4_torch_apple.py +111 -0
  213. gptqmodel-1.7.0/tests/test_q4_triton.py +98 -0
  214. gptqmodel-1.7.0/tests/test_quant_batch.py +109 -0
  215. gptqmodel-1.7.0/tests/test_quant_formats.py +132 -0
  216. gptqmodel-1.7.0/tests/test_quant_trust_remote.py +75 -0
  217. gptqmodel-1.7.0/tests/test_save_loaded_quantized_model.py +65 -0
  218. gptqmodel-1.7.0/tests/test_serialization.py +58 -0
  219. gptqmodel-1.7.0/tests/test_sglang.py +59 -0
  220. gptqmodel-1.7.0/tests/test_sharded.py +100 -0
  221. gptqmodel-1.7.0/tests/test_tgi.py +123 -0
  222. gptqmodel-1.7.0/tests/test_transformers_integration.py +81 -0
  223. gptqmodel-1.7.0/tests/test_triton.py +104 -0
  224. gptqmodel-1.7.0/tests/test_verify_hash.py +45 -0
  225. gptqmodel-1.7.0/tests/test_vllm.py +179 -0
@@ -0,0 +1,203 @@
1
+ Copyright 2024- ModelCloud.ai. All rights reserved.
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ global-include gptqmodel_ext/**/*.cuh
2
+ global-include gptqmodel_ext/**/*.h
3
+ global-include gptqmodel_ext/**/*.cpp
4
+ global-include gptqmodel_ext/**/*.cu
5
+ global-include gptqmodel_ext/**/*.py
6
+ include requirements.txt
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.2
2
+ Name: gptqmodel
3
+ Version: 1.7.0
4
+ Summary: A LLM quantization package with user-friendly apis. Based on GPTQ algorithm.
5
+ Home-page: https://github.com/ModelCloud/GPTQModel
6
+ Author: ModelCloud
7
+ Author-email: qubitium@modelcloud.ai
8
+ Keywords: gptq,quantization,large-language-models,transformers,4bit,llm
9
+ Platform: linux
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: C++
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: Education
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.9.0
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8.2.2; extra == "test"
26
+ Requires-Dist: parameterized; extra == "test"
27
+ Provides-Extra: quality
28
+ Requires-Dist: ruff==0.4.9; extra == "quality"
29
+ Requires-Dist: isort==5.13.2; extra == "quality"
30
+ Provides-Extra: vllm
31
+ Requires-Dist: vllm>=0.6.4; extra == "vllm"
32
+ Requires-Dist: flashinfer==0.1.6; extra == "vllm"
33
+ Provides-Extra: sglang
34
+ Requires-Dist: sglang>=0.3.2; extra == "sglang"
35
+ Requires-Dist: flashinfer==0.1.6; extra == "sglang"
36
+ Provides-Extra: bitblas
37
+ Requires-Dist: bitblas==0.0.1.dev13; extra == "bitblas"
38
+ Provides-Extra: hf
39
+ Requires-Dist: optimum>=1.21.2; extra == "hf"
40
+ Provides-Extra: ipex
41
+ Requires-Dist: intel_extension_for_pytorch>=2.5.0; extra == "ipex"
42
+ Provides-Extra: auto-round
43
+ Requires-Dist: auto_round>=0.3; extra == "auto-round"
44
+ Provides-Extra: logger
45
+ Requires-Dist: clearml; extra == "logger"
46
+ Requires-Dist: random_word; extra == "logger"
47
+ Requires-Dist: plotly; extra == "logger"
48
+ Provides-Extra: eval
49
+ Requires-Dist: lm_eval>=0.4.7; extra == "eval"
50
+ Requires-Dist: evalplus>=0.3.1; extra == "eval"
51
+ Provides-Extra: triton
52
+ Requires-Dist: triton>=2.0.0; extra == "triton"
53
+ Provides-Extra: openai
54
+ Requires-Dist: uvicorn; extra == "openai"
55
+ Requires-Dist: fastapi; extra == "openai"
56
+ Requires-Dist: pydantic; extra == "openai"
57
+ Provides-Extra: mlx
58
+ Requires-Dist: mlx_lm>=0.20.6; extra == "mlx"
59
+ Dynamic: author
60
+ Dynamic: author-email
61
+ Dynamic: classifier
62
+ Dynamic: description
63
+ Dynamic: description-content-type
64
+ Dynamic: home-page
65
+ Dynamic: keywords
66
+ Dynamic: platform
67
+ Dynamic: provides-extra
68
+ Dynamic: requires-python
69
+ Dynamic: summary
70
+
71
+ <h1 align="center">GPTQModel</h1>
72
+ <p align="center">Production ready LLM model compression/quantization toolkit with accelerated inference support for both cpu/gpu via HF, vLLM, and SGLang.</p>
73
+ <p align="center">
74
+ <a href="https://github.com/ModelCloud/GPTQModel/releases" style="text-decoration:none;"><img alt="GitHub release" src="https://img.shields.io/github/release/ModelCloud/GPTQModel.svg"></a>
75
+ <a href="https://pypi.org/project/gptqmodel/" style="text-decoration:none;"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gptqmodel"></a>
76
+ <a href="https://pepy.tech/projects/gptqmodel" style="text-decoration:none;"><img src="https://static.pepy.tech/badge/gptqmodel" alt="PyPI Downloads"></a>
77
+ <a href="https://github.com/ModelCloud/GPTQModel/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/gptqmodel"></a>
78
+ <a href="https://huggingface.co/modelcloud/"><img src="https://img.shields.io/badge/🤗%20Hugging%20Face-ModelCloud-%23ff8811.svg"></a>
79
+ </p>
80
+
81
+ ## News
82
+ * 01/17/2025 [1.7.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.7.0): 👀 ✨ `backend.MLX` added for runtime-conversion and execution of GPTQ models on Apple's `MLX` framework on Apple Silicon (M1+). Exports of `gptq` models to `mlx` also now possible. We have added `mlx` exported models to [huggingface.co/ModelCloud](https://huggingface.co/collections/ModelCloud/vortex-673743382af0a52b2a8b9fe2). ✨ `lm_head` quantization now fully support by GPTQModel without external pkg dependency.
83
+ * 01/07/2025 [1.6.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.6.1): 🎉 New OpenAI api compatible end-point via `model.serve(host, port)`. Auto-enable flash-attention2 for inference. Fixed `sym=False` loading regression.
84
+ * 01/06/2025 [1.6.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.6.0): ⚡25% faster quantization. 35% reduction in vram usage vs v1.5. 👀 AMD ROCm (6.2+) support added and validated for 7900XT+ GPU. Auto-tokenizer loader via `load()` api. For most models you no longer need to manually init a tokenizer for both inference and quantization.
85
+ * 01/01/2025 [1.5.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.5.1): 🎉 2025! Added `QuantizeConfig.device` to clearly define which device is used for quantization: default = `auto`. Non-quantized models are always loaded on cpu by-default and each layer is moved to `QuantizeConfig.device` during quantization to minimize vram usage. Compatibility fixes for `attn_implementation_autoset` in latest transformers.
86
+ * 12/23/2024 [1.5.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.5.0): Multi-modal (image-to-text) optimized quantization support has been added for Qwen 2-VL and Ovis 1.6-VL. Previous image-to-text model quantizations did not use image calibration data, resulting in less than optimal post-quantization results. Version 1.5.0 is the first release to provide a stable path for multi-modal quantization: only text layers are quantized.
87
+ * 12/19/2024 [1.4.5](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.4.5): Windows 11 support added/validated. Ovis VL model support with image dataset calibration. Fixed `dynamic` loading. Reduced quantization vram usage.
88
+ * 12/15/2024 [1.4.2](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.4.2): MacOS `gpu` (Metal) and `cpu` (M+) support added/validated for inference and quantization. Cohere 2 model support added.
89
+ * 12/13/2024 [1.4.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.4.1): Added Qwen2-VL model support. `mse` quantization control exposed in `QuantizeConfig`. Monkey patch `patch_vllm()` and `patch_hf()` api added to allow Transformers/Optimum/PEFT and vLLM to correctly loaded GPTQModel quantized models while upstream PRs are in pending status.
90
+
91
+
92
+ <details>
93
+
94
+ <summary>Archived News</summary>
95
+ * 12/10/2024 [1.4.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.4.0) `EvalPlus` harness integration merged upstream. We now support both `lm-eval` and `EvalPlus`. Added pure torch `Torch` kernel. Refactored `Cuda` kernel to be `DynamicCuda` kernel. `Triton` kernel now auto-padded for max model support. `Dynamic` quantization now supports both positive `+:`:default, and `-:` negative matching which allows matched modules to be skipped entirely for quantization. Fixed auto-`Marlin` kerenl selection. Added auto-kernel fallback for unsupported kernel/module pairs. Lots of internal refractor and cleanup in-preparation for transformers/optimum/peft upstream PR merge. Deprecated the saving of `Marlin` weight format since `Marlin` supports auto conversion of `gptq` format to `Marlin` during runtime.
96
+
97
+ * 11/29/2024 [1.3.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.3.1) Olmo2 model support. Intel XPU acceleration via IPEX. Model sharding Transformer compat fix due to api deprecation in HF. Removed triton dependency. Triton kernel now optionally dependent on triton pkg.
98
+
99
+ * 11/26/2024 [1.3.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.3.0) Zero-Day Hymba model support. Removed `tqdm` and `rogue` dependency.
100
+ * 11/24/2024 [1.2.3](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.2.3) HF GLM model support. ClearML logging integration. Use `device-smi` and replace `gputil` + `psutil` depends. Fixed model unit tests.
101
+
102
+ * 11/11/2024 🚀 [1.2.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.2.1) Meta MobileLLM model support added. `lm-eval[gptqmodel]` integration merged upstream. Intel/IPEX cpu inference merged replacing QBits (deprecated). Auto-fix/patch ChatGLM-3/GLM-4 compat with latest transformers. New `.load()` and `.save()` api.
103
+
104
+ * 10/29/2024 🚀 [1.1.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.1.0) IBM Granite model support. Full auto-buildless wheel install from pypi. Reduce max cpu memory usage by >20% during quantization. 100% CI model/feature coverage.
105
+
106
+ * 10/12/2024 ✨ [1.0.9](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.9) Move AutoRound to optional and fix pip install regression in v1.0.8.
107
+
108
+ * 10/11/2024 ✨ [1.0.8](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.8) Add wheel for python 3.12 and cuda 11.8.
109
+ * 10/08/2024 ✨ [1.0.7](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.7) Fixed marlin (faster) kernel was not auto-selected for some models.
110
+
111
+ * 09/26/2024 ✨ [1.0.6](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.6) Fixed quantized Llama 3.2 vision quantized loader.
112
+ * 09/26/2024 ✨ [1.0.5](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.5) Partial Llama 3.2 Vision model support (mllama): only text-layer quantization layers are supported for now.
113
+
114
+ * 09/26/2024 ✨ [1.0.4](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.4) Integrated Liger Kernel support for ~1/2 memory reduction on some models during quantization. Added control toggle disable parallel packing.
115
+ * 09/18/2024 ✨ [1.0.3](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.3) Added Microsoft GRIN-MoE and MiniCPM3 support.
116
+ * 08/16/2024 ✨ [1.0.2](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.2) Support Intel/AutoRound v0.3, pre-built whl packages, and PyPI release.
117
+ * 08/14/2024 ✨ [1.0.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.0) 40% faster `packing`, Fixed Python 3.9 compat, added `lm_eval` api.
118
+ * 08/10/2024 🚀 [0.9.11](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.11) Added LG EXAONE 3.0 model support. New `dynamic` per layer/module flexible quantization where each layer/module may have different bits/params. Added proper sharding support to `backend.BITBLAS`. Auto-heal quantization errors due to small damp values.
119
+ * 07/31/2024 🚀 [0.9.10](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.10) Ported vllm/nm `gptq_marlin` inference kernel with expanded bits (8bits), group_size (64,32), and desc_act support for all GPTQ models with `FORMAT.GPTQ`. Auto calculate auto-round nsamples/seglen parameters based on calibration dataset. Fixed save_quantized() called on pre-quantized models with non-supported backends. HF transformers depend updated to ensure Llama 3.1 fixes are correctly applied to both quant and inference.
120
+ * 07/25/2024 🚀 [0.9.9](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.9): Added Llama-3.1 support, Gemma2 27B quant inference support via vLLM, auto pad_token normalization, fixed auto-round quant compat for vLLM/SGLang, and more.
121
+ * 07/13/2024 🚀 [0.9.8](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.8):
122
+ Run quantized models directly using GPTQModel using fast `vLLM` or `SGLang` backend! Both vLLM and SGLang are optimized for dyanamic batching inference for maximum `TPS` (check usage under examples). Marlin backend also
123
+ got full end-to-end in/out features padding to enhance current/future model compatibility.
124
+ * 07/08/2024 🚀 [0.9.7](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.7): InternLM 2.5 model support added.
125
+ * 07/08/2024 🚀 [0.9.6](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.6): [Intel/AutoRound](https://github.com/intel/auto-round) QUANT_METHOD support added for a potentially higher quality quantization with `lm_head` module quantization support for even more vram reduction: format export to `FORMAT.GPTQ` for max inference compatibility.
126
+ * 07/05/2024 🚀 [0.9.5](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.5): Cuda kernels have been fully deprecated in favor of Exllama(v1/v2)/Marlin/Triton.
127
+ * 07/03/2024 🚀 [0.9.4](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.4): HF Transformers integration added and bug fixed Gemma 2 support.
128
+ * 07/02/2024 🚀 [0.9.3](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.3): Added Gemma 2 support, faster PPL calculations on gpu, and more code/arg refractor.
129
+ * 06/30/2024 🚀 [0.9.2](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.2): Added auto-padding of model in/out-features for exllama and exllama v2.
130
+ Fixed quantization of OPT and DeepSeek V2-Lite models. Fixed inference for DeepSeek V2-Lite.
131
+ * 06/29/2024 🚀 [0.9.1](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.1): With 3 new models (DeepSeek-V2, DeepSeek-V2-Lite, DBRX Converted), BITBLAS new format/kernel, proper batching of calibration dataset resulting > 50% quantization speedup, security hash check of loaded model weights, tons of refractor/usability improvements, bugs fixes and much more.
132
+ * 06/20/2924 ✨ [0.9.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.0): Thanks for all the work from ModelCloud team and the opensource ML community for their contributions!
133
+ </details>
134
+
135
+ ## What is GPTQModel?
136
+
137
+ GPTQModel started out as a major refractor (fork) of AutoGPTQ but has now morphed into a full-stand-in replacement with cleaner api, up-to-date model support, faster inference, higher quality quants and a pledge that ModelCloud, together with the open-source ML community, will take every effort to bring the library up-to-date with latest advancements and model support.
138
+
139
+ Public tests/papers and ModelCloud's internal tests have shown that GPTQ is on-par and/or exceeds other 4bit quantization methods in terms of both quality recovery and production-level inference speed for token latency and rps. GPTQ has the optimal blend of quality and inference speed you need in a real-world production deployment.
140
+
141
+ ## Features
142
+ * 🚀 Extensive model support for: `Ovis VL`, `Llama 1-3.3`, `Qwen2-VL`, `Olmo2`, `Hymba`, `GLM`, `IBM Granite`, `Llama 3.2 Vision`, `MiniCPM3`, `GRIN-Moe`, `Phi 1-4`, `EXAONE 3.0`, `InternLM 2.5`, `Gemma 2`, `DeepSeek-V2`, `DeepSeek-V2-Lite`, `ChatGLM`, `MiniCPM`, `Qwen2MoE`, `DBRX`.
143
+ * ✨ Linux, MacOS, Windows platform quantization and accelerated inference support for CUDA (Nvidia), XPU (Intel), ROCm (AMD), MPS (Apple Silicon), CPU (Intel/AMD/Apple Silicon).
144
+ * 💯 100% CI unit-test coverage for all supported models and kernels including post-quantization quality regression.
145
+ * ✨ `Dynamic` mixed quantization control on a per-module basis. Each layer/module can have a unique quantization config or be excluded from quantization all together.
146
+ * 🚀 [vLLM](https://github.com/vllm-project/vllm) and [SGLang](https://github.com/sgl-project/sglang) inference integration for quantized model where format = `FORMAT.GPTQ`
147
+ * 🚀 [Intel/IPEX](https://github.com/intel/intel-extension-for-pytorch) hardware accelerated quantization/inference for CPU [`avx`, `amx`, `xmx`] and Intel GPU [`Arc` + `Datacenter Max`].
148
+ * 🚀 [Microsoft/BITBLAS](https://github.com/microsoft/BitBLAS) format + dynamically compiled inference.
149
+ * ✨ [Intel/AutoRound](https://github.com/intel/auto-round) alternative gptq-inference compatible quantization method.
150
+ * ✨ Asymmetric `Sym=False` support.
151
+ * ✨ `lm_head` module quant inference support for further VRAM reduction (auto-round only).
152
+ * ✨ Model weights sharding support with optional hash check of model weights on load.
153
+ * 🚀 40% faster `packing` stage in quantization (Llama 3.1 8B). 50% faster PPL calculations (OPT).
154
+
155
+ ## Quality: GPTQ 4bit can match BF16:
156
+ 🤗 [ModelCloud quantized Vortex models on HF](https://huggingface.co/collections/ModelCloud/vortex-673743382af0a52b2a8b9fe2)
157
+
158
+ ![image](https://github.com/user-attachments/assets/7b2db012-b8af-4d19-a25d-7023cef19220)
159
+
160
+ ## Model Support
161
+ | Model | | | | | | | | | |
162
+ |------------------|----|----------------|----|------------------|----|------------|----|----|---|
163
+ | Baichuan | ✅ | Falcon | ✅ | Llama 1-3.3 | ✅ | OLMo2 | ✅ | Yi | ✅ |
164
+ | Bloom | ✅ | Gemma 2 | ✅ | Llama 3.2 VL | ✅ | Ovis 1.6 | ✅ | | |
165
+ | ChatGLM | ✅ | GPTBigCod | ✅ | LongLLaMA | ✅ | Phi 1-4 | ✅ | | |
166
+ | CodeGen | ✅ | GPTNeoX | ✅ | MiniCPM3 | ✅ | Qwen | ✅ | | |
167
+ | Cohere 1-2 | ✅ | GPT-2 | ✅ | Mistral | ✅ | Qwen2 MoE | ✅ | | |
168
+ | DBRX Converted | ✅ | GPT-J | ✅ | Mixtral | ✅ | Qwen2 VL | ✅ | | |
169
+ | Deci | ✅ | Granite | ✅ | MobileLLM | ✅ | RefinedWeb | ✅ | | |
170
+ | DeepSeek-V2 | ✅ | GRIN-MoE | ✅ | MOSS | ✅ | StableLM | ✅ | | |
171
+ | DeepSeek-V2-Lite | ✅ | Hymba | ✅ | MPT | ✅ | StarCoder2 | ✅ | | |
172
+ | EXAONE 3.0 | ✅ | InternLM 1/2.5 | ✅ | OPT | ✅ | XVERSE | ✅ | | |
173
+
174
+ ## Platform and HW Support
175
+
176
+ GPTQModel is validated for Linux, MacOS, and Windows 11:
177
+
178
+ | Platform | Device | | Optimized Arch | Kernels |
179
+ |-----------------|---------------| --- | -------------- | -------------- |
180
+ | 🐧 Linux | Nvidia GPU | ✅ | `Ampere+` | Marlin, Exllama V2, Exallma V1, Triton, DyanamicCuda, Torch |
181
+ | 🐧 Linux | Intel XPU | ✅ | `Arc`, `Datacenter Max` | IPEX, Torch |
182
+ | 🐧 Linux | AMD GPU | ✅ | `7900XT+`, `ROCm 6.2+` | Exllama V2, Exallma V1, DyanamicCuda, Torch |
183
+ | 🐧 Linux | Intel/AMD CPU | ✅ | `avx`, `amx`, `xmx` | IPEX, Torch |
184
+ | 🍎 MacOS | GPU (Metal) / CPU | ✅ | `Apple Silicon`, `M1+` | Torch |
185
+ | 🪟 Windows | GPU (Nvidia) / CPU | ✅ | `Nvidia` | DynamicCuda, Torch |
186
+
187
+ ## Install
188
+
189
+ ### PIP/UV
190
+
191
+ ```bash
192
+ # You can install optional modules like autoround, ipex, vllm, sglang, bitblas, and ipex.
193
+ # Example: pip install -v --no-build-isolation gptqmodel[vllm,sglang,bitblas,ipex,auto_round]
194
+ pip install -v gptqmodel --no-build-isolation
195
+ uv pip install -v gptqmodel --no-build-isolation
196
+ ```
197
+
198
+ ### Install from source
199
+
200
+ ```bash
201
+ # clone repo
202
+ git clone https://github.com/ModelCloud/GPTQModel.git && cd GPTQModel
203
+
204
+ # pip: compile and install
205
+ # You can install optional modules like autoround, ipex, vllm, sglang, bitblas, and ipex.
206
+ # Example: pip install -v --no-build-isolation .[vllm,sglang,bitblas,ipex,auto_round]
207
+ pip install -v . --no-build-isolation
208
+ ```
209
+
210
+ ### Inference
211
+ Two line api to use `GPTQModel` for gptq model inference:
212
+
213
+ ```py
214
+ from gptqmodel import GPTQModel
215
+
216
+ model = GPTQModel.load("ModelCloud/Llama-3.2-1B-Instruct-gptqmodel-4bit-vortex-v2.5")
217
+ result = model.generate("Uncovering deep insights begins with")[0]
218
+ ```
219
+
220
+
221
+ ### OpenAI API compatible end-point
222
+ ```py
223
+ # load model using above inference guide first
224
+ model.serve(host="0.0.0.0",port="12345")
225
+ ```
226
+
227
+ ### Quantization
228
+ Basic example of using `GPTQModel` to quantize a llm model:
229
+
230
+ ```py
231
+ from datasets import load_dataset
232
+ from gptqmodel import GPTQModel, QuantizeConfig
233
+
234
+ model_id = "meta-llama/Llama-3.2-1B-Instruct"
235
+ quant_path = "Llama-3.2-1B-Instruct-gptqmodel-4bit"
236
+
237
+ calibration_dataset = load_dataset(
238
+ "allenai/c4",
239
+ data_files="en/c4-train.00001-of-01024.json.gz",
240
+ split="train"
241
+ ).select(range(1024))["text"]
242
+
243
+ quant_config = QuantizeConfig(bits=4, group_size=128)
244
+
245
+ model = GPTQModel.load(model_id, quant_config)
246
+
247
+ # increase `batch_size` to match gpu/vram specs to speed up quantization
248
+ model.quantize(calibration_dataset, batch_size=2)
249
+
250
+ model.save(quant_path)
251
+
252
+ # test post-quant inference
253
+ model = GPTQModel.load(quant_path)
254
+ result = model.generate("Uncovering deep insights begins with")[0]
255
+ ```
256
+
257
+ For more advanced features of model quantization, please reference to [this script](https://github.com/ModelCloud/GPTQModel/blob/main/examples/quantization/basic_usage_wikitext2.py)
258
+
259
+ ### How to Add Support for a New Model
260
+
261
+ Read the [`gptqmodel/models/llama.py`](https://github.com/ModelCloud/GPTQModel/blob/5627f5ffeb3f19b1a2a97e3b6de6fbe668b0dc42/gptqmodel/models/llama.py) code which explains in detail via comments how the model support is defined. Use it as guide to PR for to new models. Most models follow the same pattern.
262
+
263
+ ### Evaluation and Quality Benchmarks
264
+
265
+ GPTQModel inference is integrated into both [lm-eval](https://github.com/EleutherAI/lm-evaluation-harness) and [evalplus](https://github.com/evalplus/evalplus)
266
+ We highly recommend avoid using `ppl` and use `lm-eval`/`evalplus` to validate post-quantization model quality. `ppl` should only be used for regression tests and is not a good indicator of model output quality.
267
+
268
+ ```
269
+ # gptqmodel is integrated into lm-eval >= v0.4.7
270
+ pip install lm-eval>=0.4.7
271
+ ```
272
+
273
+ ```
274
+ # gptqmodel is integrated into evalplus[main]
275
+ pip install -U "evalplus @ git+https://github.com/evalplus/evalplus"
276
+ ```
277
+
278
+ Below is a basic sample using `GPTQModel.eval` API
279
+
280
+ ```py
281
+ from gptqmodel import GPTQModel
282
+ from gptqmodel.utils import EVAL
283
+
284
+ model_id = "ModelCloud/Llama-3.2-1B-Instruct-gptqmodel-4bit-vortex-v1"
285
+
286
+ # Use `lm-eval` as framework to evaluate the model
287
+ lm_eval_results = GPTQModel.eval(model_id, framework=EVAL.LM_EVAL, tasks=[EVAL.LM_EVAL.ARC_CHALLENGE], output_file='lm-eval_result.json')
288
+
289
+ # Use `evalplus` as framework to evaluate the model
290
+ evalplus_results = GPTQModel.eval(model_id, framework=EVAL.EVALPLUS, tasks=[EVAL.EVALPLUS.HUMAN], output_file='evalplus_result.json')
291
+ ```
292
+
293
+ ## Citation
294
+ ```
295
+ @misc{gptqmodel,
296
+ author = {ModelCloud.ai and qubitium@modelcloud.ai},
297
+ title = {GPTQModel},
298
+ year = {2024},
299
+ publisher = {GitHub},
300
+ journal = {GitHub repository},
301
+ howpublished = {\url{https://github.com/modelcloud/gptqmodel}},
302
+ note = {Contact: qubitium@modelcloud.ai}
303
+ }
304
+
305
+ @article{frantar-gptq,
306
+ title={{GPTQ}: Accurate Post-training Compression for Generative Pretrained Transformers},
307
+ author={Elias Frantar and Saleh Ashkboos and Torsten Hoefler and Dan Alistarh},
308
+ year={2022},
309
+ journal={arXiv preprint arXiv:2210.17323}
310
+ }
311
+
312
+ @article{frantar2024marlin,
313
+ title={MARLIN: Mixed-Precision Auto-Regressive Parallel Inference on Large Language Models},
314
+ author={Frantar, Elias and Castro, Roberto L and Chen, Jiale and Hoefler, Torsten and Alistarh, Dan},
315
+ journal={arXiv preprint arXiv:2408.11743},
316
+ year={2024}
317
+ }
318
+ ```