Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
SunMarc committed Dec 11, 2023
1 parent 1fd9c58 commit 39aab85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion optimum/gptq/quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __init__(
"sym",
"true_sequential",
"quant_method",
"inside_layer_modules"
"inside_layer_modules",
]

if self.bits not in [2, 3, 4, 8]:
Expand Down
12 changes: 5 additions & 7 deletions tests/gptq/test_quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setUpClass(cls):
disable_exllama=cls.disable_exllama,
exllama_config=cls.exllama_config,
cache_block_outputs=cls.cache_block_outputs,
inside_layer_modules=cls.inside_layer_modules
inside_layer_modules=cls.inside_layer_modules,
)

cls.quantized_model = cls.quantizer.quantize_model(cls.model_fp16, cls.tokenizer)
Expand Down Expand Up @@ -302,18 +302,16 @@ class GPTQTestNoBlockCaching(GPTQTest):
EXPECTED_OUTPUTS.add("Hello my name is jay and i am a student at university.")
EXPECTED_OUTPUTS.add("Hello my name is John, I am a student in the University of")


class GPTQTestInsideLayerModules(GPTQTest):
# all layers are quantized apart from self_attention.dense
inside_layer_modules = [
["self_attention.query_key_value"],
["mlp.dense_h_to_4h"],
["mlp.dense_4h_to_h"]
]
inside_layer_modules = [["self_attention.query_key_value"], ["mlp.dense_h_to_4h"], ["mlp.dense_4h_to_h"]]
EXPECTED_RELATIVE_DIFFERENCE = 1.57705236164535

def test_not_converted_layers(self):
# self_attention.dense should not be converted
self.assertTrue(self.quantized_model.transformer.h[0].self_attention.dense.__class__.__name__== "Linear")
self.assertTrue(self.quantized_model.transformer.h[0].self_attention.dense.__class__.__name__ == "Linear")


class GPTQUtilsTest(unittest.TestCase):
"""
Expand Down

0 comments on commit 39aab85

Please sign in to comment.