Skip to content

Commit 07726ef

Browse files
authored
Remove MonkeyPatch for GPUs (#1227)
SUMMARY: - This was added previously due to an error we were seeing with multiple GPUs (i.e having more than one gpu visible would cause an error) - Can verify this no longer happens
1 parent 7bb517f commit 07726ef

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

tests/llmcompressor/transformers/finetune/test_finetune_no_recipe_custom_dataset.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def create_mock_file(self, extension, content, path, filename):
108108

109109
def tearDown(self):
110110
shutil.rmtree(self.output)
111-
self.monkeypatch.undo()
112111

113112

114113
@pytest.mark.integration
@@ -121,11 +120,8 @@ class TestOneshotCustomDatasetSmall(TestFinetuneNoRecipeCustomDataset):
121120
def setUp(self):
122121
import torch
123122

124-
self.monkeypatch = pytest.MonkeyPatch()
125-
126123
if torch.cuda.is_available():
127124
self.device = "cuda:0"
128-
self.monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
129125
else:
130126
self.device = "cpu"
131127

@@ -147,15 +143,12 @@ def setUp(self):
147143
import torch
148144
from transformers import AutoModelForCausalLM
149145

150-
self.monkeypatch = pytest.MonkeyPatch()
151146
self.device = "cuda:0"
152147
self.output = "./oneshot_output"
153-
self.monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
154148

155149
self.model = AutoModelForCausalLM.from_pretrained(
156150
self.model, device_map=self.device, torch_dtype=torch.bfloat16
157151
)
158-
self.monkeypatch = pytest.MonkeyPatch()
159152

160153
def test_oneshot_then_finetune_gpu(self):
161154
self._test_finetune_wout_recipe_custom_dataset()

tests/llmcompressor/transformers/finetune/test_oneshot_and_finetune_with_tokenizer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ def setUp(self):
2121
self.output = "./finetune_output"
2222
# finetune workflows in general seem to have trouble with multi-gpus
2323
# use just one atm
24-
self.monkeypatch = pytest.MonkeyPatch()
2524

2625
def test_oneshot_and_finetune_with_tokenizer(self):
2726
from datasets import load_dataset
2827
from transformers import AutoModelForCausalLM, AutoTokenizer
2928

3029
from llmcompressor.transformers import compress
3130

32-
self.monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
33-
3431
recipe_str = (
3532
"tests/llmcompressor/transformers/finetune/test_alternate_recipe.yaml"
3633
)
@@ -71,4 +68,3 @@ def test_oneshot_and_finetune_with_tokenizer(self):
7168

7269
def tearDown(self):
7370
shutil.rmtree(self.output)
74-
self.monkeypatch.undo()

0 commit comments

Comments
 (0)