gptqmodel 1.0.1__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.
- gptqmodel-1.0.1/LICENSE +201 -0
- gptqmodel-1.0.1/MANIFEST.in +6 -0
- gptqmodel-1.0.1/PKG-INFO +320 -0
- gptqmodel-1.0.1/README.md +291 -0
- gptqmodel-1.0.1/gptqmodel/__init__.py +5 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/__init__.py +3 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/_base.py +65 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/_utils/__init__.py +0 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/_utils/classification_utils.py +42 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/_utils/data_utils.py +263 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/_utils/generation_utils.py +34 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/language_modeling_task.py +45 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/sequence_classification_task.py +101 -0
- gptqmodel-1.0.1/gptqmodel/eval_tasks/text_summarization_task.py +70 -0
- gptqmodel-1.0.1/gptqmodel/integration/__init__.py +1 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/__init__.py +2 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/constants.py +23 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/data.py +257 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/hf_quantizer_gptq.py +88 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/quantizer.py +883 -0
- gptqmodel-1.0.1/gptqmodel/integration/optimum/utils.py +153 -0
- gptqmodel-1.0.1/gptqmodel/models/__init__.py +37 -0
- gptqmodel-1.0.1/gptqmodel/models/_const.py +64 -0
- gptqmodel-1.0.1/gptqmodel/models/auto.py +143 -0
- gptqmodel-1.0.1/gptqmodel/models/baichuan.py +16 -0
- gptqmodel-1.0.1/gptqmodel/models/base.py +1495 -0
- gptqmodel-1.0.1/gptqmodel/models/bloom.py +20 -0
- gptqmodel-1.0.1/gptqmodel/models/chatglm.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/codegen.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/cohere.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/dbrx.py +7 -0
- gptqmodel-1.0.1/gptqmodel/models/dbrx_converted.py +51 -0
- gptqmodel-1.0.1/gptqmodel/models/decilm.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/deepseek_v2.py +42 -0
- gptqmodel-1.0.1/gptqmodel/models/exaone.py +17 -0
- gptqmodel-1.0.1/gptqmodel/models/gemma.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/gemma2.py +55 -0
- gptqmodel-1.0.1/gptqmodel/models/gpt2.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/gpt_bigcode.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/gpt_neox.py +16 -0
- gptqmodel-1.0.1/gptqmodel/models/gptj.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/internlm.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/internlm2.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/llama.py +22 -0
- gptqmodel-1.0.1/gptqmodel/models/longllama.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/minicpm.py +16 -0
- gptqmodel-1.0.1/gptqmodel/models/mistral.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/mixtral.py +40 -0
- gptqmodel-1.0.1/gptqmodel/models/moss.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/mpt.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/opt.py +20 -0
- gptqmodel-1.0.1/gptqmodel/models/phi.py +16 -0
- gptqmodel-1.0.1/gptqmodel/models/phi3.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/qwen.py +19 -0
- gptqmodel-1.0.1/gptqmodel/models/qwen2.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/qwen2_moe.py +23 -0
- gptqmodel-1.0.1/gptqmodel/models/rw.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/stablelmepoch.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/starcoder2.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/xverse.py +14 -0
- gptqmodel-1.0.1/gptqmodel/models/yi.py +14 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/__init__.py +0 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/__init__.py +94 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/bitblas_target_detector.py +106 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_bitblas.py +379 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_exllama.py +192 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_exllamav2.py +236 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_marlin.py +268 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_marlin_inference.py +315 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_qbits.py +334 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/qlinear/qlinear_tritonv2.py +139 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/triton_utils/__init__.py +0 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/triton_utils/custom_autotune.py +209 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/triton_utils/dequant.py +138 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/triton_utils/kernels.py +461 -0
- gptqmodel-1.0.1/gptqmodel/nn_modules/triton_utils/mixin.py +4 -0
- gptqmodel-1.0.1/gptqmodel/quantization/__init__.py +4 -0
- gptqmodel-1.0.1/gptqmodel/quantization/config.py +387 -0
- gptqmodel-1.0.1/gptqmodel/quantization/gptq.py +224 -0
- gptqmodel-1.0.1/gptqmodel/quantization/quantizer.py +142 -0
- gptqmodel-1.0.1/gptqmodel/utils/__init__.py +2 -0
- gptqmodel-1.0.1/gptqmodel/utils/backend.py +21 -0
- gptqmodel-1.0.1/gptqmodel/utils/bitblas.py +137 -0
- gptqmodel-1.0.1/gptqmodel/utils/data.py +260 -0
- gptqmodel-1.0.1/gptqmodel/utils/device.py +13 -0
- gptqmodel-1.0.1/gptqmodel/utils/exllama.py +79 -0
- gptqmodel-1.0.1/gptqmodel/utils/importer.py +75 -0
- gptqmodel-1.0.1/gptqmodel/utils/marlin.py +204 -0
- gptqmodel-1.0.1/gptqmodel/utils/model.py +696 -0
- gptqmodel-1.0.1/gptqmodel/utils/perplexity.py +227 -0
- gptqmodel-1.0.1/gptqmodel/utils/sglang.py +56 -0
- gptqmodel-1.0.1/gptqmodel/utils/vllm.py +67 -0
- gptqmodel-1.0.1/gptqmodel/version.py +1 -0
- gptqmodel-1.0.1/gptqmodel.egg-info/PKG-INFO +320 -0
- gptqmodel-1.0.1/gptqmodel.egg-info/SOURCES.txt +145 -0
- gptqmodel-1.0.1/gptqmodel.egg-info/dependency_links.txt +1 -0
- gptqmodel-1.0.1/gptqmodel.egg-info/requires.txt +41 -0
- gptqmodel-1.0.1/gptqmodel.egg-info/top_level.txt +5 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cu_compat.cuh +58 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_buffers.cu +75 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_buffers.cuh +55 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/column_remap.cu +63 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/column_remap.cuh +19 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/q4_matmul.cu +260 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/q4_matmul.cuh +43 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/q4_matrix.cu +225 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/cuda_func/q4_matrix.cuh +53 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/exllama_ext.cpp +260 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/hip_compat.cuh +53 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/matrix.cuh +294 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/tuning.h +13 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllama/util.cuh +33 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/config.h +13 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cpp/util.h +12 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/compat.cuh +56 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/compat_gemm.cuh +38 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/matrix_view.cuh +121 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_gemm.cu +211 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_gemm.cuh +33 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_gemm_kernel.cuh +487 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_gemm_kernel_gptq.cuh +223 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_matrix.cu +627 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/q_matrix.cuh +73 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_2.cuh +103 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_3.cuh +169 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_4.cuh +227 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_5.cuh +207 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_6.cuh +44 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_8.cuh +38 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/quant/qdq_util.cuh +51 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/cuda/util.cuh +42 -0
- gptqmodel-1.0.1/gptqmodel_ext/exllamav2/ext.cpp +134 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin/marlin_cuda.cpp +80 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin/marlin_cuda_kernel.cu +849 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin/marlin_cuda_kernel.cuh +20 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin/marlin_repack.cu +93 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin/marlin_repack.cuh +12 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin.cuh +90 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_cuda.cpp +20 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_cuda_kernel.cu +2185 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_cuda_kernel.cuh +8 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_dtypes.cuh +81 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_repack.cu +347 -0
- gptqmodel-1.0.1/gptqmodel_ext/marlin_inference/marlin_repack.cuh +16 -0
- gptqmodel-1.0.1/requirements.txt +19 -0
- gptqmodel-1.0.1/setup.cfg +4 -0
- gptqmodel-1.0.1/setup.py +186 -0
gptqmodel-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
gptqmodel-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gptqmodel
|
|
3
|
+
Version: 1.0.1
|
|
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 :: C++
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.8.0
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Provides-Extra: quality
|
|
24
|
+
Provides-Extra: vllm
|
|
25
|
+
Provides-Extra: sglang
|
|
26
|
+
Provides-Extra: bitblas
|
|
27
|
+
Provides-Extra: hf
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
|
|
30
|
+
<h1 align="center">GPTQModel</h1>
|
|
31
|
+
<p align="center">An easy-to-use LLM quantization and inference toolkit based on GPTQ algorithm (weight-only quantization).</p>
|
|
32
|
+
<p align="center">
|
|
33
|
+
<a href="https://github.com/ModelCloud/GPTQModel/releases">
|
|
34
|
+
<img alt="GitHub release" src="https://img.shields.io/github/release/ModelCloud/GPTQModel.svg">
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://pypi.org/project/model-gptq/">
|
|
37
|
+
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dd/gptq-model">
|
|
38
|
+
</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
## News
|
|
42
|
+
* 08/14/2024 ✨✨ [v1.0.0](https://github.com/ModelCloud/GPTQModel/releases/tag/v1.0.0) 40% faster `packing`, Fixed Python 3.9 compat, added `lm_eval` api.
|
|
43
|
+
* 08/10/2024 🚀🚀🚀 [v0.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.
|
|
44
|
+
* 07/31/2024 🚀🚀 [v0.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.
|
|
45
|
+
* 07/25/2024 🚀 [v0.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.
|
|
46
|
+
* 07/13/2024 🚀🚀🚀 [v0.9.8](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.8):
|
|
47
|
+
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
|
|
48
|
+
got full end-to-end in/out features padding to enhance current/future model compatibility.
|
|
49
|
+
<details>
|
|
50
|
+
|
|
51
|
+
<summary>Archived News:</summary>
|
|
52
|
+
|
|
53
|
+
* 07/08/2024 🚀 [v0.9.7](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.7): InternLM 2.5 model support added.
|
|
54
|
+
|
|
55
|
+
* 07/08/2024 🚀🚀 [v0.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.
|
|
56
|
+
|
|
57
|
+
* 07/05/2024 🚀🚀 [v0.9.5](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.5): [Intel/QBits](https://github.com/intel/intel-extension-for-transformers) support added for [2,3,4,8] bit quantization/inference on CPU. Cuda kernels have been fully deprecated in favor of Exllama(v1/v2)/Marlin/Triton.
|
|
58
|
+
|
|
59
|
+
* 07/03/2024 🚀 [v0.9.4](https://github.com/ModelCloud/GPTQModel/releases/tag/v0.9.4): HF Transformers integration added and bug fixed Gemma 2 support.
|
|
60
|
+
|
|
61
|
+
* 07/02/2024 🚀 [v0.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.
|
|
62
|
+
|
|
63
|
+
* 06/30/2024 🚀 [v0.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.
|
|
64
|
+
Fixed quantization of OPT and DeepSeek V2-Lite models. Fixed inference for DeepSeek V2-Lite.
|
|
65
|
+
|
|
66
|
+
* 06/29/2024 🚀🚀🚀 [v0.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.
|
|
67
|
+
|
|
68
|
+
* 06/20/2924 ✨ GPTQModel [v0.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!
|
|
69
|
+
</details>
|
|
70
|
+
|
|
71
|
+
## Mission Statement
|
|
72
|
+
|
|
73
|
+
We want GPTQModel to be highly focused on GPTQ based quantization and target inference compatibility with HF Transformers, vLLM, and SGLang.
|
|
74
|
+
|
|
75
|
+
## How is GPTQModel different from AutoGPTQ?
|
|
76
|
+
|
|
77
|
+
GPTQModel is an opinionated fork/refactor of AutoGPTQ with latest bug fixes, more model support, faster quant inference, faster quantization, better quants (as measured in PPL) and a pledge from the ModelCloud team and that we, along with the open-source ML community, will take every effort to bring the library up-to-date with latest advancements, model support, and bug fixes.
|
|
78
|
+
|
|
79
|
+
We will backport bug fixes to AutoGPTQ on a case-by-case basis.
|
|
80
|
+
|
|
81
|
+
## Major Changes (Advantages) vs AutoGPTQ
|
|
82
|
+
* 🚀🚀🚀🚀 Extensive model support for: `EXAONE 3.0`, `InternLM 2.5`, `Gemma 2`, `DeepSeek-V2`, `DeepSeek-V2-Lite`, `ChatGLM`, `MiniCPM`, `Phi-3`, `Qwen2MoE`, `DBRX` (Converted).
|
|
83
|
+
* 🚀🚀 vLLM inference integration for quantized model where format = `FORMAT.GPTQ`
|
|
84
|
+
* 🚀🚀 SGLang inference integration for quantized model where format = `FORMAT.GPTQ`
|
|
85
|
+
* 🚀 [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.
|
|
86
|
+
* 🚀 [Intel/QBits](https://github.com/intel/intel-extension-for-transformers) support added for [2,3,4,8] bit quantization/inference on CPU.
|
|
87
|
+
* 🚀 [BITBLAS](https://github.com/microsoft/BitBLAS) format/inference support from Microsoft
|
|
88
|
+
* 🚀`Sym=False` Support. AutoGPTQ has unusable `sym=false`. (Re-quant required)
|
|
89
|
+
* 🚀`lm_head` module quant inference support for further VRAM reduction.
|
|
90
|
+
* 🚀 Faster quantization: More than 50% faster for TinyLlama + 4090 with batching and large calibration dataset.
|
|
91
|
+
* 🚀 Better quality quants as measured by PPL. (Test config: defaults + `sym=True` + `FORMAT.GPTQ`, TinyLlama)
|
|
92
|
+
* 🚀 Model weights sharding support
|
|
93
|
+
* 🚀 Security: hash check of model weights on load
|
|
94
|
+
* 🚀 Over 50% faster PPL calculations (OPT)
|
|
95
|
+
* 🚀 Over 40% faster `packing` stage in quantization (Llama 3.1 8B)
|
|
96
|
+
* ✨ Alert users of sub-optimal calibration data. Most new users get this part horribly wrong.
|
|
97
|
+
* ✨ Increased compatibility with newest models with auto-padding of in/out-features for [ Exllama, Exllama V2 ] backends.
|
|
98
|
+
* 👾 Removed non-working, partially working, or fully deprecated features: Peft, ROCM, AWQ Gemm inference, Triton v1 (replaced by v2), Fused Attention (Replaced by Marlin/Exllama).
|
|
99
|
+
* 👾 <del>Fixed packing Performance regression on high core-count systems.</del> Backported to AutoGPTQ
|
|
100
|
+
* 👾 <del>Fixed crash on H100.</del> Backported to AutoGPTQ
|
|
101
|
+
* ✨ 10s of thousands of lines of refactor/cleanup.
|
|
102
|
+
* ✨ Over 8+ overly complex api args removed/merged into simple human-readable args.
|
|
103
|
+
* ✨ Added CI workflow for validation of future PRs and prevent code regressions.
|
|
104
|
+
* ✨ Added perplexity unit-test to prevent against model quant quality regressions.
|
|
105
|
+
* 👾 De-bloated 271K lines of which 250K was caused by a single dataset used only by an example.
|
|
106
|
+
* 👾 De-bloat the number of args presented in public `.from_quantized()`/`.from_pretrained()` api
|
|
107
|
+
* ✨ Shorter and more concise public api/internal vars. No need to mimic HF style for verbose class names.
|
|
108
|
+
* ✨ Everything that did not pass unit-tests have been removed from repo.
|
|
109
|
+
|
|
110
|
+
## Model Support ( 🚀 GPTQModel only )
|
|
111
|
+
[Ready to deply quantized models](https://hf.co/ModelCloud)
|
|
112
|
+
|
|
113
|
+
| Model | | | | | | | |
|
|
114
|
+
|------------------|----|-----------------------|----|-----------|----|------------|----|
|
|
115
|
+
| Baichuan | ✅ | EXAONE 3.0 | 🚀 | LongLLaMA | ✅ | Qwen2MoE | 🚀 |
|
|
116
|
+
| Bloom | ✅ | Falon | ✅ | MiniCPM | 🚀 | RefinedWeb | ✅ |
|
|
117
|
+
| ChatGLM | 🚀 | Gemma 2 | 🚀 | Mistral | ✅ | StableLM | ✅ |
|
|
118
|
+
| CodeGen | ✅ | GPTBigCod | ✅ | Mixtral | ✅ | StarCoder2 | ✅ |
|
|
119
|
+
| Cohere | ✅ | GPTNeoX | ✅ | MOSS | ✅ | XVERSE | ✅ |
|
|
120
|
+
| DBRX Converted | 🚀 | GPT-2 | ✅ | MPT | ✅ | Yi | ✅ |
|
|
121
|
+
| Deci | ✅ | GPT-J | ✅ | OPT | ✅ | | |
|
|
122
|
+
| DeepSeek-V2 | 🚀 | InternLM/InternLM 2.5 | 🚀 | Phi/Phi-3 | 🚀 | | |
|
|
123
|
+
| DeepSeek-V2-Lite | 🚀 | Llama | ✅ | Qwen | ✅ | | |
|
|
124
|
+
|
|
125
|
+
## Compatiblity
|
|
126
|
+
|
|
127
|
+
We aim for 100% compatibility with models quanted by AutoGPTQ <= 0.7.1 and will consider syncing future compatibilty on a case-by-case basis.
|
|
128
|
+
|
|
129
|
+
## Platform/GPU Requirements
|
|
130
|
+
|
|
131
|
+
GPTQModel is currently Linux only and requires CUDA capability >= 6.0 Nvidia GPU.
|
|
132
|
+
|
|
133
|
+
WSL on Windows should work as well.
|
|
134
|
+
|
|
135
|
+
ROCM/AMD support will be re-added in a future version after everything on ROCM has been validated. Only fully validated features will be re-added from the original AutoGPTQ repo.
|
|
136
|
+
|
|
137
|
+
## Install
|
|
138
|
+
|
|
139
|
+
### Install from source
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# clone repo
|
|
143
|
+
git clone https://github.com/ModelCloud/GPTQModel.git && cd GPTQModel
|
|
144
|
+
|
|
145
|
+
# compile and install
|
|
146
|
+
# You can optionally include specific modules like vllm, sglang, or bitblas by adding them in brackets. Example: pip install -vvv --no-build-isolation .[vllm,sglang,bitblas]
|
|
147
|
+
pip install -vvv --no-build-isolation .
|
|
148
|
+
|
|
149
|
+
# If you have `uv` package version 0.1.16 or higher, you can use `uv pip` for potentially better dependency management
|
|
150
|
+
# Include modules as needed: uv pip install -vvv --no-build-isolation .[vllm,sglang,bitblas]
|
|
151
|
+
uv pip install -vvv --no-build-isolation .
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Script installation
|
|
155
|
+
```bash
|
|
156
|
+
# You can pass modules as arguments, e.g., --vllm --sglang --bitblas. Example: bash install.sh --vllm --sglang --bitblas
|
|
157
|
+
bash install.sh
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### PIP (PENDING RELEASE)
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Include any specific modules needed using brackets. Example: pip install gptqmodel[sglang,vllm,bitblas] --no-build-isolation
|
|
164
|
+
pip install gptqmodel --no-build-isolation
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Quantization and Inference
|
|
168
|
+
|
|
169
|
+
> warning: this is just a showcase of the usage of basic apis in GPTQModel, which uses only one sample to quantize a much small model, quality of quantized model using such little samples may not good.
|
|
170
|
+
|
|
171
|
+
Below is an example for the simplest use of `gptqmodel` to quantize a model and inference after quantization:
|
|
172
|
+
|
|
173
|
+
```py
|
|
174
|
+
from transformers import AutoTokenizer
|
|
175
|
+
from gptqmodel import GPTQModel, QuantizeConfig
|
|
176
|
+
|
|
177
|
+
pretrained_model_dir = "facebook/opt-125m"
|
|
178
|
+
quant_output_dir = "opt-125m-4bit"
|
|
179
|
+
|
|
180
|
+
tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True)
|
|
181
|
+
calibration_dataset = [
|
|
182
|
+
tokenizer(
|
|
183
|
+
"The world is a wonderful place full of beauty and love."
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
quant_config = QuantizeConfig(
|
|
188
|
+
bits=4, # 4-bit
|
|
189
|
+
group_size=128, # 128 is good balance between quality and performance
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# load un-quantized model, by default, the model will always be loaded into CPU memory
|
|
193
|
+
model = GPTQModel.from_pretrained(pretrained_model_dir, quant_config)
|
|
194
|
+
|
|
195
|
+
# quantize model, the calibration_dataset should be list of dict whose keys can only be "input_ids" and "attention_mask"
|
|
196
|
+
model.quantize(calibration_dataset)
|
|
197
|
+
|
|
198
|
+
# save quantized model
|
|
199
|
+
model.save_quantized(quant_output_dir)
|
|
200
|
+
|
|
201
|
+
# load quantized model to the first GPU
|
|
202
|
+
model = GPTQModel.from_quantized(quant_output_dir)
|
|
203
|
+
|
|
204
|
+
# inference with model.generate
|
|
205
|
+
print(tokenizer.decode(model.generate(**tokenizer("gptqmodel is", return_tensors="pt").to(model.device))[0]))
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
For more advanced features of model quantization, please reference to [this script](examples/quantization/quant_with_alpaca.py)
|
|
209
|
+
|
|
210
|
+
### How to Add Support for a New Model
|
|
211
|
+
|
|
212
|
+
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.
|
|
213
|
+
|
|
214
|
+
### Evaluation on Downstream Tasks
|
|
215
|
+
|
|
216
|
+
You can use tasks defined in `gptqmodel.eval_tasks` to evaluate model's performance on specific down-stream task before and after quantization.
|
|
217
|
+
|
|
218
|
+
The predefined tasks support all causal-language-models implemented in [🤗 transformers](https://github.com/huggingface/transformers) and in this project.
|
|
219
|
+
|
|
220
|
+
<details>
|
|
221
|
+
|
|
222
|
+
<summary>Below is an example to evaluate `EleutherAI/gpt-j-6b` on sequence-classification task using `cardiffnlp/tweet_sentiment_multilingual` dataset:</summary>
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from functools import partial
|
|
226
|
+
|
|
227
|
+
import datasets
|
|
228
|
+
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
|
229
|
+
from gptqmodel import GPTQModel, QuantizeConfig
|
|
230
|
+
from gptqmodel.eval_tasks import SequenceClassificationTask
|
|
231
|
+
|
|
232
|
+
MODEL = "EleutherAI/gpt-j-6b"
|
|
233
|
+
DATASET = "cardiffnlp/tweet_sentiment_multilingual"
|
|
234
|
+
TEMPLATE = "Question:What's the sentiment of the given text? Choices are {labels}.\nText: {text}\nAnswer:"
|
|
235
|
+
ID2LABEL = {
|
|
236
|
+
0: "negative",
|
|
237
|
+
1: "neutral",
|
|
238
|
+
2: "positive"
|
|
239
|
+
}
|
|
240
|
+
LABELS = list(ID2LABEL.values())
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def ds_refactor_fn(samples):
|
|
244
|
+
text_data = samples["text"]
|
|
245
|
+
label_data = samples["label"]
|
|
246
|
+
|
|
247
|
+
new_samples = {"prompt": [], "label": []}
|
|
248
|
+
for text, label in zip(text_data, label_data):
|
|
249
|
+
prompt = TEMPLATE.format(labels=LABELS, text=text)
|
|
250
|
+
new_samples["prompt"].append(prompt)
|
|
251
|
+
new_samples["label"].append(ID2LABEL[label])
|
|
252
|
+
|
|
253
|
+
return new_samples
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# model = AutoModelForCausalLM.from_pretrained(MODEL).eval().half().to("cuda:0")
|
|
257
|
+
model = GPTQModel.from_pretrained(MODEL, QuantizeConfig())
|
|
258
|
+
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
|
259
|
+
|
|
260
|
+
task = SequenceClassificationTask(
|
|
261
|
+
model=model,
|
|
262
|
+
tokenizer=tokenizer,
|
|
263
|
+
classes=LABELS,
|
|
264
|
+
data_name_or_path=DATASET,
|
|
265
|
+
prompt_col_name="prompt",
|
|
266
|
+
label_col_name="label",
|
|
267
|
+
**{
|
|
268
|
+
"num_samples": 1000, # how many samples will be sampled to evaluation
|
|
269
|
+
"sample_max_len": 1024, # max tokens for each sample
|
|
270
|
+
"block_max_len": 2048, # max tokens for each data block
|
|
271
|
+
# function to load dataset, one must only accept data_name_or_path as input
|
|
272
|
+
# and return datasets.Dataset
|
|
273
|
+
"load_fn": partial(datasets.load_dataset, name="english"),
|
|
274
|
+
# function to preprocess dataset, which is used for datasets.Dataset.map,
|
|
275
|
+
# must return Dict[str, list] with only two keys: [prompt_col_name, label_col_name]
|
|
276
|
+
"preprocess_fn": ds_refactor_fn,
|
|
277
|
+
# truncate label when sample's length exceed sample_max_len
|
|
278
|
+
"truncate_prompt": False
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
# note that max_new_tokens will be automatically specified internally based on given classes
|
|
283
|
+
print(task.run())
|
|
284
|
+
|
|
285
|
+
# self-consistency
|
|
286
|
+
print(
|
|
287
|
+
task.run(
|
|
288
|
+
generation_config=GenerationConfig(
|
|
289
|
+
num_beams=3,
|
|
290
|
+
num_return_sequences=3,
|
|
291
|
+
do_sample=True
|
|
292
|
+
)
|
|
293
|
+
)
|
|
294
|
+
)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
</details>
|
|
298
|
+
|
|
299
|
+
## Learn More
|
|
300
|
+
|
|
301
|
+
[tutorials](docs/tutorial) provide step-by-step guidance to integrate `gptqmodel` with your own project and some best practice principles.
|
|
302
|
+
|
|
303
|
+
[examples](examples/README.md) provide plenty of example scripts to use `gptqmodel` in different ways.
|
|
304
|
+
|
|
305
|
+
## Supported Evaluation Tasks
|
|
306
|
+
|
|
307
|
+
Currently, `gptqmodel` supports: `LanguageModelingTask`, `SequenceClassificationTask` and `TextSummarizationTask`; more Tasks will come soon!
|
|
308
|
+
|
|
309
|
+
### Which kernel is used by default?
|
|
310
|
+
|
|
311
|
+
GPTQModel will use Marlin, Exllama v2, Triton kernels in that order for maximum inference performance.
|
|
312
|
+
|
|
313
|
+
# Acknowledgements
|
|
314
|
+
|
|
315
|
+
* **Elias Frantar**, **Saleh Ashkboos**, **Torsten Hoefler** and **Dan Alistarh**: for creating [GPTQ](https://github.com/IST-DASLab/gptq) and [Marlin](https://github.com/IST-DASLab/marlin).
|
|
316
|
+
* **PanQiWei**: for creation of [AutoGPTQ](https://github.com/autogptq/AutoGPTQ) which this project code is based upon.
|
|
317
|
+
* **FXMarty**: for maintaining and support of [AutoGPTQ](https://github.com/autogptq/AutoGPTQ).
|
|
318
|
+
* **Qwopqwop200**: for quantization code used in this project adapted from [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa/tree/cuda).
|
|
319
|
+
* **Turboderp**: for releasing [Exllama v1](https://github.com/turboderp/exllama) and [Exllama v2](https://github.com/turboderp/exllamav2) kernels adapted for use in this project.
|
|
320
|
+
* **FpgaMiner**: for [GPTQ-Triton](https://github.com/fpgaminer/GPTQ-triton) kernels used in [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa/tree/cuda) which is adapted into this project.
|