Skip to content

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Nov 7, 2022

Closes #6750. Instead of having a fixed info.closeness_kwargs, this PR adds support for info.get_closeness_kwargs(test_id, dtype=dtype, device=device). Here, test_id is the same concept we are already using for @pytest.mark's

# Tuple of test class name and test function name that identifies the test the mark is applied to. If there is
# no test class, i.e. a standalone test function, use `None`.
test_id,

Meaning, with this PR we have the ability to set the tolerances on a test, dtype, device level. IMO that should be enough. If someone needs even finer control, you are probably better off writing a custom test rather than using the common test infrastructure.

cc @vfdev-5 @datumbox @bjuncek

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, feel free to merge on green CI.

class InfoBase:
def __init__(self, *, id, test_marks=None, closeness_kwargs=None):
def __init__(
self,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change just moves the comments to the signature as it is done in all other related classes.

Comment on lines +64 to +67
DEFAULT_PIL_REFERENCE_CLOSENESS_KWARGS = {
(("TestKernels", "test_against_reference"), torch.float32, "cpu"): dict(atol=1e-5, rtol=0, agg_method="mean"),
(("TestKernels", "test_against_reference"), torch.uint8, "cpu"): dict(atol=1e-5, rtol=0, agg_method="mean"),
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two lessons here:

  1. We only need the tolerances for the reference tests, but they were applied everywhere. There was no harm here, but this could have hidden bugs before.
  2. Some of our kernels like resize produce quite large differences for some pixels, which are hidden by aggregating them. Maybe we should review and use stricter "default" tolerances and just increase it for the few that need more.

@pmeier pmeier requested a review from vfdev-5 November 7, 2022 12:38
@pmeier pmeier merged commit b80f83d into pytorch:main Nov 7, 2022
@pmeier pmeier deleted the fine-tol branch November 7, 2022 15:56
facebook-github-bot pushed a commit that referenced this pull request Nov 14, 2022
Summary:
* add support for fine-grained tolerance settings

* fix test_cuda_vs_cpu

Reviewed By: NicolasHug

Differential Revision: D41265204

fbshipit-source-id: 8309f5d957f0ff351277684349b6926c8f2c1775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow closeness_kwargs to be set more specifically

3 participants