Skip to content

merge fbcode-only TARGETS rules into existing targets.bzl files (#21145)#21145

Open
bigfootjon wants to merge 1 commit into
pytorch:mainfrom
bigfootjon:export-D109082046
Open

merge fbcode-only TARGETS rules into existing targets.bzl files (#21145)#21145
bigfootjon wants to merge 1 commit into
pytorch:mainfrom
bigfootjon:export-D109082046

Conversation

@bigfootjon

@bigfootjon bigfootjon commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary:

Chunk 7B of fbcode/executorch TARGETS->BUCK migration. 5 directories where
both a TARGETS file (with extra fbcode-only rules) and a targets.bzl
existed. For each:

  1. Added the new fbcode-only loads from TARGETS to the top of targets.bzl
    (deduped against already-present loads).
  2. Updated def define_common_targets(...) to accept is_fbcode = False.
  3. Appended the fbcode-only TARGETS body at the end of the function inside
    an if is_fbcode: block so xplat continues to skip those rules.
  4. Replaced TARGETS with a thin BUCK calling
    define_common_targets(is_fbcode = is_fbcode()).

Directories migrated:

  • backends/cortex_m/test
  • examples/models/llama/fb
  • examples/qualcomm/oss_scripts/llama
  • examples/qualcomm/oss_scripts/whisper
  • kernels/fb/custom_ops

Reviewed By: mzlee

Differential Revision: D109082046

Copilot AI review requested due to automatic review settings July 22, 2026 17:40
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 6181ea1 with merge base 007fc2b (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 Jul 22, 2026
@meta-codesync

meta-codesync Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates fbcode-only Buck TARGETS rules into the corresponding targets.bzl files (with an is_fbcode gate) and replaces TARGETS with thin BUCK wrappers that call define_common_targets(is_fbcode = is_fbcode()), supporting the ongoing TARGETS→BUCK migration while keeping xplat behavior unchanged.

Changes:

  • Introduces/updates define_common_targets(is_fbcode = False) and gates fbcode-only rules behind if is_fbcode.
  • Replaces legacy TARGETS files with BUCK wrappers that call into targets.bzl.
  • Adds required fbcode-only loads to targets.bzl where needed.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/end2end/targets.bzl New fbcode-gated target definitions migrated from TARGETS.
test/end2end/TARGETS Removed; content migrated into targets.bzl.
test/end2end/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).
exir/tests/targets.bzl New fbcode-gated test/library targets migrated from TARGETS.
exir/tests/TARGETS Removed; content migrated into targets.bzl.
exir/tests/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).
exir/dialects/edge/test/targets.bzl New fbcode-gated test targets migrated from TARGETS.
exir/dialects/edge/test/TARGETS Removed; content migrated into targets.bzl.
exir/dialects/edge/test/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).
examples/qualcomm/oss_scripts/whisper/targets.bzl Adds is_fbcode gating for fbcode-only Python targets; keeps OSS targets unconditional.
examples/qualcomm/oss_scripts/whisper/TARGETS Removed; content migrated into targets.bzl.
examples/qualcomm/oss_scripts/whisper/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).
examples/qualcomm/oss_scripts/llama/targets.bzl Adds is_fbcode gating for fbcode-only Python targets/aliases; keeps OSS targets unconditional.
examples/qualcomm/oss_scripts/llama/TARGETS Removed; content migrated into targets.bzl.
examples/qualcomm/oss_scripts/llama/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).
backends/cortex_m/test/targets.bzl Adds is_fbcode gating and inlines the fbcode-only unittest previously in TARGETS.
backends/cortex_m/test/TARGETS Removed; content migrated into targets.bzl.
backends/cortex_m/test/BUCK Now calls define_common_targets(is_fbcode = is_fbcode()).

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

Comment on lines +39 to +51
python_unittest(
name = "test_replace_quant_nodes",
srcs = [
"test_helpers_passes_utils.py",
"test_replace_quant_nodes.py",
],
deps = [
"//pytorch/ao:torchao", # @manual
"//caffe2:torch",
"//executorch/backends/cortex_m/passes:replace_quant_nodes_pass",
"//executorch/backends/cortex_m/ops:ops",
],
)
Comment thread test/end2end/BUCK
Comment on lines +1 to +5
# Any targets that should be shared between fbcode and xplat must be defined in
# targets.bzl.

load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode")
load(":targets.bzl", "define_common_targets")
Comment thread test/end2end/targets.bzl
Comment on lines +4 to +12
def define_common_targets(is_fbcode = False):
if not is_fbcode:
return

# @noautodeps



runtime.python_library(
@meta-codesync meta-codesync Bot changed the title merge fbcode-only TARGETS rules into existing targets.bzl files merge fbcode-only TARGETS rules into existing targets.bzl files (#21145) Jul 23, 2026
Copilot AI review requested due to automatic review settings July 23, 2026 16:52
bigfootjon added a commit to bigfootjon/executorch that referenced this pull request Jul 23, 2026
…rch#21145)

Summary:

Chunk 7B of fbcode/executorch TARGETS->BUCK migration. 5 directories where
both a TARGETS file (with extra fbcode-only rules) and a targets.bzl
existed. For each:

  1. Added the new fbcode-only loads from TARGETS to the top of targets.bzl
     (deduped against already-present loads).
  2. Updated `def define_common_targets(...)` to accept `is_fbcode = False`.
  3. Appended the fbcode-only TARGETS body at the end of the function inside
     an `if is_fbcode:` block so xplat continues to skip those rules.
  4. Replaced TARGETS with a thin BUCK calling
     `define_common_targets(is_fbcode = is_fbcode())`.

Directories migrated:
  - backends/cortex_m/test
  - examples/models/llama/fb
  - examples/qualcomm/oss_scripts/llama
  - examples/qualcomm/oss_scripts/whisper
  - kernels/fb/custom_ops

Reviewed By: mzlee

Differential Revision: D109082046

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

backends/cortex_m/test/targets.bzl:44

  • python_unittest here no longer sets TEST_RUNTIME_IS_NOT_OSS. backends/cortex_m/test/conftest.py checks this env var in pytest_configure() to decide whether to import torch early; without it, fbcode packaged test runs may import torch during collection/config and fail (this is why the old TARGETS rule set it). Consider restoring the env setting on this test target.
    if is_fbcode:
        python_unittest(
            name = "test_replace_quant_nodes",
            srcs = [
                "test_helpers_passes_utils.py",
                "test_replace_quant_nodes.py",
            ],

…rch#21145)

Summary:
Pull Request resolved: pytorch#21145

Chunk 7B of fbcode/executorch TARGETS->BUCK migration. 5 directories where
both a TARGETS file (with extra fbcode-only rules) and a targets.bzl
existed. For each:

  1. Added the new fbcode-only loads from TARGETS to the top of targets.bzl
     (deduped against already-present loads).
  2. Updated `def define_common_targets(...)` to accept `is_fbcode = False`.
  3. Appended the fbcode-only TARGETS body at the end of the function inside
     an `if is_fbcode:` block so xplat continues to skip those rules.
  4. Replaced TARGETS with a thin BUCK calling
     `define_common_targets(is_fbcode = is_fbcode())`.

Directories migrated:
  - backends/cortex_m/test
  - examples/models/llama/fb
  - examples/qualcomm/oss_scripts/llama
  - examples/qualcomm/oss_scripts/whisper
  - kernels/fb/custom_ops

Reviewed By: mzlee

Differential Revision: D109082046
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants