Update constant folding behavior for large tensors#2488
Merged
justinchuby merged 23 commits intomainfrom Sep 4, 2025
Merged
Conversation
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2488 +/- ##
==========================================
- Coverage 70.00% 69.94% -0.06%
==========================================
Files 215 216 +1
Lines 25988 26064 +76
Branches 2606 2614 +8
==========================================
+ Hits 18192 18231 +39
- Misses 6896 6932 +36
- Partials 900 901 +1 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
gramalingam
reviewed
Aug 15, 2025
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
justinchuby
commented
Aug 15, 2025
gramalingam
reviewed
Aug 18, 2025
Collaborator
Author
|
I will remove the allow bloat option for now. Will create a function arg for user specified rules |
justinchuby
commented
Aug 28, 2025
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Collaborator
Author
|
@iksnagreb @gramalingam I removed the previous always_fold option and added a should_fold arg that takes a function. This is a breaking change. Please let me know if it looks ok. |
gramalingam
reviewed
Sep 3, 2025
gramalingam
reviewed
Sep 3, 2025
gramalingam
approved these changes
Sep 3, 2025
Collaborator
Author
|
@gramalingam could you reapprove? Thanks |
xadupre
approved these changes
Sep 4, 2025
titaiwangms
reviewed
Oct 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested by #2466, I updated the constant folder logic to allow
Constant folding customization:
always_fold_opsparameter with ashould_foldcallable that determines on a per-node basis whether folding should occur. This allows users to specify more complex folding policies and makes the API more explicit. (FoldConstantsPass,fold_constants) [1] [2] [3] [4] [5]Logging and diagnostics improvements:
should_foldreturns a decision. [1] [2] [3]Code cleanup and minor fixes:
_update_typefunction.Fix #2466
cc @iksnagreb