From 0477bb0c4f2bcb2c8a14e2b3427d6afa3ffebecd Mon Sep 17 00:00:00 2001 From: "Wang, Chang" Date: Tue, 9 Jul 2024 16:54:51 +0800 Subject: [PATCH 1/3] update fp4_e2m1 mapping list --- .../torch/algorithms/weight_only/utility.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/neural_compressor/torch/algorithms/weight_only/utility.py b/neural_compressor/torch/algorithms/weight_only/utility.py index 207dc212dcf..476c6a95ae2 100644 --- a/neural_compressor/torch/algorithms/weight_only/utility.py +++ b/neural_compressor/torch/algorithms/weight_only/utility.py @@ -66,7 +66,23 @@ 1.0, ] FP4_BNB = [-12.0, -8.0, -6.0, -4.0, -3.0, -2.0, -0.0625, 0, 0.0625, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0] -FP4_E2M1 = [-6.0, -4.0, -3.0, -2.0, -1.5, -1.0, -0.0625, 0, 0.0625, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0] +FP4_E2M1 = [ + -1.0, + -0.6666666666666666, + -0.5, + -0.3333333333333333, + -0.25, + -0.16666666666666666, + -0.010416666666666666, + 0.0, + 0.010416666666666666, + 0.16666666666666666, + 0.25, + 0.3333333333333333, + 0.5, + 0.6666666666666666, + 1.0 + ] # the order is the same as float list, bit value range is [-7, 7] # 1111 = -1, 1110 = -2, 1101= -3, ... From 55c1624266e2e48225c100fb765263006d8acd8d Mon Sep 17 00:00:00 2001 From: "Wang, Chang" Date: Tue, 9 Jul 2024 16:56:27 +0800 Subject: [PATCH 2/3] Update utility.py --- neural_compressor/torch/algorithms/weight_only/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neural_compressor/torch/algorithms/weight_only/utility.py b/neural_compressor/torch/algorithms/weight_only/utility.py index 476c6a95ae2..5954df66efb 100644 --- a/neural_compressor/torch/algorithms/weight_only/utility.py +++ b/neural_compressor/torch/algorithms/weight_only/utility.py @@ -81,7 +81,7 @@ 0.3333333333333333, 0.5, 0.6666666666666666, - 1.0 + 1.0, ] # the order is the same as float list, bit value range is [-7, 7] From e7c270c79b881ddb9cdf1a6b792e8feaf0949377 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:58:50 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- neural_compressor/torch/algorithms/weight_only/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neural_compressor/torch/algorithms/weight_only/utility.py b/neural_compressor/torch/algorithms/weight_only/utility.py index 5954df66efb..0cb6d6d938d 100644 --- a/neural_compressor/torch/algorithms/weight_only/utility.py +++ b/neural_compressor/torch/algorithms/weight_only/utility.py @@ -82,7 +82,7 @@ 0.5, 0.6666666666666666, 1.0, - ] +] # the order is the same as float list, bit value range is [-7, 7] # 1111 = -1, 1110 = -2, 1101= -3, ...