Less flaky test_assisted_decoding_matches_greedy_search (#23451)
* fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -1477,6 +1477,9 @@ class GenerationTesterMixin:
|
||||
):
|
||||
return
|
||||
|
||||
# This for loop is a naive and temporary effort to make the test less flaky.
|
||||
failed = 0
|
||||
for i in range(10):
|
||||
# enable cache
|
||||
config, input_ids, attention_mask, max_length = self._get_input_ids_and_config(batch_size=1)
|
||||
|
||||
@@ -1513,6 +1516,14 @@ class GenerationTesterMixin:
|
||||
return_dict_in_generate=True,
|
||||
)
|
||||
|
||||
try:
|
||||
self.assertListEqual(output_greedy.sequences.tolist(), output_assisted.sequences.tolist())
|
||||
|
||||
for output in (output_greedy, output_assisted):
|
||||
self._check_outputs(output, input_ids, model.config, use_cache=True)
|
||||
except AssertionError:
|
||||
failed += 1
|
||||
if failed > 1:
|
||||
self.assertListEqual(output_greedy.sequences.tolist(), output_assisted.sequences.tolist())
|
||||
|
||||
for output in (output_greedy, output_assisted):
|
||||
|
||||
Reference in New Issue
Block a user