Skip to content

Generic numeric debugging (#19317)#19317

Open
metascroy wants to merge 1 commit into
pytorch:mainfrom
metascroy:export-D103956056
Open

Generic numeric debugging (#19317)#19317
metascroy wants to merge 1 commit into
pytorch:mainfrom
metascroy:export-D103956056

Conversation

@metascroy
Copy link
Copy Markdown
Contributor

@metascroy metascroy commented May 6, 2026

Summary: Pull Request resolved: #19317

Differential Revision: D103956056

Pulled By: metascroy

@metascroy metascroy requested a review from Gasoonjia as a code owner May 6, 2026 00:31
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 6, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures, 2 Unrelated Failures

As of commit cc5b5a0 with merge base bd5752a (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 May 6, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 6, 2026

@metascroy has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103956056.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 6, 2026

@metascroy has imported this pull request. If you are a Meta employee, you can view this in D103956056.

specs: list[TapSpec] = []
new_tap_nodes: list[fx.Node] = []

for node in candidate_nodes:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what happens if the delegate have to fuse some candidate nodes? Try lowering conv2d-->batch_norm, where XNNPACK doesn't support standalone batch_norm IIRC.
Also how is it better than forced-single-op-partitions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is primarily to help RL in a numeric debugging investigation. I may clean it up to make it a generic utility if they find it useful, but will likely go through design review to get input from others if I do that.

To answer your question on fused candidates: this is tested with CoreML's quantized linear pattern [dequantize -> linear]. In that case, we tap the intermediate output after linear node, which is actually a quantized linear in both eager (from QDQ pattern) and CoreML (from its internal fusion). In the [conv2d-->batch_norm] case, I'd have to check. Tapping batch norm should mean we want the output of batch_norm, i.e., the intermediate output after batchnorm, which can be the result of a fused [conv2d-->batch_norm] op. If we did forced single-op partitions on con2d and batch_norm separately, we wouldn't get the fusion.

how is it better than forced-single-op-partitions

One reason is single-op partitions destroy fusion that backends do. Here we tap intermediates, so as long as we tap the final intermediate after a fusion pattern we should be good.

A second reason is this approach does keep the same big delegate blob, just with extra outputs. In CoreML's case that means it will still be routed to ANE, whereas if you break up into single op partitions, it will very likely reroute to CPU b/c they are small.

@meta-codesync meta-codesync Bot changed the title Generic numeric debugging Generic numeric debugging (#19317) May 12, 2026
metascroy added a commit to metascroy/executorch that referenced this pull request May 12, 2026
Summary: Pull Request resolved: pytorch#19317

Differential Revision: D103956056

Pulled By: metascroy
@metascroy metascroy force-pushed the export-D103956056 branch from 7ad210a to f8d3715 Compare May 12, 2026 19:56
metascroy added a commit to metascroy/executorch that referenced this pull request May 12, 2026
Summary: Pull Request resolved: pytorch#19317

Differential Revision: D103956056

Pulled By: metascroy
@metascroy metascroy force-pushed the export-D103956056 branch from f8d3715 to c4fc2e5 Compare May 12, 2026 19:56
metascroy added a commit to metascroy/executorch that referenced this pull request May 12, 2026
Summary: Pull Request resolved: pytorch#19317

Differential Revision: D103956056

Pulled By: metascroy
@metascroy metascroy force-pushed the export-D103956056 branch from c4fc2e5 to 74941da Compare May 12, 2026 20:46
Summary: Pull Request resolved: pytorch#19317

Differential Revision: D103956056

Pulled By: metascroy
@metascroy metascroy force-pushed the export-D103956056 branch from 74941da to cc5b5a0 Compare May 12, 2026 20:50
Copy link
Copy Markdown
Contributor

@YIWENX14 YIWENX14 left a comment

Choose a reason for hiding this comment

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

LGTM.

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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants