Proposal to address precision issues in CI #4775
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Looking through the precision related tests Push failures, I noticed that most of the 85 failures are coming from tests defined in the PipelineMixin class. With 30 failures coming from test_float16_inference The reason for this is that all Pipeline tests inherit from this Mixin class, and run their tests with the default precision tolerance for the test.
Given that most pipelines on Slow Tests are using different checkpoints, they tend to produce very different levels of precision error.
e.g. (notice that Panorama, IF, and Kandinsky have different scales of error)
Rather than hardcoding these precision values into the individual tests, I am proposing that we use a measurement metric that is slightly more robust to the small numerical fluctuations caused by GPU Non-Determinism. Using cosine similarity distance between the generated outputs of the pipelines and our expected output to assess similarity.
Results from running the same tests with Cosine Similarity Distance and the default precision tolerance
To test the sensitivity of Cosine Similarity I ran a quick test, by adding gradually increasing levels of noise to a flattened image numpy array and measured the Max Abs Distance (what we use now) and the Cosine Similarity
Notice that at low noise levels (caused by GPU non-determinism) Cosine Similarity is relatively flat.
At higher noise levels Cosine Similarity does start to change more significantly.
Colab Notebook with Full Analysis:
https://colab.research.google.com/gist/DN6/fcbc10649977fbecd604e5feef1f5b05/cosine-similarity-tests.ipynb
Moving other precision related tests to use Cosine Distance will likely lead to a big reduction in flaky test behaviour due to GPU no determinism. Opening this PR for thoughts and discussion.
Fixes # (issue)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.