device agnostic models testing (#27146)
* device agnostic models testing * add decorator `require_torch_fp16` * make style * apply review suggestion * Oops, the fp16 decorator was misused
This commit is contained in:
@@ -23,7 +23,13 @@ import numpy as np
|
||||
import requests
|
||||
|
||||
from transformers import CONFIG_MAPPING, Blip2Config, Blip2QFormerConfig, Blip2VisionConfig
|
||||
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
|
||||
from transformers.testing_utils import (
|
||||
require_torch,
|
||||
require_torch_multi_accelerator,
|
||||
require_vision,
|
||||
slow,
|
||||
torch_device,
|
||||
)
|
||||
from transformers.utils import is_torch_available, is_vision_available
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
@@ -934,8 +940,8 @@ class Blip2ModelIntegrationTest(unittest.TestCase):
|
||||
self.assertEqual(predictions[0].tolist(), [0, 2335, 1556, 28, 1782, 30, 8, 2608, 1])
|
||||
self.assertEqual(predictions[1].tolist(), [0, 2335, 1556, 28, 1782, 30, 8, 2608, 1])
|
||||
|
||||
@require_torch_multi_gpu
|
||||
def test_inference_opt_multi_gpu(self):
|
||||
@require_torch_multi_accelerator
|
||||
def test_inference_opt_multi_accelerator(self):
|
||||
processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
||||
model = Blip2ForConditionalGeneration.from_pretrained(
|
||||
"Salesforce/blip2-opt-2.7b", torch_dtype=torch.float16, device_map="balanced"
|
||||
@@ -966,8 +972,8 @@ class Blip2ModelIntegrationTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(generated_text, "it's not a city, it's a beach")
|
||||
|
||||
@require_torch_multi_gpu
|
||||
def test_inference_t5_multi_gpu(self):
|
||||
@require_torch_multi_accelerator
|
||||
def test_inference_t5_multi_accelerator(self):
|
||||
processor = Blip2Processor.from_pretrained("Salesforce/blip2-flan-t5-xl")
|
||||
device_map = device_map = {
|
||||
"query_tokens": 0,
|
||||
|
||||
Reference in New Issue
Block a user