Arm backend: Deduplicate constants emitted during TOSA lowering - #22638
Open
YufengShi-dudu wants to merge 2 commits into
Open
Arm backend: Deduplicate constants emitted during TOSA lowering#22638YufengShi-dudu wants to merge 2 commits into
YufengShi-dudu wants to merge 2 commits into
Conversation
Pool backend-generated helper constants per TOSA basic block using dtype, shape, and exact serialized bytes as the key. Implement the pool in a TosaSerializer subclass. Helper operands use the tensor returned by addConst, making reuse safe. Keep graph-owned constants unpooled because later lowering refers to their FX names. This covers model parameters, buffers, lifted constants, and CONST_SHAPE outputs, while preserving packed FP4 serialization. Deduplicate identical static CONST_SHAPE nodes in FX, where their uses can safely be rewritten to the first occurrence. Representative TOSA-FP operator comparisons: | Model | Before | After | Reduction | Bytes saved | |-------------|-------:|------:|------------:|------------:| | SD3 | 1,518 | 1,038 | 480 (31.6%) | 89,068 | | InceptionV3 | 673 | 456 | 217 (32.2%) | 42,092 | | Conformer | 488 | 365 | 123 (25.2%) | 22,852 | This change was authored with assistance from Codex. Change-Id: I4de44b034aff33cbf2888801238cc48df5a9124d Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22638
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (1 Unrelated Failure), 1 Unclassified FailureAs of commit d0c222d with merge base 56a461f ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
zingo
approved these changes
Sep 9, 2026
Collaborator
Author
|
The |
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.
Pool backend-generated helper constants per TOSA basic block using dtype, shape, and exact serialized bytes as the key. Implement the pool in a TosaSerializer subclass. Helper operands use the tensor returned by addConst, making reuse safe.
Keep graph-owned constants unpooled because later lowering refers to their FX names. This covers model parameters, buffers, lifted constants, and CONST_SHAPE outputs, while preserving packed FP4 serialization.
Deduplicate identical static CONST_SHAPE nodes in FX, where their uses can safely be rewritten to the first occurrence.
Representative TOSA-FP operator comparisons:
This change was authored with assistance from Codex.
Change-Id: I4de44b034aff33cbf2888801238cc48df5a9124d
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani