Skip to content

[wip] Enforce flatbuffer verification#18824

Open
lucylq wants to merge 1 commit intomainfrom
lfq.enforce-flatbuffer-verification
Open

[wip] Enforce flatbuffer verification#18824
lucylq wants to merge 1 commit intomainfrom
lfq.enforce-flatbuffer-verification

Conversation

@lucylq
Copy link
Copy Markdown
Contributor

@lucylq lucylq commented Apr 10, 2026

[edit] on ci this adds closer to 10-12kB, and puts us way above 50kb :(
linux: echo 'Fail 56448 > 45000'
gcc: echo 'Fail 60296 > 48500'

Seems like this only adds 8kb, so let's try to enable it. It's logging that adds 20-30kb.

  1. Default to Verification::InternalConsistency even in release builds.
  2. If Verification::InternalConsistency is requested but not available, error out.
  3. Embedded and other systems that do not want it can opt-out by disabling the flag.

Test Plan
Check CI size test

@lucylq lucylq requested a review from larryliu0820 as a code owner April 10, 2026 21:28
Copilot AI review requested due to automatic review settings April 10, 2026 21:28
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 10, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 5 New Failures, 3 Unrelated Failures

As of commit 1015912 with merge base 5e8a0df (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs 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.

@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 Apr 10, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copy link
Copy Markdown
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

Enables ExecuTorch flatbuffer/program verification by default (including release builds) and makes Verification::InternalConsistency a strict requirement when requested, rather than silently falling back to minimal checks.

Changes:

  • Default CMake preset EXECUTORCH_ENABLE_PROGRAM_VERIFICATION to ON (release builds now include verification unless explicitly disabled).
  • Change Program::load() (and related Module/Python entrypoints) default verification level to Verification::InternalConsistency.
  • When verification code is compiled out, requesting InternalConsistency now returns Error::NotSupported instead of logging and falling back.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/cmake/preset/default.cmake Defaults program verification build option to ON.
CMakeLists.txt Updates documentation/comments around the verification build flag behavior and size impact.
runtime/executor/targets.bzl Updates Buck/Bazel-side comments describing verification size and behavior when disabled.
runtime/executor/program.h Switches default verification argument to InternalConsistency.
runtime/executor/program.cpp Enforces NotSupported when InternalConsistency is requested but compiled out; keeps minimal checks only for Minimal.
extension/pybindings/pybindings.cpp Updates Python bindings’ default verification argument to InternalConsistency.
extension/module/module.h Updates Module API default verification argument to InternalConsistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Error,
"InternalConsistency verification requested but not available. "
"Build with ET_ENABLE_PROGRAM_VERIFICATION=1 or "
"use Verification::Minimal to skip verification.");
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error text says "use Verification::Minimal to skip verification", but Minimal still performs basic checks (e.g., root table offset bounds check below). Consider rewording to avoid implying verification is entirely skipped (e.g., "use Verification::Minimal for basic verification" / "reduced verification").

Suggested change
"use Verification::Minimal to skip verification.");
"use Verification::Minimal for basic verification.");

Copilot uses AI. Check for mistakes.
Comment on lines 87 to 90
ET_NODISCARD static Result<Program> load(
DataLoader* loader,
Verification verification = Verification::Minimal);
Verification verification = Verification::InternalConsistency);

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the default argument now set to Verification::InternalConsistency, building with ET_ENABLE_PROGRAM_VERIFICATION=0 (or equivalent build option) will make Program::load(loader) fail with Error::NotSupported unless callers explicitly pass Verification::Minimal. If the goal is that space-constrained builds can "opt out" purely via the build flag, consider making the default conditional on ET_ENABLE_PROGRAM_VERIFICATION (or introducing a "Default" mode) or documenting this behavior prominently.

Copilot uses AI. Check for mistakes.
@lucylq lucylq changed the title Enforce flatbuffer verification [wip] Enforce flatbuffer verification Apr 10, 2026
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. security-fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants