Skip to content

Conversation

@chizkiyahu
Copy link
Contributor

@chizkiyahu chizkiyahu commented Jan 19, 2026

Title

Introduce flatbuffer serializer as default for program serialization

Summary

Add a FlatBuffers-based serializer at exir/_serialize/_flatbuffer_program.py and 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:

  • ~36.3× average speedup (serialize latency).
  • ~61.6% average reduction in memory usage during serialization.

Tests

Unit tests added at:

  • exir/_serialize/test/test_flatbuffer_program.py

cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai

Copilot AI review requested due to automatic review settings January 19, 2026 12:09
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 19, 2026

🔗 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 Failures

As of commit e89436b with merge base 3b16295 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla 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 Jan 19, 2026
Copy link
Contributor

Copilot AI left a 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.py with direct Python-to-binary conversion
  • Updated default serialization path in _program.py to 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.

@chizkiyahu
Copy link
Contributor Author

@pytorchbot label ciflow/trunk

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 19, 2026

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
@chizkiyahu chizkiyahu force-pushed the exir-flatbuffer-serialize-fastpath branch from 92918a7 to e89436b Compare January 19, 2026 12:11
@chizkiyahu
Copy link
Contributor Author

@pytorchbot label "partner: arm"

@pytorch-bot pytorch-bot bot added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Jan 19, 2026
@chizkiyahu
Copy link
Contributor Author

@pytorchbot label ciflow/trunk

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 19, 2026

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.

@chizkiyahu
Copy link
Contributor Author

@pytorchbot label "release notes: exir"

@pytorch-bot pytorch-bot bot added the release notes: exir Changes to any dialects and passes on these dialects, such as memory planning label Jan 19, 2026
@zingo
Copy link
Collaborator

zingo commented Jan 19, 2026

Hi @SS-JIA / @swolchok here is one nore thet is outside or Arm folders that we don't want to review ourself :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: exir Changes to any dialects and passes on these dialects, such as memory planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants