-
Notifications
You must be signed in to change notification settings - Fork 7.2k
add support for fine-grained tolerance settings #6921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
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"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two lessons here:
- 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.
- 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.
Summary: * add support for fine-grained tolerance settings * fix test_cuda_vs_cpu Reviewed By: NicolasHug Differential Revision: D41265204 fbshipit-source-id: 8309f5d957f0ff351277684349b6926c8f2c1775
Closes #6750. Instead of having a fixed
info.closeness_kwargs
, this PR adds support forinfo.get_closeness_kwargs(test_id, dtype=dtype, device=device)
. Here,test_id
is the same concept we are already using for@pytest.mark
'svision/test/prototype_common_utils.py
Lines 605 to 607 in 4f3a000
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