8000 [WIP] Move XNNPACKQuantizer from PyTorch to ExecuTorch by digantdesai · Pull Request #144940 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[WIP] Move XNNPACKQuantizer from PyTorch to ExecuTorch #144940

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

Closed
wants to merge 1 commit into from

Conversation

digantdesai
Copy link
Contributor
@digantdesai digantdesai commented Jan 16, 2025

Summary:
This replicates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.
Other impact and considerations:
PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.
Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Differential Revision: D68191752

cc @albanD @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames

Copy link
pytorch-bot bot commented Jan 16, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5a7bfc9 with merge base b2c89bc (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
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @kimishpatel feels like reference representation is not really used, should we delete?

Copy link
Contributor

Choose a reason for hiding this comment

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

WHy is this test being deleted entirely though? I am guessing because xnnpack quantizer is moving hence? I would have to think a bit on removing reference representation, and we should discuss. Potentially we remove those in favor providing an API that will use customer defined representation

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this test is moved to executorch I think. sounds good, custom defined representation makes sense as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking of adding a dummy_quantizer in the test dir to run these tests especially qat ones.

@@ -31,7 +31,7 @@ def generate_numeric_debug_handle(ep: ExportedProgram) -> None:
generate_numeric_debug_handle(ep)

m = ep.module()
quantizer = XNNPACKQuantizer()
quantizer = XNNPACKQuantizer() # In the ExecuTorch repo.
Copy link
Contributor

Choose a reason for hiding this comment

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

please add an import for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean? This is an example, do you mean to put import line in addition to the comment in the doc string?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah.. just to make it clearer since it's in executorch now

@@ -64,6 +58,73 @@
"get_x86_inductor_linear_dynamic_fp16_config",
]

# In the absence of better name, just winging it with QuantizationConfig
@dataclass(eq=True, frozen=True)
class QuantizationConfig:
Copy link
Contributor
@jerryzh168 jerryzh168 Jan 16, 2025

Choose a reason for hiding this comment

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

we can probably put these in quantizer/utils.py since multiple quantizers are using it, but should be clear that there is no requirement of quantizers using them

I remember we discussed a bit before @kimishpatel and you were pushing for having these as utils, I feel it's fine to have them in utils as long as we are clear that it's more of a convenience function and not required to use now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can move them, but IIRC no one else is using it so kept it here.

Copy link
Collaborator
@albanD albanD left a comment

Choose a reason for hiding this comment

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

Simplification!!
skipping pr sanity check is obviously ok for this one!

@@ -359,7 +359,6 @@
"prepare_qat_pt2e",
# torch.ao.quantization.quantizer.embedding_quantizer
"get_embedding_operators_config",
# torch.ao.quantization.quantizer.xnnpack_quantizer_utils
Copy link
Collaborator

Choose a reason for hiding this comment

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

Everything below this comment until the next comed from this namespace. So you can delete all these lines as well


__all__ = [
"get_embedding_operators_config",
"EmbeddingQuantizer",
]

# In the absence of better name, just winging it with QuantizationConfig
@dataclass(eq=True, frozen=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need to be added to the __all__ block above and be properly documented on the doc website if you want to move them here as public API.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

digantdesai added a commit to digantdesai/pytorch that referenced this pull request Jan 17, 2025
Summary:
Pull Request resolved: pytorch#144940

X-link: pytorch/ao#1572

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, after talking with jerryzh168 - this diff moves most of the tests to ExecuTorch/backends/xnnpack/test/quantizer.
- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Differential Revision: D68191752
@pytorch-bot pytorch-bot < 6D47 span class="Label Label--secondary">bot temporarily deployed to upload-benchmark-results January 17, 2025 03:55 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 03:55 Inactive
Copy link
Contributor
@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

please update the PR summary as well about the migration plan

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 17, 2025
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 04:38 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 04:38 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 04:38 Inactive
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 22:16 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 17, 2025 22:16 Inactive
@pytorch-bot pytorch-bot bot had a problem deploying to upload-benchmark-results January 17, 2025 22:16 Error
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 23, 2025 22:20 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 23, 2025 22:20 Inactive
@pytorch-bot pytorch-bot bot had a problem deploying to upload-benchmark-results January 23, 2025 22:22 Error
@pytorch-bot pytorch-bot bot had a problem deploying to upload-benchmark-results January 23, 2025 22:22 Error
@pytorch-bot pytorch-bot bot had a problem deploying to upload-benchmark-results January 23, 2025 22:22 Error
digantdesai added a commit to digantdesai/executorch-1 that referenced this pull request Jan 23, 2025
Summary:
Pull Request resolved: pytorch#7804

X-link: pytorch/pytorch#144940

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.

- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Reviewed By: mcr229

Differential Revision: D68191752
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

digantdesai added a commit to digantdesai/executorch-1 that referenced this pull request Jan 23, 2025
Summary:
Pull Request resolved: pytorch#7804

X-link: pytorch/pytorch#144940

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.

- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Reviewed By: mcr229

Differential Revision: D68191752
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

digantdesai added a commit to digantdesai/pytorch that referenced this pull request Jan 23, 2025
Summary:
X-link: pytorch/executorch#7804

Pull Request resolved: pytorch#144940

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.

- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Test Plan: CI

Reviewed By: mcr229

Differential Revision: D68191752
Summary:
X-link: pytorch/executorch#7804

Pull Request resolved: pytorch#144940

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.

- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Test Plan: CI

Reviewed By: mcr229

Differential Revision: D68191752
digantdesai added a commit to digantdesai/executorch-1 that referenced this pull request Jan 24, 2025
Summary:
Pull Request resolved: pytorch#7804

X-link: pytorch/pytorch#144940

This migrates XNNPACKQuantizer from PyTorch to ExecuTorch.

Rationale:
Main motivation is to avoid pytorch pin update in OSS after updating XNNPACKQuantizer, which can be rather frequent.

Other impact and considerations:
- PT2e flow (which lives in PyTorch) relies havily on XNNPACKQuantizer for a "example" implementation for quantizer and more importantly tests. Fow now, we will keep the torch.ao.quantization.xnnpack_quantizer as is but mark is as not BC, and deprecated to discourace future new dependencies on it.

- Other OSS repository using XNNPACKQuantizer from PyTorch now have to take an additional dependency on ExecuTorch.

Reviewed By: mcr229

Differential Revision: D68191752
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68191752

@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 02:00 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 02:00 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 02:01 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 02:01 Inactive
@pytorch-bot pytorch-bot bot temporarily deployed to upload-benchmark-results January 24, 2025 02:01 Inactive
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0