Skip to content

[ExecuTorch] Dramatically improve op_clamp build time #5784

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 5 commits into from

Conversation

swolchok
Copy link
Contributor

@swolchok swolchok commented Oct 1, 2024

Stack from ghstack (oldest at bottom):

Instead of building O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|) kernel code (where |T| means the number of possibilities for type T), we build O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|) kernel code. (Concretely, ET_SWITCH_REALHB_TYPES has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)

Differential Revision: D63681034

Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX|
* |CTYPE_OUT|)` kernel code (where |T| means the number of
possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| +
|CTYPE_MAX|) * |CTYPE_OUT|)` kernel code. (Concretely,
`ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we
went from 9**4 = 6561 template instantiations to 9 * 3 * 9 = 243
kernels, or a 27x reduction.)

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Oct 1, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit fdc1fc1 with merge base 92d1d1e (image):

BROKEN TRUNK - The following job failed but were 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.

@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 Oct 1, 2024
swolchok added a commit that referenced this pull request Oct 1, 2024
Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX|
* |CTYPE_OUT|)` kernel code (where |T| means the number of
possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| +
|CTYPE_MAX|) * |CTYPE_OUT|)` kernel code. (Concretely,
`ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we
went from 9**4 = 6561 template instantiations to 9 * 3 * 9 = 243
kernels, or a 27x reduction.)

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

ghstack-source-id: 245613707
Pull Request resolved: #5784
@facebook-github-bot
Copy link
Contributor

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

…ld time (2/2)"


Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX|* |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 3 * 9 = 243 instantiations, or a 27x reduction.)

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 1, 2024
Pull Request resolved: #5784

Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 3 * 9 = 243
instantiations, or a 27x reduction.)

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)
ghstack-source-id: 245741505
@facebook-github-bot
Copy link
Contributor

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

@swolchok
Copy link
Contributor Author

swolchok commented Oct 1, 2024

updated description to match rebase atop #5798 despite not having exported yet; will export when #5798 lands

@swolchok swolchok changed the title [ExecuTorch] Dramatically improve op_clamp build time (2/2) [ExecuTorch] Dramatically improve op_clamp build time Oct 2, 2024
Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)


Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

swolchok added a commit that referenced this pull request Oct 2, 2024
Pull Request resolved: #5784

Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)
ghstack-source-id: 245912988

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)
Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)


Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

swolchok added a commit that referenced this pull request Oct 2, 2024
Pull Request resolved: #5784

Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)
ghstack-source-id: 246018181

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)
Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)


Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in aa8a93c.

kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Pull Request resolved: pytorch/executorch#5784

Instead of building `O(|CTYPE_IN| * |CTYPE_MIN| * |CTYPE_MAX| * |CTYPE_OUT|)` kernel code (where |T| means the number of possibilities for type T), we build `O((|CTYPE_IN| + |CTYPE_MIN| + |CTYPE_MAX| + |CTYPE_COMMON|) * |CTYPE_OUT|)` kernel code. (Concretely, `ET_SWITCH_REALHB_TYPES` has 9 possibilities, so I estimate that we went from 9**4 = 6561 template instantiations to 9 * 4 * 9 = 324
instantiations, or a 20x reduction.)
ghstack-source-id: 246132260

Differential Revision: [D63681034](https://our.internmc.facebook.com/intern/diff/D63681034/)
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 Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants