Skip to content
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

feat(//tests): Update rtol and atol based tolerance for test cases #1055

Merged
merged 3 commits into from
Jun 22, 2022

Conversation

andi4191
Copy link
Contributor

@andi4191 andi4191 commented May 11, 2022

Signed-off-by: Anurag Dixit a.dixit91@gmail.com

Description

Updating the tolerance metric using absolute and relative tolerance threshold.

This PR directly impacts the CI, DLFW workflow.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)
#1054

Type of change

Please delete options that are not relevant and/or add your own.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>
@andi4191 andi4191 added the component: tests Issues re: Tests label May 11, 2022
@andi4191 andi4191 requested a review from narendasan May 11, 2022 22:13
@andi4191 andi4191 self-assigned this May 11, 2022
@andi4191
Copy link
Contributor Author

Current threshold in test cases will act as absolute tolerance limit as intended.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

LOG_GRAPH(a << std::endl << b << std::endl);
auto a_float = a.toType(at::kFloat);
auto b_float = b.toType(at::kFloat);

auto diff = a_float - b_float;
auto result = diff.abs().max().item<float>() - (atol + rtol * b.abs().max().item<float>());
auto result = diff.abs().max().item<float>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This equation is still confusing (see #1052)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the discussion in 1052, is this resolved? Anurag mentioned we need this PR for DLFW release.

@andi4191 andi4191 requested a review from narendasan May 27, 2022 00:24
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/tests/util/util.cpp b/tmp/changes.txt
index 6dc0d81..13d0d18 100644
--- a/workspace/tests/util/util.cpp
+++ b/tmp/changes.txt
@@ -18,7 +18,7 @@ bool almostEqual(const at::Tensor& computed_tensor, const at::Tensor& gt_tensor,
  auto result = diff.abs().max().item<float>();
  auto threshold = atol + (rtol * gt_tensor.abs().max().item<float>());

-  LOG_GRAPH(std::string("Max Difference: ") + std::to_string(result) );
+  LOG_GRAPH(std::string("Max Difference: ") + std::to_string(result));
  LOG_GRAPH(std::string("Acceptable Threshold: ") + std::to_string(threshold));

  return result <= threshold;
ERROR: Some files do not conform to style guidelines

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

LGTM according to the equation that torch.allclose is using

LOG_GRAPH(a << std::endl << b << std::endl);
auto a_float = a.toType(at::kFloat);
auto b_float = b.toType(at::kFloat);

auto diff = a_float - b_float;
auto result = diff.abs().max().item<float>() - (atol + rtol * b.abs().max().item<float>());
auto result = diff.abs().max().item<float>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the discussion in 1052, is this resolved? Anurag mentioned we need this PR for DLFW release.

@peri044 peri044 merged commit c51ba38 into master Jun 22, 2022
@andi4191 andi4191 deleted the anuragd/test_update_atol_rtol branch August 10, 2022 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants