-
Notifications
You must be signed in to change notification settings - Fork 801
exir: add flatbuffer Program serialization for performance #16691
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
base: main
Are you sure you want to change the base?
exir: add flatbuffer Program serialization for performance #16691
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16691
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit e89436b with merge base 3b16295 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a FlatBuffers-based serializer to achieve significant performance improvements in program serialization (36.3× speedup, 61.6% memory reduction). The new serializer converts Python Program objects directly to binary format, bypassing the previous JSON intermediate step while maintaining robustness through a fallback mechanism.
Changes:
- New FlatBuffers serializer module at
exir/_serialize/_flatbuffer_program.pywith direct Python-to-binary conversion - Updated default serialization path in
_program.pyto use the new FlatBuffer serializer with JSON fallback for robustness - Comprehensive unit tests covering roundtrip serialization, path equivalence validation, and error handling
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| exir/_serialize/_flatbuffer_program.py | Implements direct Python-to-FlatBuffer serialization logic, avoiding JSON intermediate representation |
| exir/_serialize/_program.py | Integrates the new FlatBuffer serializer as the default path with JSON fallback for error cases |
| exir/_serialize/test/test_flatbuffer_program.py | Tests for the new serializer including roundtrip validation and alignment verification |
| exir/_serialize/test/TARGETS | Adds test target for the new FlatBuffer program tests |
| exir/_serialize/TARGETS | Registers the new _flatbuffer_program.py module in the build system |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@pytorchbot label ciflow/trunk |
|
To add these label(s) (ciflow/trunk) to the PR, please first approve the workflows that are awaiting approval (scroll to the bottom of this page). This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
Introduce the flatbuffer serializer in
exir/_serialize/_flatbuffer_program.py
and use it by default, delivering ~36.3x average speedup and ~61.6%
average memory reduction across ~600 models,
with JSON fallback and error logging for robustness.
Signed-off-by: Chizkiyahu Raful <chizkiyahu.raful@arm.com>
Change-Id: If3eda942162f99fb53bba739d4e97a14c60974fa
92918a7 to
e89436b
Compare
|
@pytorchbot label "partner: arm" |
|
@pytorchbot label ciflow/trunk |
|
To add these label(s) (ciflow/trunk) to the PR, please first approve the workflows that are awaiting approval (scroll to the bottom of this page). This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot label "release notes: exir" |
Title
Introduce flatbuffer serializer as default for program serialization
Summary
Add a FlatBuffers-based serializer at
exir/_serialize/_flatbuffer_program.pyand make it the default serializer for program artifacts. The new serializer achieves large efficiency gains across our model suite while retaining robustness via a JSON fallback and detailed error logging.Before
python -> json -> binary
After
python -> binary
Performance
Measured across ~600 models:
Tests
Unit tests added at:
exir/_serialize/test/test_flatbuffer_program.pycc @freddan80 @per @zingo @oscarandersson8218 @digantdesai