From 5fde50f2c0476dbc08d59481b742515f5a210de1 Mon Sep 17 00:00:00 2001 From: "Wang, Chang" Date: Wed, 10 Jul 2024 10:34:46 +0800 Subject: [PATCH] update fp4_e2m1 mapping list (#1906) * update fp4_e2m1 mapping list * Update utility.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../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..0cb6d6d938d 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, ...