Skip to content

Commit 8f3bd10

Browse files
jiqing-fengsayakpaul
authored andcommitted
reset deterministic in tearDownClass (huggingface#11785)
* reset deterministic in tearDownClass Signed-off-by: jiqing-feng <[email protected]> * fix deterministic setting Signed-off-by: jiqing-feng <[email protected]> --------- Signed-off-by: jiqing-feng <[email protected]> Co-authored-by: Sayak Paul <[email protected]>
1 parent fee118f commit 8f3bd10

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/quantization/bnb/test_4bit.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ class Base4bitTests(unittest.TestCase):
9898

9999
@classmethod
100100
def setUpClass(cls):
101-
torch.use_deterministic_algorithms(True)
101+
cls.is_deterministic_enabled = torch.are_deterministic_algorithms_enabled()
102+
if not cls.is_deterministic_enabled:
103+
torch.use_deterministic_algorithms(True)
104+
105+
@classmethod
106+
def tearDownClass(cls):
107+
if not cls.is_deterministic_enabled:
108+
torch.use_deterministic_algorithms(False)
102109

103110
def get_dummy_inputs(self):
104111
prompt_embeds = load_pt(

tests/quantization/bnb/test_mixed_int8.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ class Base8bitTests(unittest.TestCase):
9999

100100
@classmethod
101101
def setUpClass(cls):
102-
torch.use_deterministic_algorithms(True)
102+
cls.is_deterministic_enabled = torch.are_deterministic_algorithms_enabled()
103+
if not cls.is_deterministic_enabled:
104+
torch.use_deterministic_algorithms(True)
105+
106+
@classmethod
107+
def tearDownClass(cls):
108+
if not cls.is_deterministic_enabled:
109+
torch.use_deterministic_algorithms(False)
103110

104111
def get_dummy_inputs(self):
105112
prompt_embeds = load_pt(

0 commit comments

Comments
 (0)