Skip to content

Commit 02d7bea

Browse files
committed
post rebase
1 parent e99a46c commit 02d7bea

File tree

8 files changed

+17
-29
lines changed

8 files changed

+17
-29
lines changed

docs/source/en/model_doc/hubert.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", spli
6565
sampling_rate = dataset.features["audio"].sampling_rate
6666

6767
processor = AutoProcessor.from_pretrained("facebook/hubert-base-ls960")
68-
model = AutoModelForCTC.from_pretrained("facebook/hubert-base-ls960", torch_dtype=torch.float16, device_map="auto", attn_implementation="sdpa")
68+
model = AutoModelForCTC.from_pretrained("facebook/hubert-base-ls960", dtype=torch.float16, device_map="auto", attn_implementation="sdpa")
6969

7070
inputs = processor(dataset[0]["audio"]["array"], sampling_rate=sampling_rate, return_tensors="pt")
7171
with torch.no_grad():
@@ -100,7 +100,7 @@ dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", spli
100100
sampling_rate = dataset.features["audio"].sampling_rate
101101

102102
processor = AutoProcessor.from_pretrained("facebook/hubert-base-ls960")
103-
model = AutoModelForCTC.from_pretrained("facebook/hubert-base-ls960", quantization_config=bnb_config, torch_dtype=torch.float16, device_map="auto", attn_implementation="sdpa")
103+
model = AutoModelForCTC.from_pretrained("facebook/hubert-base-ls960", quantization_config=bnb_config, dtype=torch.float16, device_map="auto", attn_implementation="sdpa")
104104

105105
inputs = processor(dataset[0]["audio"]["array"], sampling_rate=sampling_rate, return_tensors="pt")
106106
with torch.no_grad():

