Skip to content

Commit 3330584

Browse files
matthewdouglasAlanPonnachan
authored andcommitted
Fix new BNB test failures (huggingface#35345)
1 parent 34fc6b8 commit 3330584

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/quantization/bnb/test_4bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_memory_footprint(self):
172172
mem_fp16 = self.model_fp16.get_memory_footprint()
173173
mem_4bit = self.model_4bit.get_memory_footprint()
174174

175-
self.assertAlmostEqual(mem_fp16 / mem_4bit, self.EXPECTED_RELATIVE_DIFFERENCE)
175+
self.assertAlmostEqual(mem_fp16 / mem_4bit, self.EXPECTED_RELATIVE_DIFFERENCE, delta=1e-5)
176176
linear = get_some_linear_layer(self.model_4bit)
177177
self.assertTrue(linear.weight.__class__ == Params4bit)
178178

tests/quantization/bnb/test_mixed_int8.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def test_memory_footprint(self):
229229
mem_fp16 = self.model_fp16.get_memory_footprint()
230230
mem_8bit = self.model_8bit.get_memory_footprint()
231231

232-
self.assertAlmostEqual(mem_fp16 / mem_8bit, self.EXPECTED_RELATIVE_DIFFERENCE)
232+
self.assertAlmostEqual(mem_fp16 / mem_8bit, self.EXPECTED_RELATIVE_DIFFERENCE, delta=1e-5)
233233
self.assertTrue(get_some_linear_layer(self.model_8bit).weight.__class__ == Int8Params)
234234

235235
def test_linear_are_8bit(self):
@@ -938,8 +938,13 @@ class MixedInt8LlamaTest(MixedInt8Test):
938938
model_name = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
939939
EXPECTED_RELATIVE_DIFFERENCE = 1.7869331026479096
940940
EXPECTED_OUTPUTS = set()
941+
942+
# Expected on Intel XPU
941943
EXPECTED_OUTPUTS.add("Hello my name is John Smith and I am a software engineer. I")
942944

945+
# Expected on NVIDIA T4
946+
EXPECTED_OUTPUTS.add("Hello my name is John and I am a software engineer. I have")
947+
943948
def test_int8_from_pretrained(self):
944949
r"""
945950
Test whether loading a 8bit model from the Hub works as expected

0 commit comments

Comments
 (0)