"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "31ee80d55673f32c0f5d50936f371e661b74b21a"
Unverified Commit 2406dbdc authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Less flaky `test_assisted_decoding_matches_greedy_search` (#23451)



* fix

* fix

---------
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent 21f7e81b
...@@ -1477,6 +1477,9 @@ class GenerationTesterMixin: ...@@ -1477,6 +1477,9 @@ class GenerationTesterMixin:
): ):
return 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 # enable cache
config, input_ids, attention_mask, max_length = self._get_input_ids_and_config(batch_size=1) config, input_ids, attention_mask, max_length = self._get_input_ids_and_config(batch_size=1)
...@@ -1513,6 +1516,14 @@ class GenerationTesterMixin: ...@@ -1513,6 +1516,14 @@ class GenerationTesterMixin:
return_dict_in_generate=True, 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()) self.assertListEqual(output_greedy.sequences.tolist(), output_assisted.sequences.tolist())
for output in (output_greedy, output_assisted): for output in (output_greedy, output_assisted):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment