Restrict XOR python export targets to fbcode#19316
Conversation
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
🔗 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 PendingAs of commit 96de8cc with merge base 0f9de6a ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103951555. |
This PR needs a
|
There was a problem hiding this comment.
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_xplatfromruntime_wrapper.bzl. - Gate the
model,export_model_lib, andexport_modelPython targets behindif not is_xplat(). - Leave the
train_xorC++ 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.
Summary:
xplat/executorch/extension/training/examples/XOR/BUCKinvokesdefine_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:torchand//executorch/exir:lib, neither of which isdefined as an xplat target —
xplat/executorch/exir/BUCKonlydeclares the
:libtarget viafbcode_target(...). As a result thexplat configuration of
fbsource//xplat/executorch/extension/training/examples/XOR:export_modelfails analysis with:
Unknown target
libfrom packagefbsource//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_modeltarget with no successful run on record (linked to T168807700).
Wrap the three python rules with
if not is_xplat():so they onlyregister when called from fbcode, matching the established precedent
in
xplat/executorch/kernels/portable/test/targets.bzl. Thetrain_xorC++ binary continues to be defined for both cells sinceits dependencies are xplat-compatible.
Differential Revision: D103951555