Skip to content

[Backend Tester] Add tensor error statistic reporting #12809

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

Open
wants to merge 3 commits into
base: gh/GregoryComer/88/head
Choose a base branch
from

Conversation

GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Jul 24, 2025

Report various error statistics for the test outputs, including SQNR, mean absolute error (MAE), and L2 norm. These are saved in the detail report per test case.

As an example, here is the output from Core ML running MobileNet V2 (roughly formatted from csv -> sheets -> markdown):

Output 0 Error Max	Output 0 Error MAE	Output 0 Error MSD	Output 0 Error L2	Output 0 SQNR
0.0005887411535		0.0001199183663		2.32E-06		0.004750485188		41.28595734

TODO: Round to a reasonable number of significant figures. (Or leave in full precision in the report?)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jul 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/12809

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit ef7af5c with merge base 4fd2079 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 24, 2025
GregoryComer added a commit that referenced this pull request Jul 24, 2025
ghstack-source-id: 9eb6b0a
ghstack-comment-id: 3112003831
Pull-Request: #12809
@GregoryComer GregoryComer requested a review from digantdesai July 24, 2025 05:29
@@ -302,17 +303,15 @@ def run_method_and_compare_outputs(
atol=1e-03,
rtol=1e-03,
qtol=0,
statistics_callback: Callable[[ErrorStatistics], None] | None = None,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not completely happy with the callback approach for exposing this, but I don't really have a better idea, since the tester relies on a builder-style pattern where it returns self to allow chaining. I'm open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

just update the tester method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you clarify what you're thinking? Are you meaning update the tester run_method_and_compare outputs to directly return the error stats and then update all of the callers to not use it in a chained fashion? Or something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Modify the existing method, keeping the outside behavior but also add def get_comparison_stats(self) method on that stage or something?
Or if you want to pass a callback for flexibility that's also fine.

@GregoryComer
Copy link
Member Author

I'll add some tests for the error statistic calculation to this PR shortly.

[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Jul 24, 2025
ghstack-source-id: dd1b232
ghstack-comment-id: 3112003831
Pull-Request: #12809
[ghstack-poisoned]
GregoryComer added a commit that referenced this pull request Jul 24, 2025
ghstack-source-id: 63819cb
ghstack-comment-id: 3112003831
Pull-Request: #12809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants