Skip to content

Add centralized tolerance registry and integrate with Tester harness#20014

Open
RiyaP2508 wants to merge 1 commit into
pytorch:mainfrom
RiyaP2508:rpunia/tolerance-registry
Open

Add centralized tolerance registry and integrate with Tester harness#20014
RiyaP2508 wants to merge 1 commit into
pytorch:mainfrom
RiyaP2508:rpunia/tolerance-registry

Conversation

@RiyaP2508

@RiyaP2508 RiyaP2508 commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Add a centralized tolerance registry for the backend test harness that documents per-backend numerical accuracy defaults and integrates with the Tester class.

  • New ToleranceConfig dataclass and get_tolerance() lookup API in backends/test/harness/tolerance.py
  • Registry covers 15 backends with defaults extracted from a cross-backend audit
  • Tester.__init__() accepts optional backend parameter
  • run_method_and_compare_outputs() consults registry when tolerances aren't explicitly provided
  • Fully backward-compatible: no backend = same defaults as before; explicit values always win
  • 37 unit tests

Part of #19910.

Test plan

  • 37 unit tests in backends/test/harness/tests/test_tolerance.py — all passing
  • Backward compatibility verified: no-backend path produces identical 1e-3/1e-3/0 defaults
  • Explicit atol/rtol/qtol values always override registry
  • CI passes (no existing tests modified)

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.
@pytorch-bot

pytorch-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

🔗 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.

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

@meta-cla meta-cla 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 Jun 4, 2026
@RiyaP2508

Copy link
Copy Markdown
Author

@pytorchbot label "release notes: none"

@RiyaP2508

RiyaP2508 commented Jun 4, 2026

Copy link
Copy Markdown
Author

cc: @gjcomer @kirklandsign @metascroy @digantdesai

Would appreciate any feedback on the approach. Thank you!

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. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants