Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20014
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit bc75860 with merge base 20675ac ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: none" |
|
cc: @gjcomer @kirklandsign @metascroy @digantdesai Would appreciate any feedback on the approach. Thank you! |
|
@gggekov could you review this? |
GregoryComer
left a comment
There was a problem hiding this comment.
Looks reasonable. Thanks for adding this.
b34ccc9 to
ed9709b
Compare
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
ed9709b to
ded3ddf
Compare
|
@pytorchbot label -"Stale" |
|
❌ 🤖 pytorchbot command failed: Try |
|
@pytorchbot label "no-stale" |
Add a tolerance registry that documents per-backend numerical accuracy defaults extracted from a cross-backend audit of all ExecuTorch test files. Wire it into the Tester harness so backends that identify themselves via the new `backend` parameter get appropriate tolerance defaults automatically. New files: - backends/test/harness/tolerance.py: ToleranceConfig dataclass, BACKEND_TOLERANCES registry (15 backends), get_tolerance() lookup with fallback chain (dtype-specific → backend default → global default) - backends/test/harness/tests/test_tolerance.py: 37 unit tests Tester integration: - New optional `backend` param in Tester.__init__() - run_method_and_compare_outputs() consults registry when tolerances are not explicitly provided - Fully backward-compatible: no backend set = same defaults as before (atol=1e-3, rtol=1e-3, qtol=0); explicit values always win Part of pytorch#19910. See pytorch#13347 for the broader tolerance strategy discussion.
|
CI workflows are awaiting approval - could a maintainer please approve the runs? This PR was approved by @GregoryComer and is ready to merge once CI passes. |
|
Thanks for the ping, @RiyaP2508. While I run CI tests, @gggekov could you review the PR as well? |
|
@rascani hey tagging you on this. Thanks for coming to our poster :) |
rascani
left a comment
There was a problem hiding this comment.
Generally LGTM, just want to know how to plan on passing dtype & quantization through.
| if self.backend is not None: | ||
| from executorch.backends.test.harness.tolerance import get_tolerance | ||
|
|
||
| config = get_tolerance(self.backend) |
There was a problem hiding this comment.
This lookup always uses the default dtype=torch.float32 and quantized=False. With backend="xnnpack", fp16 comparisons therefore get atol=0.001 instead of 0.002, and quantized comparisons get qtol=0 instead of 1.
Could we pass the output dtype and quantization state into the lookup? A test through Tester.run_method_and_compare_outputs() would catch this; the current tests only exercise the registry directly.
There was a problem hiding this comment.
@rascani yeah you're right -- it's always hitting "default" right now. The fix should be straightforward since quantization_scale and reference_output.dtype are already available inside the loop:
ref = reference_output[0] if isinstance(reference_output, tuple) else reference_output
config = get_tolerance(self.backend, dtype=ref.dtype, quantized=quantization_scale is not None)
Same quantization_scale signal that's already used at line 514. I'll add a test through run_method_and_compare_outputs() for the fp16/quantized paths too.
Happy to adjust if you have a better approach in mind!
There was a problem hiding this comment.
Deriving the dtype/quantization from a output dtype assumes that output metadata represents the computation's numerical behavior. Its fairly common for outputs to be dequantized. I'd prefer the backend/test configuration select the intended precision and quantization profile.
Summary
Add a centralized tolerance registry for the backend test harness that documents per-backend numerical accuracy defaults and integrates with the
Testerclass.ToleranceConfigdataclass andget_tolerance()lookup API inbackends/test/harness/tolerance.pyTester.__init__()accepts optionalbackendparameterrun_method_and_compare_outputs()consults registry when tolerances aren't explicitly providedPart of #19910.
Test plan
backends/test/harness/tests/test_tolerance.py— all passingcc @nil-is-all