src/transformers/pipelines/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ def pipeline(
983983
model_kwargs["device_map"] = device_map
984984

985985
# BC for the `torch_dtype` argument
986-
if (torch_dtype := kwargs.get("torch_dtype", None)) is not None:
986+
if (torch_dtype := kwargs.get("torch_dtype")) is not None:
987987
logger.warning_once("`torch_dtype` is deprecated! Use `dtype` instead!")
988988
# If both are provided, keep `dtype`
989989
dtype = torch_dtype if dtype == "auto" else dtype

tests/models/fuyu/test_modeling_fuyu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def default_processor(self):
265265

266266
@cached_property
267267
def default_model(self):
268-
return FuyuForCausalLM.from_pretrained("adept/fuyu-8b", torch_dtype="float16", device_map=torch_device)
268+
return FuyuForCausalLM.from_pretrained("adept/fuyu-8b", dtype="float16", device_map=torch_device)
269269

270270
def test_greedy_generation(self):
271271
processor = self.default_processor

tests/models/gemma2/test_modeling_gemma2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def test_generation_beyond_sliding_window_dynamic(self, attn_implementation: str
506506
inputs = tokenizer(input_text, padding=True, return_tensors="pt").to(torch_device)
507507

508508
model = AutoModelForCausalLM.from_pretrained(
509-
model_id, attn_implementation=attn_implementation, torch_dtype=torch.float16
509+
model_id, attn_implementation=attn_implementation, dtype=torch.float16
510510
).to(torch_device)
511511

512512
# Make sure prefill is larger than sliding window

tests/models/glm4_moe/test_modeling_glm4_moe.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ def test_compile_static_cache(self):
108108

109109
prompts = ["[gMASK]<sop>hello", "[gMASK]<sop>tell me"]
110110
tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-4.5")
111-
model = Glm4MoeForCausalLM.from_pretrained(
112-
"zai-org/GLM-4.5", device_map=torch_device, dtype=torch.bfloat16
113-
)
111+
model = Glm4MoeForCausalLM.from_pretrained("zai-org/GLM-4.5", device_map=torch_device, dtype=torch.bfloat16)
114112
inputs = tokenizer(prompts, return_tensors="pt", padding=True).to(model.device)
115113

116114
# Dynamic Cache

tests/models/glm4v_moe/test_modeling_glm4v_moe.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,7 @@ def tearDown(self):
328328

329329
@slow
330330
def test_small_model_integration_test(self):
331-
model = Glm4vMoeForConditionalGeneration.from_pretrained(
332-
"zai-org/GLM-4.5V", torch_dtype="auto", device_map="auto"
333-
)
331+
model = Glm4vMoeForConditionalGeneration.from_pretrained("zai-org/GLM-4.5V", dtype="auto", device_map="auto")
334332

335333
inputs = self.processor.apply_chat_template(
336334
self.message, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
@@ -364,9 +362,7 @@ def test_small_model_integration_test(self):
364362

365363
@slow
366364
def test_small_model_integration_test_batch(self):
367-
model = Glm4vMoeForConditionalGeneration.from_pretrained(
368-
"zai-org/GLM-4.5V", torch_dtype="auto", device_map="auto"
369-
)
365+
model = Glm4vMoeForConditionalGeneration.from_pretrained("zai-org/GLM-4.5V", dtype="auto", device_map="auto")
370366
batch_messages = [self.message] * 2
371367
inputs = self.processor.apply_chat_template(
372368
batch_messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
@@ -388,7 +384,7 @@ def test_small_model_integration_test_batch(self):
388384
def test_small_model_integration_test_with_video(self):
389385
processor = AutoProcessor.from_pretrained("zai-org/GLM-4.5V", max_image_size={"longest_edge": 50176})
390386
model = Glm4vMoeForConditionalGeneration.from_pretrained(
391-
"zai-org/GLM-4.5V", torch_dtype=torch.float16, device_map="auto"
387+
"zai-org/GLM-4.5V", dtype=torch.float16, device_map="auto"
392388
)
393389
questions = ["Describe this video."] * 2
394390
video_urls = [
@@ -424,9 +420,7 @@ def test_small_model_integration_test_with_video(self):
424420

425421
@slow
426422
def test_small_model_integration_test_expand(self):
427-
model = Glm4vMoeForConditionalGeneration.from_pretrained(
428-
"zai-org/GLM-4.5V", torch_dtype="auto", device_map="auto"
429-
)
423+
model = Glm4vMoeForConditionalGeneration.from_pretrained("zai-org/GLM-4.5V", dtype="auto", device_map="auto")
430424
inputs = self.processor.apply_chat_template(
431425
self.message, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
432426
).to(torch_device)
@@ -444,9 +438,7 @@ def test_small_model_integration_test_expand(self):
444438

445439
@slow
446440
def test_small_model_integration_test_batch_wo_image(self):
447-
model = Glm4vMoeForConditionalGeneration.from_pretrained(
448-
"zai-org/GLM-4.5V", torch_dtype="auto", device_map="auto"
449-
)
441+
model = Glm4vMoeForConditionalGeneration.from_pretrained("zai-org/GLM-4.5V", dtype="auto", device_map="auto")
450442
message_wo_image = [
451443
{"role": "user", "content": [{"type": "text", "text": "Who are you?"}]},
452444
]
@@ -474,9 +466,7 @@ def test_small_model_integration_test_batch_wo_image(self):
474466

475467
@slow
476468
def test_small_model_integration_test_batch_different_resolutions(self):
477-
model = Glm4vMoeForConditionalGeneration.from_pretrained(
478-
"zai-org/GLM-4.5V", torch_dtype="auto", device_map="auto"
479-
)
469+
model = Glm4vMoeForConditionalGeneration.from_pretrained("zai-org/GLM-4.5V", dtype="auto", device_map="auto")
480470
batched_messages = [self.message, self.message2]
481471
inputs = self.processor.apply_chat_template(
482472
batched_messages,
@@ -505,7 +495,7 @@ def test_small_model_integration_test_batch_different_resolutions(self):
505495
def test_small_model_integration_test_batch_flashatt2(self):
506496
model = Glm4vMoeForConditionalGeneration.from_pretrained(
507497
"zai-org/GLM-4.5V",
508-
torch_dtype=torch.bfloat16,
498+
dtype=torch.bfloat16,
509499
attn_implementation="flash_attention_2",
510500
device_map="auto",
511501
)
@@ -537,7 +527,7 @@ def test_small_model_integration_test_batch_flashatt2(self):
537527
def test_small_model_integration_test_batch_wo_image_flashatt2(self):
538528
model = Glm4vMoeForConditionalGeneration.from_pretrained(
539529
"zai-org/GLM-4.5V",
540-
torch_dtype=torch.bfloat16,
530+
dtype=torch.bfloat16,
541531
attn_implementation="flash_attention_2",
542532
device_map="auto",
543533
)

tests/models/mistral/test_modeling_mistral.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def test_generation_beyond_sliding_window_dynamic(self, attn_implementation: str
355355
inputs = tokenizer(input_text, padding=True, return_tensors="pt").to(torch_device)
356356

357357
model = MistralForCausalLM.from_pretrained(
358-
model_id, attn_implementation=attn_implementation, device_map=torch_device, torch_dtype=torch.float16
358+
model_id, attn_implementation=attn_implementation, device_map=torch_device, dtype=torch.float16
359359
)
360360

361361
# Make sure prefill is larger than sliding window

tests/test_modeling_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ def flash_attn_inference_equivalence(self, attn_implementation: str, padding_sid
34963496
model = model_class(config)
34973497
with tempfile.TemporaryDirectory() as tmpdirname:
34983498
model.save_pretrained(tmpdirname)
3499-
model = model_class.from_pretrained(tmpdirname, torch_dtype=torch.bfloat16)
3499+
model = model_class.from_pretrained(tmpdirname, dtype=torch.bfloat16)
35003500
model.to(torch_device)
35013501

35023502
dummy_input = inputs_dict[model.main_input_name][:1]
@@ -4330,7 +4330,7 @@ def test_flash_attention_2_continue_generate_with_position_ids(self):
43304330
model = (
43314331
model_class.from_pretrained(
43324332
tmpdirname,
4333-
torch_dtype=torch.bfloat16,
4333+
dtype=torch.bfloat16,
43344334
attn_implementation="flash_attention_2",
43354335
)
43364336
.to(torch_device)

0 commit comments

Comments
 (0)