Skip to content

Commit 8c8b529

Browse files
CI: More caching in tests to avoid 429 (#2472)
1 parent 7dcdf7b commit 8c8b529

11 files changed

+90
-55
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
env:
1313
HF_HOME: .cache/huggingface
14+
TRANSFORMERS_IS_CI: 1
1415

1516
permissions: {}
1617

tests/test_common_gpu.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import pytest
1919
import torch
2020
import torch.nn.functional as F
21-
from datasets import load_dataset
2221
from parameterized import parameterized
2322
from torch import nn
2423
from transformers import (
@@ -59,6 +58,7 @@
5958

6059
from .testing_utils import (
6160
device_count,
61+
load_cat_image,
6262
require_bitsandbytes,
6363
require_multi_accelerator,
6464
require_non_cpu,
@@ -1416,8 +1416,7 @@ def test_apply_GS_hra_conv2d_inference(self):
14161416
# check for different result with and without apply_GS
14171417
model_id = "microsoft/resnet-18"
14181418
image_processor = AutoImageProcessor.from_pretrained(model_id)
1419-
dataset = load_dataset("huggingface/cats-image", trust_remote_code=True)
1420-
image = dataset["test"]["image"][0]
1419+
image = load_cat_image()
14211420
data = image_processor(image, return_tensors="pt")
14221421

14231422
model = AutoModelForImageClassification.from_pretrained(model_id).eval()

tests/test_decoder_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import pytest
1919
import torch
20-
from datasets import load_dataset
2120
from parameterized import parameterized
2221
from transformers import (
2322
AutoModelForCausalLM,
@@ -43,6 +42,7 @@
4342

4443
from .testing_common import PeftCommonTester
4544
from .testing_common import PeftTestConfigManagerForDecoderModels as PeftTestConfigManager
45+
from .testing_utils import load_dataset_english_quotes
4646

4747

4848
PEFT_DECODER_MODELS_TO_TEST = [
@@ -526,7 +526,7 @@ def process(samples):
526526
tokenized = tokenizer(samples["quote"], truncation=True, max_length=128)
527527
return tokenized
528528

529-
data = load_dataset("ybelkada/english_quotes_copy")
529+
data = load_dataset_english_quotes()
530530
data = data.map(process, batched=True)
531531

532532
with tempfile.TemporaryDirectory() as tmp_dirname:
@@ -579,7 +579,7 @@ def process(samples):
579579
tokenized = tokenizer(samples["quote"], truncation=True, max_length=128)
580580
return tokenized
581581

582-
data = load_dataset("ybelkada/english_quotes_copy")
582+
data = load_dataset_english_quotes()
583583
data = data.map(process, batched=True)
584584

585585
with tempfile.TemporaryDirectory() as tmp_dirname:

tests/test_gptqmodel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import pytest
2222
import torch
23-
from datasets import load_dataset
2423
from transformers import (
2524
AutoModelForCausalLM,
2625
AutoTokenizer,
@@ -40,6 +39,7 @@
4039
from peft.utils import SAFETENSORS_WEIGHTS_NAME, infer_device
4140

4241
from .testing_utils import (
42+
load_dataset_english_quotes,
4343
require_gptqmodel,
4444
require_optimum,
4545
require_torch_multi_gpu,
@@ -158,7 +158,7 @@ def test_causal_lm_training(self):
158158
)
159159
model = get_peft_model(model, config)
160160

161-
data = load_dataset("ybelkada/english_quotes_copy")
161+
data = load_dataset_english_quotes()
162162
data = data.map(lambda samples: self.tokenizer(samples["quote"]), batched=True)
163163

164164
trainer = Trainer(
@@ -221,7 +221,7 @@ def test_adalora_causalLM(self):
221221

222222
model = get_peft_model(model, peft_config)
223223

224-
data = load_dataset("ybelkada/english_quotes_copy")
224+
data = load_dataset_english_quotes()
225225
data = data.map(lambda samples: self.tokenizer(samples["quote"]), batched=True)
226226
batch = tokenizer(data["train"][:3]["quote"], return_tensors="pt", padding=True)
227227
self._check_inference_finite(model, batch)
@@ -287,7 +287,7 @@ def test_causal_lm_training_multi_gpu(self):
287287

288288
model = get_peft_model(model, config)
289289

290-
data = load_dataset("Abirate/english_quotes")
290+
data = load_dataset_english_quotes()
291291
data = data.map(lambda samples: self.tokenizer(samples["quote"]), batched=True)
292292

293293
trainer = Trainer(

0 commit comments

Comments
 (0)