Skip to content

Add some basic xnnpack recipes #10035

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 11 commits into
base: main
Choose a base branch
from
Open

Add some basic xnnpack recipes #10035

wants to merge 11 commits into from

Conversation

tarun292
Copy link
Contributor

@tarun292 tarun292 commented Apr 10, 2025

Copy link

pytorch-bot bot commented Apr 10, 2025

🔗 Helpful Links

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

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

❌ 75 New Failures

As of commit ec902d5 with merge base 879235b (image):

NEW FAILURES - The following jobs have failed:

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 Apr 10, 2025
@facebook-github-bot
Copy link
Contributor

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

Copy link

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

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

is_per_channel=True, is_dynamic=True
)
quantizer.set_global(operator_config)
DuplicateDynamicQuantChainPass
Copy link
Contributor

Choose a reason for hiding this comment

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

i've actually done some work to remove the need for this. I guess it's ok to have for now as it should still work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove it if not needed?


)

def get_dynamic_quant_recipe() -> ExportRecipe:
Copy link
Contributor

Choose a reason for hiding this comment

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

organizationally maybe quant recipes can be in a separate folder?

Copy link
Contributor

@digantdesai digantdesai left a comment

Choose a reason for hiding this comment

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

Looks good. Stamping, left some comments.

)
from executorch.exir import ExportRecipe

def get_generic_fp32_cpu_recipe() -> ExportRecipe:
Copy link
Contributor

Choose a reason for hiding this comment

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

if namespaced to XNNPACK then cpu may not be needed?

Suggested change
def get_generic_fp32_cpu_recipe() -> ExportRecipe:
def get_fp32_recipe() -> ExportRecipe:

Comment on lines +45 to +46
"FP32_CPU_ACCELERATED_RECIPE": get_generic_fp32_cpu_recipe,
"DYNAMIC_QUANT_CPU_ACCELERATED_RECIPE": get_dynamic_quant_recipe,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
"FP32_CPU_ACCELERATED_RECIPE": get_generic_fp32_cpu_recipe,
"DYNAMIC_QUANT_CPU_ACCELERATED_RECIPE": get_dynamic_quant_recipe,
"FP32_RECIPE": get_fp32_recipe,
"DYNAMIC_QUANT_RECIPE": get_dynamic_quant_recipe,

name = "fp32_recipe",
quantizer = None,
partitioners=[XnnpackPartitioner()],

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Comment on lines 20 to 22
quantizer = XNNPACKQuantizer()
operator_config = get_symmetric_quantization_config(is_per_channel=False)
quantizer.set_global(operator_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
quantizer = XNNPACKQuantizer()
operator_config = get_symmetric_quantization_config(is_per_channel=False)
quantizer.set_global(operator_config)

is_per_channel=True, is_dynamic=True
)
quantizer.set_global(operator_config)
DuplicateDynamicQuantChainPass
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove it if not needed?

operator_config = get_symmetric_quantization_config(is_per_channel=False)
quantizer.set_global(operator_config)
return ExportRecipe(
name = "fp32_recipe",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
name = "fp32_recipe",
name = "fp32",

Comment on lines +13 to +17
def setUp(self) -> None:
super().setUp()

def tearDown(self) -> None:
super().tearDown()
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need these?

example_inputs=example_inputs,
export_recipe=get_xnnpack_recipe("FP32_CPU_ACCELERATED_RECIPE")
)
export_session.export()
Copy link
Contributor

Choose a reason for hiding this comment

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

will this raise? should we catch it?

tarun292 added a commit that referenced this pull request May 6, 2025
Pull Request resolved: #10035


ghstack-source-id: 282298047
@exported-using-ghexport

Differential Revision: [D72085170](https://our.internmc.facebook.com/intern/diff/D72085170/)
@facebook-github-bot
Copy link
Contributor

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

tarun292 added a commit that referenced this pull request May 14, 2025
Pull Request resolved: #10035


ghstack-source-id: 283781375
@exported-using-ghexport

Differential Revision: [D72085170](https://our.internmc.facebook.com/intern/diff/D72085170/)
tarun292 added a commit that referenced this pull request May 14, 2025
Pull Request resolved: #10035


ghstack-source-id: 284046762
@exported-using-ghexport

Differential Revision: [D72085170](https://our.internmc.facebook.com/intern/diff/D72085170/)
tarun292 added a commit that referenced this pull request May 14, 2025
Pull Request resolved: #10035


ghstack-source-id: 284082032
@exported-using-ghexport

Differential Revision: [D72085170](https://our.internmc.facebook.com/intern/diff/D72085170/)
@tarun292 tarun292 changed the base branch from gh/tarun292/5/base to main May 14, 2025 23:59
@facebook-github-bot
Copy link
Contributor

Hi @tarun292!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Differential Revision: [D72085170](https://our.internmc.facebook.com/intern/diff/D72085170/)

ghstack-source-id: 275959832
Pull Request resolved: pytorch/executorch#10035
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants