Skip to content

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

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
bigfootjon:export-D109082046
Jul 24, 2026
Merged

merge fbcode-only TARGETS rules into existing targets.bzl files (#21145)#21145
meta-codesync[bot] merged 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 eecb716 with merge base fbd14e6 (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",
            ],

bigfootjon added a commit to bigfootjon/executorch that referenced this pull request Jul 23, 2026
…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
bigfootjon added a commit to bigfootjon/executorch that referenced this pull request Jul 24, 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 review requested due to automatic review settings July 24, 2026 14:34
…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

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 3 comments.

Comments suppressed due to low confidence (1)

backends/cortex_m/test/targets.bzl:41

  • The fbcode-only python_unittest target previously set TEST_RUNTIME_IS_NOT_OSS via env, but that env var is now missing. This changes how backends/cortex_m/test/conftest.py seeds randomness in fbcode runs and likely diverges from the prior behavior.
        python_unittest(
            name = "test_replace_quant_nodes",
            srcs = [

Comment on lines +33 to 35
def define_common_targets(is_fbcode = False):
"""Defines targets that should be shared between fbcode and xplat."""
for op in OPERATORS:
Comment on lines +60 to +63
deps = [
":runner_lib",
"//executorch/extension/threadpool:threadpool", # this depeneency shouldn't be needed. But it fails to build..
],
Comment on lines +338 to +342
env = {
"LD_LIBRARY_PATH": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs)".format(get_qnn_library_version()),
# Place holder to pass the QNN_SDK_ROOT check in executorch/examples/qualcomm/utils.py
"QNN_SDK_ROOT": "",
},
Copilot AI review requested due to automatic review settings July 24, 2026 14:39

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 1 comment.

Comments suppressed due to low confidence (2)

examples/qualcomm/oss_scripts/llama/targets.bzl:62

  • Spelling typo in comment: "depeneency" → "dependency".
                "//executorch/extension/threadpool:threadpool", # this depeneency shouldn't be needed. But it fails to build..

backends/cortex_m/test/targets.bzl:51

  • The original fbcode-only python_unittest set TEST_RUNTIME_IS_NOT_OSS based on runtime.is_oss to avoid importing torch during pytest configuration in non-OSS builds (see conftest.py usage). That env var is dropped in the new python_unittest, which can change test behavior / break collection in packaged fbcode builds.
        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 on lines +10 to +12
def define_common_targets(is_fbcode = False):
if not is_fbcode:
runtime.cxx_library(
@meta-codesync
meta-codesync Bot merged commit ff0f92e into pytorch:main Jul 24, 2026
197 of 199 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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants