neural-compressor-tf 3.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.
Files changed (136) hide show
  1. neural_compressor_tf-3.0.1/LICENSE +201 -0
  2. neural_compressor_tf-3.0.1/PKG-INFO +229 -0
  3. neural_compressor_tf-3.0.1/README.md +205 -0
  4. neural_compressor_tf-3.0.1/neural_compressor/common/__init__.py +45 -0
  5. neural_compressor_tf-3.0.1/neural_compressor/common/base_config.py +933 -0
  6. neural_compressor_tf-3.0.1/neural_compressor/common/base_tuning.py +491 -0
  7. neural_compressor_tf-3.0.1/neural_compressor/common/benchmark.py +524 -0
  8. neural_compressor_tf-3.0.1/neural_compressor/common/tuning_param.py +131 -0
  9. neural_compressor_tf-3.0.1/neural_compressor/common/utils/__init__.py +21 -0
  10. neural_compressor_tf-3.0.1/neural_compressor/common/utils/constants.py +61 -0
  11. neural_compressor_tf-3.0.1/neural_compressor/common/utils/logger.py +206 -0
  12. neural_compressor_tf-3.0.1/neural_compressor/common/utils/save_load.py +61 -0
  13. neural_compressor_tf-3.0.1/neural_compressor/common/utils/utility.py +408 -0
  14. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/__init__.py +24 -0
  15. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/__init__.py +17 -0
  16. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/smoother/__init__.py +27 -0
  17. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/smoother/calibration.py +503 -0
  18. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/smoother/core.py +196 -0
  19. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/smoother/scaler.py +268 -0
  20. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/__init__.py +17 -0
  21. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/keras.py +775 -0
  22. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/keras.yaml +121 -0
  23. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/tensorflow.py +1549 -0
  24. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/tensorflow.yaml +244 -0
  25. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/algorithms/static_quant/tensorflow_itex.yaml +149 -0
  26. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/__init__.py +19 -0
  27. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/__init__.py +24 -0
  28. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/conv2d.py +415 -0
  29. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/dense.py +215 -0
  30. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/depthwise_conv2d.py +432 -0
  31. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/layer_initializer.py +34 -0
  32. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/pool2d.py +283 -0
  33. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/layers/separable_conv2d.py +431 -0
  34. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/quantization/__init__.py +19 -0
  35. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/keras/quantization/config.py +161 -0
  36. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/__init__.py +25 -0
  37. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/algorithm_entry.py +89 -0
  38. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/autotune.py +85 -0
  39. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/config.py +296 -0
  40. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/quantize.py +104 -0
  41. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/__init__.py +14 -0
  42. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_converter.py +1000 -0
  43. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/__init__.py +14 -0
  44. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/bf16/__init__.py +17 -0
  45. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/bf16/bf16_convert.py +290 -0
  46. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/bf16/dequantize_cast_optimizer.py +79 -0
  47. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/__init__.py +17 -0
  48. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/convert_add_to_biasadd.py +76 -0
  49. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/convert_layout.py +85 -0
  50. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/convert_leakyrelu.py +78 -0
  51. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/convert_nan_to_random.py +52 -0
  52. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/convert_placeholder_to_const.py +99 -0
  53. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/dilated_contraction.py +89 -0
  54. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/dummy_biasadd.py +130 -0
  55. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/expanddims_optimizer.py +81 -0
  56. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fetch_weight_from_reshape.py +89 -0
  57. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fold_batch_norm.py +271 -0
  58. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fold_constant.py +182 -0
  59. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_biasadd_add.py +75 -0
  60. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_column_wise_mul.py +86 -0
  61. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_conv_with_math.py +111 -0
  62. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_decomposed_bn.py +400 -0
  63. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_decomposed_in.py +369 -0
  64. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_gelu.py +227 -0
  65. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_layer_norm.py +244 -0
  66. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_pad_with_conv.py +125 -0
  67. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_pad_with_fp32_conv.py +128 -0
  68. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/fuse_reshape_transpose.py +126 -0
  69. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/graph_cse_optimizer.py +145 -0
  70. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/grappler_pass.py +69 -0
  71. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/insert_print_node.py +223 -0
  72. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/move_squeeze_after_relu.py +123 -0
  73. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/pre_optimize.py +310 -0
  74. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/remove_training_nodes.py +66 -0
  75. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/rename_batch_norm.py +60 -0
  76. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/split_shared_input.py +60 -0
  77. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/strip_equivalent_nodes.py +50 -0
  78. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/strip_unused_nodes.py +42 -0
  79. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/generic/switch_optimizer.py +85 -0
  80. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/graph_base.py +40 -0
  81. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/__init__.py +17 -0
  82. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/freeze_fake_quant.py +149 -0
  83. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/freeze_value.py +396 -0
  84. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/fuse_conv_redundant_dequantize.py +150 -0
  85. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/fuse_conv_requantize.py +819 -0
  86. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/fuse_matmul_redundant_dequantize.py +158 -0
  87. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/fuse_matmul_requantize.py +908 -0
  88. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/meta_op_optimizer.py +116 -0
  89. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/post_hostconst_converter.py +53 -0
  90. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/post_quantized_op_cse.py +135 -0
  91. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/int8/scale_propagation.py +118 -0
  92. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/qdq/__init__.py +17 -0
  93. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/qdq/insert_qdq_pattern.py +750 -0
  94. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/qdq/merge_duplicated_qdq.py +94 -0
  95. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_rewriter/qdq/share_qdq_y_pattern.py +60 -0
  96. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/graph_util.py +1115 -0
  97. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/__init__.py +17 -0
  98. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/__init__.py +17 -0
  99. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_bn.py +303 -0
  100. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_concatv2.py +261 -0
  101. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_conv.py +2022 -0
  102. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_deconv.py +541 -0
  103. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_in.py +183 -0
  104. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_matmul.py +1039 -0
  105. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/fuse_qdq_pooling.py +137 -0
  106. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/qdq/optimize_qdq.py +158 -0
  107. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_base.py +759 -0
  108. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_bn.py +298 -0
  109. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_concatv2.py +106 -0
  110. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_conv.py +378 -0
  111. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_for_intel_cpu.py +130 -0
  112. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_matmul.py +351 -0
  113. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph/quantize_graph_pooling.py +73 -0
  114. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/quantize_graph_common.py +448 -0
  115. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/transform_graph/__init__.py +18 -0
  116. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/transform_graph/bias_correction.py +137 -0
  117. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/transform_graph/graph_transform_base.py +111 -0
  118. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/transform_graph/insert_logging.py +199 -0
  119. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/transform_graph/rerange_quantized_concat.py +313 -0
  120. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/quantization/utils/utility.py +619 -0
  121. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/__init__.py +56 -0
  122. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/constants.py +60 -0
  123. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/data.py +605 -0
  124. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/model.py +118 -0
  125. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/model_wrappers.py +1494 -0
  126. neural_compressor_tf-3.0.1/neural_compressor/tensorflow/utils/utility.py +437 -0
  127. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/PKG-INFO +229 -0
  128. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/SOURCES.txt +135 -0
  129. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/dependency_links.txt +1 -0
  130. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/entry_points.txt +2 -0
  131. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/requires.txt +6 -0
  132. neural_compressor_tf-3.0.1/neural_compressor_tf.egg-info/top_level.txt +1 -0
  133. neural_compressor_tf-3.0.1/pyproject.toml +109 -0
  134. neural_compressor_tf-3.0.1/setup.cfg +9 -0
  135. neural_compressor_tf-3.0.1/setup.py +160 -0
  136. neural_compressor_tf-3.0.1/third-party-programs.txt +1911 -0
@@ -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
+ ============================================================================
179
+
180
+ Copyright 2016-2019 Intel Corporation
181
+ Copyright 2018 YANDEX LLC
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
194
+
195
+ This distribution includes third party software ("third party programs").
196
+ This third party software, even if included with the distribution of
197
+ the Intel software, may be governed by separate license terms, including
198
+ without limitation, third party license terms, other Intel software license
199
+ terms, and open source software license terms. These separate license terms
200
+ govern your use of the third party programs as set forth in the
201
+ "THIRD-PARTY-PROGRAMS" file.
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.1
2
+ Name: neural_compressor_tf
3
+ Version: 3.0.1
4
+ Summary: Repository of Intel® Neural Compressor
5
+ Home-page: https://github.com/intel/neural-compressor
6
+ Author: Intel AIPT Team
7
+ Author-email: feng.tian@intel.com, haihao.shen@intel.com, suyue.chen@intel.com
8
+ License: Apache 2.0
9
+ Keywords: quantization,auto-tuning,post-training static quantization,post-training dynamic quantization,quantization-aware training
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Requires-Python: >=3.7.0
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: third-party-programs.txt
18
+ Requires-Dist: prettytable
19
+ Requires-Dist: psutil
20
+ Requires-Dist: py-cpuinfo
21
+ Requires-Dist: pydantic
22
+ Requires-Dist: pyyaml
23
+ Requires-Dist: tensorflow
24
+
25
+ <div align="center">
26
+
27
+ Intel® Neural Compressor
28
+ ===========================
29
+ <h3> An open-source Python library supporting popular model compression techniques on all mainstream deep learning frameworks (TensorFlow, PyTorch, and ONNX Runtime)</h3>
30
+
31
+ [![python](https://img.shields.io/badge/python-3.8%2B-blue)](https://github.com/intel/neural-compressor)
32
+ [![version](https://img.shields.io/badge/release-3.0-green)](https://github.com/intel/neural-compressor/releases)
33
+ [![license](https://img.shields.io/badge/license-Apache%202-blue)](https://github.com/intel/neural-compressor/blob/master/LICENSE)
34
+ [![coverage](https://img.shields.io/badge/coverage-85%25-green)](https://github.com/intel/neural-compressor)
35
+ [![Downloads](https://static.pepy.tech/personalized-badge/neural-compressor?period=total&units=international_system&left_color=grey&right_color=green&left_text=downloads)](https://pepy.tech/project/neural-compressor)
36
+
37
+ [Architecture](./docs/source/3x/design.md#architecture)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Workflow](./docs/source/3x/design.md#workflows)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[LLMs Recipes](./docs/source/llm_recipes.md)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Results](./docs/source/validated_model_list.md)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Documentations](https://intel.github.io/neural-compressor)
38
+
39
+ ---
40
+ <div align="left">
41
+
42
+ Intel® Neural Compressor aims to provide popular model compression techniques such as quantization, pruning (sparsity), distillation, and neural architecture search on mainstream frameworks such as [TensorFlow](https://www.tensorflow.org/), [PyTorch](https://pytorch.org/), and [ONNX Runtime](https://onnxruntime.ai/),
43
+ as well as Intel extensions such as [Intel Extension for TensorFlow](https://github.com/intel/intel-extension-for-tensorflow) and [Intel Extension for PyTorch](https://github.com/intel/intel-extension-for-pytorch).
44
+ In particular, the tool provides the key features, typical examples, and open collaborations as below:
45
+
46
+ * Support a wide range of Intel hardware such as [Intel Gaudi Al Accelerators](https://www.intel.com/content/www/us/en/products/details/processors/ai-accelerators/gaudi-overview.html), [Intel Core Ultra Processors](https://www.intel.com/content/www/us/en/products/details/processors/core-ultra.html), [Intel Xeon Scalable Processors](https://www.intel.com/content/www/us/en/products/details/processors/xeon/scalable.html), [Intel Xeon CPU Max Series](https://www.intel.com/content/www/us/en/products/details/processors/xeon/max-series.html), [Intel Data Center GPU Flex Series](https://www.intel.com/content/www/us/en/products/details/discrete-gpus/data-center-gpu/flex-series.html), and [Intel Data Center GPU Max Series](https://www.intel.com/content/www/us/en/products/details/discrete-gpus/data-center-gpu/max-series.html) with extensive testing;
47
+ support AMD CPU, ARM CPU, and NVidia GPU through ONNX Runtime with limited testing; support NVidia GPU for some WOQ algorithms like AutoRound and HQQ.
48
+
49
+ * Validate popular LLMs such as [LLama2](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [Falcon](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [GPT-J](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [Bloom](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [OPT](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), and more than 10,000 broad models such as [Stable Diffusion](/examples/pytorch/nlp/huggingface_models/text-to-image/quantization), [BERT-Large](/examples/pytorch/nlp/huggingface_models/text-classification/quantization/ptq_static/fx), and [ResNet50](/examples/pytorch/image_recognition/torchvision_models/quantization/ptq/cpu/fx) from popular model hubs such as [Hugging Face](https://huggingface.co/), [Torch Vision](https://pytorch.org/vision/stable/index.html), and [ONNX Model Zoo](https://github.com/onnx/models#models), with automatic [accuracy-driven](/docs/source/design.md#workflow) quantization strategies
50
+
51
+ * Collaborate with cloud marketplaces such as [Google Cloud Platform](https://console.cloud.google.com/marketplace/product/bitnami-launchpad/inc-tensorflow-intel?project=verdant-sensor-286207), [Amazon Web Services](https://aws.amazon.com/marketplace/pp/prodview-yjyh2xmggbmga#pdp-support), and [Azure](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/bitnami.inc-tensorflow-intel), software platforms such as [Alibaba Cloud](https://www.intel.com/content/www/us/en/developer/articles/technical/quantize-ai-by-oneapi-analytics-on-alibaba-cloud.html), [Tencent TACO](https://new.qq.com/rain/a/20221202A00B9S00) and [Microsoft Olive](https://github.com/microsoft/Olive), and open AI ecosystem such as [Hugging Face](https://huggingface.co/blog/intel), [PyTorch](https://pytorch.org/tutorials/recipes/intel_neural_compressor_for_pytorch.html), [ONNX](https://github.com/onnx/models#models), [ONNX Runtime](https://github.com/microsoft/onnxruntime), and [Lightning AI](https://github.com/Lightning-AI/lightning/blob/master/docs/source-pytorch/advanced/post_training_quantization.rst)
52
+
53
+ ## What's New
54
+ * [2024/07] From 3.0 release, framework extension API is recommended to be used for quantization.
55
+ * [2024/07] Performance optimizations and usability improvements on [client-side](./docs/source/3x/client_quant.md).
56
+
57
+ ## Installation
58
+ ### Install Framework
59
+ #### Install torch for CPU
60
+ ```Shell
61
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
62
+ ```
63
+ #### Use Docker Image with torch installed for HPU
64
+ https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#bare-metal-fresh-os-single-click
65
+
66
+ > **Note**:
67
+ > There is a version mapping between Intel Neural Compressor and Gaudi Software Stack, please refer to this [table](./docs/source/3x/gaudi_version_map.md) and make sure to use a matched combination.
68
+
69
+ #### Install torch/intel_extension_for_pytorch for Intel GPU
70
+ https://intel.github.io/intel-extension-for-pytorch/index.html#installation
71
+
72
+ #### Install torch for other platform
73
+ https://pytorch.org/get-started/locally
74
+
75
+ #### Install tensorflow
76
+ ```Shell
77
+ pip install tensorflow
78
+ ```
79
+
80
+ ### Install from pypi
81
+ ```Shell
82
+ # Install 2.X API + Framework extension API + PyTorch dependency
83
+ pip install neural-compressor[pt]
84
+ # Install 2.X API + Framework extension API + TensorFlow dependency
85
+ pip install neural-compressor[tf]
86
+ ```
87
+ > **Note**:
88
+ > Further installation methods can be found under [Installation Guide](./docs/source/installation_guide.md). check out our [FAQ](./docs/source/faq.md) for more details.
89
+
90
+ ## Getting Started
91
+
92
+ Setting up the environment:
93
+ ```bash
94
+ pip install "neural-compressor>=2.3" "transformers>=4.34.0" torch torchvision
95
+ ```
96
+ After successfully installing these packages, try your first quantization program.
97
+
98
+ ### [FP8 Quantization](./examples/3.x_api/pytorch/cv/fp8_quant/)
99
+ Following example code demonstrates FP8 Quantization, it is supported by Intel Gaudi2 AI Accelerator.
100
+
101
+ To try on Intel Gaudi2, docker image with Gaudi Software Stack is recommended, please refer to following script for environment setup. More details can be found in [Gaudi Guide](https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#launch-docker-image-that-was-built).
102
+ ```bash
103
+ # Run a container with an interactive shell
104
+ docker run -it --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host vault.habana.ai/gaudi-docker/1.17.0/ubuntu22.04/habanalabs/pytorch-installer-2.3.1:latest
105
+ ```
106
+ Run the example:
107
+ ```python
108
+ from neural_compressor.torch.quantization import (
109
+ FP8Config,
110
+ prepare,
111
+ convert,
112
+ )
113
+ import torchvision.models as models
114
+
115
+ model = models.resnet18()
116
+ qconfig = FP8Config(fp8_config="E4M3")
117
+ model = prepare(model, qconfig)
118
+ # customer defined calibration
119
+ calib_func(model)
120
+ model = convert(model)
121
+ ```
122
+
123
+ ### Weight-Only Large Language Model Loading (LLMs)
124
+
125
+ Following example code demonstrates weight-only large language model loading on Intel Gaudi2 AI Accelerator.
126
+
127
+ ```python
128
+ from neural_compressor.torch.quantization import load
129
+
130
+ model_name = "TheBloke/Llama-2-7B-GPTQ"
131
+ model = load(
132
+ model_name_or_path=model_name,
133
+ format="huggingface",
134
+ device="hpu",
135
+ torch_dtype=torch.bfloat16,
136
+ )
137
+ ```
138
+
139
+ **Note:**
140
+
141
+ Intel Neural Compressor will convert the model format from auto-gptq to hpu format on the first load and save hpu_model.safetensors to the local cache directory for the next load. So it may take a while to load for the first time.
142
+
143
+ ## Documentation
144
+
145
+ <table class="docutils">
146
+ <thead>
147
+ <tr>
148
+ <th colspan="8">Overview</th>
149
+ </tr>
150
+ </thead>
151
+ <tbody>
152
+ <tr>
153
+ <td colspan="2" align="center"><a href="./docs/source/3x/design.md#architecture">Architecture</a></td>
154
+ <td colspan="2" align="center"><a href="./docs/source/3x/design.md#workflows">Workflow</a></td>
155
+ <td colspan="2" align="center"><a href="https://intel.github.io/neural-compressor/latest/docs/source/api-doc/apis.html">APIs</a></td>
156
+ <td colspan="1" align="center"><a href="./docs/source/3x/llm_recipes.md">LLMs Recipes</a></td>
157
+ <td colspan="1" align="center"><a href="./examples/3.x_api/README.md">Examples</a></td>
158
+ </tr>
159
+ </tbody>
160
+ <thead>
161
+ <tr>
162
+ <th colspan="8">PyTorch Extension APIs</th>
163
+ </tr>
164
+ </thead>
165
+ <tbody>
166
+ <tr>
167
+ <td colspan="2" align="center"><a href="./docs/source/3x/PyTorch.md">Overview</a></td>
168
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_DynamicQuant.md">Dynamic Quantization</a></td>
169
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_StaticQuant.md">Static Quantization</a></td>
170
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_SmoothQuant.md">Smooth Quantization</a></td>
171
+ </tr>
172
+ <tr>
173
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_WeightOnlyQuant.md">Weight-Only Quantization</a></td>
174
+ <td colspan="2" align="center"><a href="./docs/3x/PT_FP8Quant.md">FP8 Quantization</a></td>
175
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_MXQuant.md">MX Quantization</a></td>
176
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_MixedPrecision.md">Mixed Precision</a></td>
177
+ </tr>
178
+ </tbody>
179
+ <thead>
180
+ <tr>
181
+ <th colspan="8">Tensorflow Extension APIs</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr>
186
+ <td colspan="3" align="center"><a href="./docs/source/3x/TensorFlow.md">Overview</a></td>
187
+ <td colspan="3" align="center"><a href="./docs/source/3x/TF_Quant.md">Static Quantization</a></td>
188
+ <td colspan="2" align="center"><a href="./docs/source/3x/TF_SQ.md">Smooth Quantization</a></td>
189
+ </tr>
190
+ </tbody>
191
+ <thead>
192
+ <tr>
193
+ <th colspan="8">Other Modules</th>
194
+ </tr>
195
+ </thead>
196
+ <tbody>
197
+ <tr>
198
+ <td colspan="4" align="center"><a href="./docs/source/3x/autotune.md">Auto Tune</a></td>
199
+ <td colspan="4" align="center"><a href="./docs/source/3x/benchmark.md">Benchmark</a></td>
200
+ </tr>
201
+ </tbody>
202
+ </table>
203
+
204
+ > **Note**:
205
+ > From 3.0 release, we recommend to use 3.X API. Compression techniques during training such as QAT, Pruning, Distillation only available in [2.X API](https://github.com/intel/neural-compressor/blob/master/docs/source/2x_user_guide.md) currently.
206
+
207
+ ## Selected Publications/Events
208
+ * Blog by Intel: [Neural Compressor: Boosting AI Model Efficiency](https://community.intel.com/t5/Blogs/Tech-Innovation/Artificial-Intelligence-AI/Neural-Compressor-Boosting-AI-Model-Efficiency/post/1604740) (June 2024)
209
+ * Blog by Intel: [Optimization of Intel AI Solutions for Alibaba Cloud’s Qwen2 Large Language Models](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-ai-solutions-accelerate-alibaba-qwen2-llms.html) (June 2024)
210
+ * Blog by Intel: [Accelerate Meta* Llama 3 with Intel AI Solutions](https://www.intel.com/content/www/us/en/developer/articles/technical/accelerate-meta-llama3-with-intel-ai-solutions.html) (Apr 2024)
211
+ * EMNLP'2023 (Under Review): [TEQ: Trainable Equivalent Transformation for Quantization of LLMs](https://openreview.net/forum?id=iaI8xEINAf&referrer=%5BAuthor%20Console%5D) (Sep 2023)
212
+ * arXiv: [Efficient Post-training Quantization with FP8 Formats](https://arxiv.org/abs/2309.14592) (Sep 2023)
213
+ * arXiv: [Optimize Weight Rounding via Signed Gradient Descent for the Quantization of LLMs](https://arxiv.org/abs/2309.05516) (Sep 2023)
214
+
215
+ > **Note**:
216
+ > View [Full Publication List](https://github.com/intel/neural-compressor/blob/master/docs/source/publication_list.md).
217
+
218
+ ## Additional Content
219
+
220
+ * [Release Information](./docs/source/releases_info.md)
221
+ * [Contribution Guidelines](./docs/source/CONTRIBUTING.md)
222
+ * [Legal Information](./docs/source/legal_information.md)
223
+ * [Security Policy](SECURITY.md)
224
+
225
+ ## Communication
226
+ - [GitHub Issues](https://github.com/intel/neural-compressor/issues): mainly for bug reports, new feature requests, question asking, etc.
227
+ - [Email](mailto:inc.maintainers@intel.com): welcome to raise any interesting research ideas on model compression techniques by email for collaborations.
228
+ - [Discord Channel](https://discord.com/invite/Wxk3J3ZJkU): join the discord channel for more flexible technical discussion.
229
+ - [WeChat group](/docs/source/imgs/wechat_group.jpg): scan the QA code to join the technical discussion.
@@ -0,0 +1,205 @@
1
+ <div align="center">
2
+
3
+ Intel® Neural Compressor
4
+ ===========================
5
+ <h3> An open-source Python library supporting popular model compression techniques on all mainstream deep learning frameworks (TensorFlow, PyTorch, and ONNX Runtime)</h3>
6
+
7
+ [![python](https://img.shields.io/badge/python-3.8%2B-blue)](https://github.com/intel/neural-compressor)
8
+ [![version](https://img.shields.io/badge/release-3.0-green)](https://github.com/intel/neural-compressor/releases)
9
+ [![license](https://img.shields.io/badge/license-Apache%202-blue)](https://github.com/intel/neural-compressor/blob/master/LICENSE)
10
+ [![coverage](https://img.shields.io/badge/coverage-85%25-green)](https://github.com/intel/neural-compressor)
11
+ [![Downloads](https://static.pepy.tech/personalized-badge/neural-compressor?period=total&units=international_system&left_color=grey&right_color=green&left_text=downloads)](https://pepy.tech/project/neural-compressor)
12
+
13
+ [Architecture](./docs/source/3x/design.md#architecture)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Workflow](./docs/source/3x/design.md#workflows)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[LLMs Recipes](./docs/source/llm_recipes.md)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Results](./docs/source/validated_model_list.md)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;[Documentations](https://intel.github.io/neural-compressor)
14
+
15
+ ---
16
+ <div align="left">
17
+
18
+ Intel® Neural Compressor aims to provide popular model compression techniques such as quantization, pruning (sparsity), distillation, and neural architecture search on mainstream frameworks such as [TensorFlow](https://www.tensorflow.org/), [PyTorch](https://pytorch.org/), and [ONNX Runtime](https://onnxruntime.ai/),
19
+ as well as Intel extensions such as [Intel Extension for TensorFlow](https://github.com/intel/intel-extension-for-tensorflow) and [Intel Extension for PyTorch](https://github.com/intel/intel-extension-for-pytorch).
20
+ In particular, the tool provides the key features, typical examples, and open collaborations as below:
21
+
22
+ * Support a wide range of Intel hardware such as [Intel Gaudi Al Accelerators](https://www.intel.com/content/www/us/en/products/details/processors/ai-accelerators/gaudi-overview.html), [Intel Core Ultra Processors](https://www.intel.com/content/www/us/en/products/details/processors/core-ultra.html), [Intel Xeon Scalable Processors](https://www.intel.com/content/www/us/en/products/details/processors/xeon/scalable.html), [Intel Xeon CPU Max Series](https://www.intel.com/content/www/us/en/products/details/processors/xeon/max-series.html), [Intel Data Center GPU Flex Series](https://www.intel.com/content/www/us/en/products/details/discrete-gpus/data-center-gpu/flex-series.html), and [Intel Data Center GPU Max Series](https://www.intel.com/content/www/us/en/products/details/discrete-gpus/data-center-gpu/max-series.html) with extensive testing;
23
+ support AMD CPU, ARM CPU, and NVidia GPU through ONNX Runtime with limited testing; support NVidia GPU for some WOQ algorithms like AutoRound and HQQ.
24
+
25
+ * Validate popular LLMs such as [LLama2](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [Falcon](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [GPT-J](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [Bloom](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), [OPT](/examples/pytorch/nlp/huggingface_models/language-modeling/quantization/llm), and more than 10,000 broad models such as [Stable Diffusion](/examples/pytorch/nlp/huggingface_models/text-to-image/quantization), [BERT-Large](/examples/pytorch/nlp/huggingface_models/text-classification/quantization/ptq_static/fx), and [ResNet50](/examples/pytorch/image_recognition/torchvision_models/quantization/ptq/cpu/fx) from popular model hubs such as [Hugging Face](https://huggingface.co/), [Torch Vision](https://pytorch.org/vision/stable/index.html), and [ONNX Model Zoo](https://github.com/onnx/models#models), with automatic [accuracy-driven](/docs/source/design.md#workflow) quantization strategies
26
+
27
+ * Collaborate with cloud marketplaces such as [Google Cloud Platform](https://console.cloud.google.com/marketplace/product/bitnami-launchpad/inc-tensorflow-intel?project=verdant-sensor-286207), [Amazon Web Services](https://aws.amazon.com/marketplace/pp/prodview-yjyh2xmggbmga#pdp-support), and [Azure](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/bitnami.inc-tensorflow-intel), software platforms such as [Alibaba Cloud](https://www.intel.com/content/www/us/en/developer/articles/technical/quantize-ai-by-oneapi-analytics-on-alibaba-cloud.html), [Tencent TACO](https://new.qq.com/rain/a/20221202A00B9S00) and [Microsoft Olive](https://github.com/microsoft/Olive), and open AI ecosystem such as [Hugging Face](https://huggingface.co/blog/intel), [PyTorch](https://pytorch.org/tutorials/recipes/intel_neural_compressor_for_pytorch.html), [ONNX](https://github.com/onnx/models#models), [ONNX Runtime](https://github.com/microsoft/onnxruntime), and [Lightning AI](https://github.com/Lightning-AI/lightning/blob/master/docs/source-pytorch/advanced/post_training_quantization.rst)
28
+
29
+ ## What's New
30
+ * [2024/07] From 3.0 release, framework extension API is recommended to be used for quantization.
31
+ * [2024/07] Performance optimizations and usability improvements on [client-side](./docs/source/3x/client_quant.md).
32
+
33
+ ## Installation
34
+ ### Install Framework
35
+ #### Install torch for CPU
36
+ ```Shell
37
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
38
+ ```
39
+ #### Use Docker Image with torch installed for HPU
40
+ https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#bare-metal-fresh-os-single-click
41
+
42
+ > **Note**:
43
+ > There is a version mapping between Intel Neural Compressor and Gaudi Software Stack, please refer to this [table](./docs/source/3x/gaudi_version_map.md) and make sure to use a matched combination.
44
+
45
+ #### Install torch/intel_extension_for_pytorch for Intel GPU
46
+ https://intel.github.io/intel-extension-for-pytorch/index.html#installation
47
+
48
+ #### Install torch for other platform
49
+ https://pytorch.org/get-started/locally
50
+
51
+ #### Install tensorflow
52
+ ```Shell
53
+ pip install tensorflow
54
+ ```
55
+
56
+ ### Install from pypi
57
+ ```Shell
58
+ # Install 2.X API + Framework extension API + PyTorch dependency
59
+ pip install neural-compressor[pt]
60
+ # Install 2.X API + Framework extension API + TensorFlow dependency
61
+ pip install neural-compressor[tf]
62
+ ```
63
+ > **Note**:
64
+ > Further installation methods can be found under [Installation Guide](./docs/source/installation_guide.md). check out our [FAQ](./docs/source/faq.md) for more details.
65
+
66
+ ## Getting Started
67
+
68
+ Setting up the environment:
69
+ ```bash
70
+ pip install "neural-compressor>=2.3" "transformers>=4.34.0" torch torchvision
71
+ ```
72
+ After successfully installing these packages, try your first quantization program.
73
+
74
+ ### [FP8 Quantization](./examples/3.x_api/pytorch/cv/fp8_quant/)
75
+ Following example code demonstrates FP8 Quantization, it is supported by Intel Gaudi2 AI Accelerator.
76
+
77
+ To try on Intel Gaudi2, docker image with Gaudi Software Stack is recommended, please refer to following script for environment setup. More details can be found in [Gaudi Guide](https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#launch-docker-image-that-was-built).
78
+ ```bash
79
+ # Run a container with an interactive shell
80
+ docker run -it --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host vault.habana.ai/gaudi-docker/1.17.0/ubuntu22.04/habanalabs/pytorch-installer-2.3.1:latest
81
+ ```
82
+ Run the example:
83
+ ```python
84
+ from neural_compressor.torch.quantization import (
85
+ FP8Config,
86
+ prepare,
87
+ convert,
88
+ )
89
+ import torchvision.models as models
90
+
91
+ model = models.resnet18()
92
+ qconfig = FP8Config(fp8_config="E4M3")
93
+ model = prepare(model, qconfig)
94
+ # customer defined calibration
95
+ calib_func(model)
96
+ model = convert(model)
97
+ ```
98
+
99
+ ### Weight-Only Large Language Model Loading (LLMs)
100
+
101
+ Following example code demonstrates weight-only large language model loading on Intel Gaudi2 AI Accelerator.
102
+
103
+ ```python
104
+ from neural_compressor.torch.quantization import load
105
+
106
+ model_name = "TheBloke/Llama-2-7B-GPTQ"
107
+ model = load(
108
+ model_name_or_path=model_name,
109
+ format="huggingface",
110
+ device="hpu",
111
+ torch_dtype=torch.bfloat16,
112
+ )
113
+ ```
114
+
115
+ **Note:**
116
+
117
+ Intel Neural Compressor will convert the model format from auto-gptq to hpu format on the first load and save hpu_model.safetensors to the local cache directory for the next load. So it may take a while to load for the first time.
118
+
119
+ ## Documentation
120
+
121
+ <table class="docutils">
122
+ <thead>
123
+ <tr>
124
+ <th colspan="8">Overview</th>
125
+ </tr>
126
+ </thead>
127
+ <tbody>
128
+ <tr>
129
+ <td colspan="2" align="center"><a href="./docs/source/3x/design.md#architecture">Architecture</a></td>
130
+ <td colspan="2" align="center"><a href="./docs/source/3x/design.md#workflows">Workflow</a></td>
131
+ <td colspan="2" align="center"><a href="https://intel.github.io/neural-compressor/latest/docs/source/api-doc/apis.html">APIs</a></td>
132
+ <td colspan="1" align="center"><a href="./docs/source/3x/llm_recipes.md">LLMs Recipes</a></td>
133
+ <td colspan="1" align="center"><a href="./examples/3.x_api/README.md">Examples</a></td>
134
+ </tr>
135
+ </tbody>
136
+ <thead>
137
+ <tr>
138
+ <th colspan="8">PyTorch Extension APIs</th>
139
+ </tr>
140
+ </thead>
141
+ <tbody>
142
+ <tr>
143
+ <td colspan="2" align="center"><a href="./docs/source/3x/PyTorch.md">Overview</a></td>
144
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_DynamicQuant.md">Dynamic Quantization</a></td>
145
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_StaticQuant.md">Static Quantization</a></td>
146
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_SmoothQuant.md">Smooth Quantization</a></td>
147
+ </tr>
148
+ <tr>
149
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_WeightOnlyQuant.md">Weight-Only Quantization</a></td>
150
+ <td colspan="2" align="center"><a href="./docs/3x/PT_FP8Quant.md">FP8 Quantization</a></td>
151
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_MXQuant.md">MX Quantization</a></td>
152
+ <td colspan="2" align="center"><a href="./docs/source/3x/PT_MixedPrecision.md">Mixed Precision</a></td>
153
+ </tr>
154
+ </tbody>
155
+ <thead>
156
+ <tr>
157
+ <th colspan="8">Tensorflow Extension APIs</th>
158
+ </tr>
159
+ </thead>
160
+ <tbody>
161
+ <tr>
162
+ <td colspan="3" align="center"><a href="./docs/source/3x/TensorFlow.md">Overview</a></td>
163
+ <td colspan="3" align="center"><a href="./docs/source/3x/TF_Quant.md">Static Quantization</a></td>
164
+ <td colspan="2" align="center"><a href="./docs/source/3x/TF_SQ.md">Smooth Quantization</a></td>
165
+ </tr>
166
+ </tbody>
167
+ <thead>
168
+ <tr>
169
+ <th colspan="8">Other Modules</th>
170
+ </tr>
171
+ </thead>
172
+ <tbody>
173
+ <tr>
174
+ <td colspan="4" align="center"><a href="./docs/source/3x/autotune.md">Auto Tune</a></td>
175
+ <td colspan="4" align="center"><a href="./docs/source/3x/benchmark.md">Benchmark</a></td>
176
+ </tr>
177
+ </tbody>
178
+ </table>
179
+
180
+ > **Note**:
181
+ > From 3.0 release, we recommend to use 3.X API. Compression techniques during training such as QAT, Pruning, Distillation only available in [2.X API](https://github.com/intel/neural-compressor/blob/master/docs/source/2x_user_guide.md) currently.
182
+
183
+ ## Selected Publications/Events
184
+ * Blog by Intel: [Neural Compressor: Boosting AI Model Efficiency](https://community.intel.com/t5/Blogs/Tech-Innovation/Artificial-Intelligence-AI/Neural-Compressor-Boosting-AI-Model-Efficiency/post/1604740) (June 2024)
185
+ * Blog by Intel: [Optimization of Intel AI Solutions for Alibaba Cloud’s Qwen2 Large Language Models](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-ai-solutions-accelerate-alibaba-qwen2-llms.html) (June 2024)
186
+ * Blog by Intel: [Accelerate Meta* Llama 3 with Intel AI Solutions](https://www.intel.com/content/www/us/en/developer/articles/technical/accelerate-meta-llama3-with-intel-ai-solutions.html) (Apr 2024)
187
+ * EMNLP'2023 (Under Review): [TEQ: Trainable Equivalent Transformation for Quantization of LLMs](https://openreview.net/forum?id=iaI8xEINAf&referrer=%5BAuthor%20Console%5D) (Sep 2023)
188
+ * arXiv: [Efficient Post-training Quantization with FP8 Formats](https://arxiv.org/abs/2309.14592) (Sep 2023)
189
+ * arXiv: [Optimize Weight Rounding via Signed Gradient Descent for the Quantization of LLMs](https://arxiv.org/abs/2309.05516) (Sep 2023)
190
+
191
+ > **Note**:
192
+ > View [Full Publication List](https://github.com/intel/neural-compressor/blob/master/docs/source/publication_list.md).
193
+
194
+ ## Additional Content
195
+
196
+ * [Release Information](./docs/source/releases_info.md)
197
+ * [Contribution Guidelines](./docs/source/CONTRIBUTING.md)
198
+ * [Legal Information](./docs/source/legal_information.md)
199
+ * [Security Policy](SECURITY.md)
200
+
201
+ ## Communication
202
+ - [GitHub Issues](https://github.com/intel/neural-compressor/issues): mainly for bug reports, new feature requests, question asking, etc.
203
+ - [Email](mailto:inc.maintainers@intel.com): welcome to raise any interesting research ideas on model compression techniques by email for collaborations.
204
+ - [Discord Channel](https://discord.com/invite/Wxk3J3ZJkU): join the discord channel for more flexible technical discussion.
205
+ - [WeChat group](/docs/source/imgs/wechat_group.jpg): scan the QA code to join the technical discussion.