Skip to content

Commit

Permalink
gfx1201 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cemberk committed Feb 6, 2025
1 parent 351de66 commit c7f62db
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 99 deletions.
40 changes: 20 additions & 20 deletions tests/generation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2546,30 +2546,30 @@ class GenerationIntegrationTests(unittest.TestCase, GenerationIntegrationTestsMi
"return_tensors": "pt",
}

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_custom_logits_processor(self):
super().test_custom_logits_processor()
pass

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_max_new_tokens_encoder_decoder(self):
super().test_max_new_tokens_encoder_decoder()
pass

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_eos_token_id_int_and_list_beam_search(self):
super().test_eos_token_id_int_and_list_beam_search()
pass

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101'])
def test_transition_scores_greedy_search_normalized(self):
super().test_transition_scores_greedy_search_normalized()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101'])
def test_transition_scores_greedy_search(self):
super().test_transition_scores_greedy_search()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_input_features_as_encoder_kwarg(self):
super().test_generate_input_features_as_encoder_kwarg()

Expand Down Expand Up @@ -2608,7 +2608,7 @@ def test_diverse_beam_search(self):
],
)

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_max_length_if_input_embeds(self):
# PT-only test: TF doesn't have StoppingCriteria
article = "Today a dragon flew over Paris."
Expand All @@ -2623,7 +2623,7 @@ def test_max_length_if_input_embeds(self):
out_gen_embeds = model.generate(inputs_embeds=inputs_embeds, max_length=max_length)
self.assertEqual(out_gen.shape[-1], input_len + out_gen_embeds.shape[-1])

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_min_length_if_input_embeds(self):
# PT-only test: TF doesn't have StoppingCriteria
article = "Today a dragon flew over Paris."
Expand Down Expand Up @@ -2676,7 +2676,7 @@ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwa
)

# TODO (joao): replace `stop_sequence` in the pipeline by the more recent `generate` functionality
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_stop_sequence_stopping_criteria(self):
# PT-only test: TF doesn't have StoppingCriteria
prompt = """Hello I believe in"""
Expand Down Expand Up @@ -3212,7 +3212,7 @@ def test_decoder_start_id_from_config(self):
with self.assertRaises(ValueError):
outputs = bart_model.generate(input_ids, generation_config=GenerationConfig(do_sample=False))

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101'])
def test_contrastive_search_batched(self):
# PT-only test: TF doesn't have constrained beam search
# Tests that contrastive search works with batched inputs (i.e. has the same output as for non-batched inputs)
Expand Down Expand Up @@ -3260,7 +3260,7 @@ def test_logits_processor_not_inplace(self):
self.assertListEqual(out.logits[-1].tolist(), out.scores[-1].tolist())
self.assertNotEqual(out_with_temp.logits[-1].tolist(), out_with_temp.scores[-1].tolist())

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_eos_token_id_int_and_list_top_k_top_sampling(self):
# Has TF equivalent: this test relies on random sampling
generation_kwargs = {
Expand Down Expand Up @@ -3289,7 +3289,7 @@ def test_eos_token_id_int_and_list_top_k_top_sampling(self):
generated_tokens = model.generate(**tokens, eos_token_id=eos_token_id, **generation_kwargs)
self.assertTrue(expectation == len(generated_tokens[0]))

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_model_kwarg_encoder_signature_filtering(self):
# Has TF equivalent: ample use of framework-specific code
bart_tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-bart")
Expand Down Expand Up @@ -3327,7 +3327,7 @@ def forward(self, input_ids, **kwargs):
# FakeEncoder.forward() accepts **kwargs -> no filtering -> type error due to unexpected input "foo"
bart_model.generate(input_ids, foo="bar")

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_default_max_length_warning(self):
model = AutoModelForCausalLM.from_pretrained("hf-internal-testing/tiny-random-gpt2").to(torch_device)
tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-gpt2")
Expand Down Expand Up @@ -3385,7 +3385,7 @@ def test_default_assisted_generation(self):
self.assertEqual(config.assistant_confidence_threshold, 0.4)
self.assertEqual(config.is_assistant, False)

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_generated_length_assisted_generation(self):
# PT-only test: TF doesn't support assisted decoding yet.
model = AutoModelForCausalLM.from_pretrained("hf-internal-testing/tiny-random-gpt2").to(torch_device)
Expand Down Expand Up @@ -3414,7 +3414,7 @@ def test_generated_length_assisted_generation(self):
)
self.assertTrue((input_length + 10) <= out.shape[-1] <= 20)

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_model_kwarg_assisted_decoding_decoder_only(self):
# PT-only test: TF doesn't support assisted decoding yet.
model = AutoModelForCausalLM.from_pretrained("hf-internal-testing/tiny-random-gpt2").to(torch_device)
Expand Down Expand Up @@ -3449,7 +3449,7 @@ def test_model_kwarg_assisted_decoding_decoder_only(self):
)
self.assertListEqual(outputs_assisted.tolist(), outputs_tti.tolist())

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_model_kwarg_assisted_decoding_encoder_decoder(self):
"""
Tests that the following scenario is compatible with assisted generation:
Expand Down Expand Up @@ -3516,7 +3516,7 @@ def prepare_inputs_for_generation(self, *args, foo=False, encoder_outputs=None,
)
self.assertListEqual(outputs_assisted.tolist(), outputs_foo.tolist())

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_assisted_decoding_encoder_decoder_shared_encoder(self):
"""
Tests that the following scenario is compatible with assisted generation:
Expand Down Expand Up @@ -3595,7 +3595,7 @@ def prepare_inputs_for_generation(self, *args, foo=False, encoder_outputs=None,
)
self.assertListEqual(outputs_assisted.tolist(), outputs_foo.tolist())

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_assisted_decoding_num_assistant_tokens_heuristic_schedule(self):
# This test ensures that the assisted generation num_assistant_tokens 'heuristic' schedule works properly.

Expand Down Expand Up @@ -4093,7 +4093,7 @@ def test_padding_input_contrastive_search_t5(self):
self.assertEqual(generated_text_no_padding, generated_text_with_padding)
self.assertEqual(generated_text_no_padding, "Ich muss diese Aufgabe vor Ende des Tages beenden.")

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_prepare_inputs_for_generation_decoder_llm(self):
"""Tests GenerationMixin.prepare_inputs_for_generation against expected usage with decoder-only llms."""

Expand Down Expand Up @@ -4234,7 +4234,7 @@ def test_generate_compile_fullgraph_tiny(self):
gen_out = compiled_generate(**model_inputs, generation_config=generation_config)
self.assertTrue(gen_out.shape[1] > model_inputs["input_ids"].shape[1]) # some text was generated

@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx942','gfx90a','gfx1100','gfx1101','gfx1200'])
def test_assisted_generation_early_exit(self):
"""
Tests that assisted generation with early exit works as expected. Under the hood, this has complex cache
Expand Down
4 changes: 2 additions & 2 deletions tests/models/aria/test_modeling_aria.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ class AriaForConditionalGenerationModelTest(ModelTesterMixin, GenerationTesterMi
test_head_masking = False
_is_composite = True

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_flex_attention_with_grads(self):
super().test_flex_attention_with_grads()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_from_inputs_embeds_with_static_cache(self):
super().test_generate_from_inputs_embeds_with_static_cache()

Expand Down
2 changes: 1 addition & 1 deletion tests/models/data2vec/test_modeling_data2vec_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask
from transformers import Data2VecAudioConfig, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_soundfile, require_torch, slow, torch_device
from transformers.testing_utils import is_pt_flax_cross_test, require_soundfile, require_torch, slow, torch_device, skipIfRocm

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init
Expand Down
4 changes: 2 additions & 2 deletions tests/models/dbrx/test_modeling_dbrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ class DbrxModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin
test_headmasking = False
test_pruning = False

@skipIfRocm(arch=['gfx1201','gfx90a','gfx942','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx90a','gfx942','gfx1100','gfx1101','gfx1200'])
def test_generate_with_static_cache(self):
super().test_generate_with_static_cache()
pass

@skipIfRocm(arch=['gfx1201','gfx90a','gfx942','gfx1100','gfx1200'])
@skipIfRocm(arch=['gfx1201','gfx90a','gfx942','gfx1100','gfx1101','gfx1200'])
def test_generate_from_inputs_embeds_with_static_cache(self):
super().test_generate_from_inputs_embeds_with_static_cache()
pass
Expand Down
2 changes: 1 addition & 1 deletion tests/models/dpr/test_modeling_dpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class DPRModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
test_pruning = False
test_head_masking = False

@skipIfRocm(arch='gfx90a')
@skipIfRocm(arch=['gfx90a','gfx942'])
def test_eager_matches_sdpa_inference_2_float32(self):
super().test_eager_matches_sdpa_inference_2_float32()
pass
Expand Down
60 changes: 30 additions & 30 deletions tests/models/emu3/test_modeling_emu3.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,123 +319,123 @@ class Emu3Vision2TextModelTest(ModelTesterMixin, GenerationTesterMixin, Pipeline
test_pruning = False
fx_compatible = False

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_methods_with_logits_to_keep(self):
super().test_generate_methods_with_logits_to_keep()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_from_inputs_embeds_with_static_cache(self):
super().test_generate_from_inputs_embeds_with_static_cache()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_with_static_cache(self):
super().test_generate_with_static_cache()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_attention_outputs(self):
super().test_attention_outputs()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_batching_equivalence(self):
super().test_batching_equivalence()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_beam_sample_generate(self):
super().test_beam_sample_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_beam_sample_generate_dict_output(self):
super().test_beam_sample_generate_dict_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_beam_search_generate(self):
super().test_beam_search_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_generate_from_inputs_embeds_with_static_cache(self):
super().test_generate_from_inputs_embeds_with_static_cache()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_beam_search_generate_dict_output(self):
super().test_beam_search_generate_dict_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_beam_search_low_memory(self):
super().test_beam_search_low_memory()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_constrained_beam_search_generate(self):
super().test_constrained_beam_search_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_constrained_beam_search_generate_dict_output(self):
super().test_constrained_beam_search_generate_dict_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_determinism(self):
super().test_determinism()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_group_beam_search_generate(self):
super().test_group_beam_search_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_group_beam_search_generate_dict_output(self):
super().test_group_beam_search_generate_dict_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_hidden_states_output(self):
super().test_hidden_states_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_model_outputs_equivalence(self):
super().test_model_outputs_equivalence()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_offloaded_cache_implementation_0_offloaded(self):
super().test_offloaded_cache_implementation_0_offloaded()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_resize_tokens_embeddings(self):
super().test_resize_tokens_embeddings()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_retain_grad_hidden_states_attentions(self):
super().test_retain_grad_hidden_states_attentions()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_feed_forward_chunking(self):
super().test_feed_forward_chunking()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_flex_attention_with_grads(self):
super().test_flex_attention_with_grads()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_forward_with_logits_to_keep(self):
super().test_forward_with_logits_to_keep()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_greedy_generate(self):
super().test_greedy_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_greedy_generate_dict_outputs(self):
super().test_greedy_generate_dict_outputs()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_group_beam_search_generate(self):
super().test_group_beam_search_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_sample_generate(self):
super().test_sample_generate()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_sample_generate_dict_output(self):
super().test_sample_generate_dict_output()

@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1201','gfx1200'])
@skipIfRocm(arch=['gfx942','gfx90a','gfx1100','gfx1101','gfx1201','gfx1200'])
def test_save_load(self):
super().test_save_load()

Expand Down
Loading

0 comments on commit c7f62db

Please sign in to comment.