Skip to content

Restrict XOR python export targets to fbcode#19316

Merged
psiddh merged 1 commit intopytorch:mainfrom
psiddh:export-D103951555
May 6, 2026
Merged

Restrict XOR python export targets to fbcode#19316
psiddh merged 1 commit intopytorch:mainfrom
psiddh:export-D103951555

Conversation

@psiddh
Copy link
Copy Markdown
Contributor

@psiddh psiddh commented May 6, 2026

Summary:
xplat/executorch/extension/training/examples/XOR/BUCK invokes
define_common_targets() for both fbcode (fbcode_target) and xplat
(non_fbcode_target). The python targets in this example
(model, export_model_lib, export_model) depend on
//caffe2:torch and //executorch/exir:lib, neither of which is
defined as an xplat target — xplat/executorch/exir/BUCK only
declares the :lib target via fbcode_target(...). As a result the
xplat configuration of fbsource//xplat/executorch/extension/training/examples/XOR:export_model
fails analysis with:

Unknown target lib from package fbsource//xplat/executorch/exir.
Did you mean one of the 0 targets in fbsource//xplat/executorch/exir:BUCK?

This produced 218/218 BUILD_RULE failures on the
fbsource//xplat/executorch/extension/training/examples/XOR:export_model
target with no successful run on record (linked to T168807700).

Wrap the three python rules with if not is_xplat(): so they only
register when called from fbcode, matching the established precedent
in xplat/executorch/kernels/portable/test/targets.bzl. The
train_xor C++ binary continues to be defined for both cells since
its dependencies are xplat-compatible.

Differential Revision: D103951555

Summary:
`xplat/executorch/extension/training/examples/XOR/BUCK` invokes
`define_common_targets()` for both fbcode (`fbcode_target`) and xplat
(`non_fbcode_target`). The python targets in this example
(`model`, `export_model_lib`, `export_model`) depend on
`//caffe2:torch` and `//executorch/exir:lib`, neither of which is
defined as an xplat target — `xplat/executorch/exir/BUCK` only
declares the `:lib` target via `fbcode_target(...)`. As a result the
xplat configuration of `fbsource//xplat/executorch/extension/training/examples/XOR:export_model`
fails analysis with:

  Unknown target `lib` from package `fbsource//xplat/executorch/exir`.
  Did you mean one of the 0 targets in fbsource//xplat/executorch/exir:BUCK?

This produced 218/218 BUILD_RULE failures on the
`fbsource//xplat/executorch/extension/training/examples/XOR:export_model`
target with no successful run on record (linked to T168807700).

Wrap the three python rules with `if not is_xplat():` so they only
register when called from fbcode, matching the established precedent
in `xplat/executorch/kernels/portable/test/targets.bzl`. The
`train_xor` C++ binary continues to be defined for both cells since
its dependencies are xplat-compatible.

Differential Revision: D103951555
@psiddh psiddh requested a review from JacobSzwejbka as a code owner May 6, 2026 00:10
Copilot AI review requested due to automatic review settings May 6, 2026 00:10
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 6, 2026

🔗 Helpful Links

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

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

⏳ No Failures, 15 Pending

As of commit 96de8cc with merge base 0f9de6a (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 May 6, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 6, 2026

@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103951555.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

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

This PR fixes a Buck analysis failure in the XOR training example by preventing Python export targets from being registered in xplat, where their //caffe2:torch and //executorch/exir:lib dependencies do not exist. It keeps the example’s C++ training binary available in both environments while aligning the Python target registration with existing non-xplat gating patterns in the build system.

Changes:

  • Import is_xplat from runtime_wrapper.bzl.
  • Gate the model, export_model_lib, and export_model Python targets behind if not is_xplat().
  • Leave the train_xor C++ binary defined unconditionally so it remains available for both fbcode and xplat.

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

@psiddh psiddh merged commit 5faf36e into pytorch:main May 6, 2026
176 of 189 checks passed
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants