Skip to content

Remove pyre_extensions dependency from native preprocessing - #22802

Merged
digantdesai merged 1 commit into
pytorch:mainfrom
JakeStevens:fix/native-preprocess-pyre-dependency
Sep 14, 2026
Merged

digantdesai merged 1 commit into
pytorch:mainfrom
JakeStevens:fix/native-preprocess-pyre-dependency

Conversation

@JakeStevens

Copy link
Copy Markdown
Contributor

Summary

Importing NativeBackend fails with ModuleNotFoundError: No module named 'pyre_extensions' in OSS installations, breaking native-backend test collection and execution on Linux and macOS. Replace the single none_throws use with a direct non-None assertion and remove the unused Buck dependency.

Test plan

Reproduced the import failure on unmodified main with pyre_extensions absent. With the fix, the same environment passes all 62 tests and 14 subtests in the affected files:

PYTHONPATH=src python -m pytest -o addopts= -q \
  backends/native/test/test_preprocess.py \
  backends/native/test/test_partitioner.py \
  backends/native/test/test_passes.py \
  exir/native/test/test_native.py

The source checkout used the packaged flatc executable and the schema resources normally installed by setup.py. Flake8, ufmt, and git diff --check pass.

Authored with OpenAI Codex.

Replace `none_throws` with a direct non-None assertion and remove the unused
Buck dependency so OSS installations can import `NativeBackend` without
installing `pyre_extensions`.

Validated with `pyre_extensions` absent: 62 native preprocessing, partitioner,
pass, and PTN export tests passed, plus 14 subtests. Flake8 and ufmt passed.

Authored with OpenAI Codex.
@pytorch-bot

pytorch-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 34 Pending

As of commit 7ecb740 with merge base 89fcfe7 (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 Sep 14, 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.

@JakeStevens
JakeStevens marked this pull request as ready for review September 14, 2026 16:08
@digantdesai
digantdesai merged commit 751481b into pytorch:main Sep 14, 2026
208 of 211 checks passed
@JakeStevens
JakeStevens deleted the fix/native-preprocess-pyre-dependency branch September 14, 2026 16:37
rascani added a commit that referenced this pull request Sep 14, 2026
JakeStevens pushed a commit that referenced this pull request Oct 14, 2026
…, and Samsung conv1d (#22373)

### Summary

Error-guard sites that construct a failure which cannot actually fire.
This PR inserts the missing `raise` (or replaces an always-true `assert`
with the file's existing `check_or_raise`) so the documented failure
mode is the one callers see.

Updated for `main` at 5e21c13: the two `ExportSession` guards were fixed
upstream in the meantime by #21748, so the only code change left in
`export/export.py` is the message typo. The regression tests for those
two guards are kept, since nothing else covers them.

| File | What happens on `main` today | Reachability |
| --- | --- | --- |
| `export/export.py` `ExportSession.print_delegation_info` | Both guards
already `raise` (#21748). Remaining here: the message says "atleast",
and no test pins either guard. | **Reachable.** `ExportSession` is in
`executorch.export.__all__` and is `@experimental`. A pipeline with no
lowering stage, or one that lists `TO_EDGE_TRANSFORM_AND_LOWER` /
`TO_BACKEND` without having run it, reaches each guard. This PR fixes
the wording and adds `export/tests/test_print_delegation_info.py` for
both. |
| `backends/xnnpack/operators/node_visitor.py` per-channel axis `else` |
`assert f"Unsupported weight per channel quantization axis ..."`: the
f-string is always truthy, so the assertion never fires. An `assert`
would also disappear under `python -O`. | **Not reachable on a normal
export.** The only call that passes `swap_in_out_for_weights=True` is
`backends/xnnpack/operators/op_conv2d.py:102`, and that visitor already
`check_or_raise`s the axis to `0` (depthwise) or `1` (transpose) before
`define_tensor`. This change restores a guard that can actually raise if
that `else` is ever entered; it does not fix a mis-serialized `.pte` on
the current conv2d path. |
| `backends/samsung/_passes/conv1d_to_conv2d.py` `update_kernel` `else`
| `RuntimeError("Weight of 1d conv should be constant tensor or
Parameter obj")` is built and discarded; `weight_node.meta["val"]` is
still unsqueezed. | **Not reachable on a normal Parameter /
lifted-constant / buffer conv1d export.** Those cases are handled by the
preceding branches (the buffer branch was added on `main` by #22725).
The `else` is the leftover for a weight that is none of those. This
change only makes that documented `RuntimeError` actually raise if the
branch is entered. |

### Test plan

Tests cover only the two reachable `ExportSession` guards. There is
intentionally no test for the XNNPACK `else` and none for the Samsung
`else`: both are unreachable on a normal export, and a test that injects
that state would exercise a situation the production callers do not
produce.

`export/tests` is already in `pytest.ini` `testpaths`:

```
pytest export/tests/test_print_delegation_info.py
```

Measured on 89cf698 (merge of `main` 5e21c13), CPython 3.12, torch
2.15.0.dev20261004+cpu:

- `export/tests/test_print_delegation_info.py`: 2 passed.
- Negative control, after `git checkout origin/main --
export/export.py`, same run: `AssertionError: 'at least one of the
lowering stages' not found in 'No delegation info available, atleast one
of the lowering stages should be present'`, 1 failed / 1 passed.
- `pytest export/tests --ignore=export/tests/test_target_recipes.py`: 8
failed / 172 passed on this branch, and the same 8 failed / 170 passed
on `main` alone. The 8 are a local-environment gap
(`exir/_serialize/program.fbs` is copied in by the build, which this
checkout has not run), not a regression. `test_target_recipes.py` does
not collect locally (no `coremltools`).

### CI

Merged `main` into the branch. The conflict in `export/export.py` was
resolved in favour of `main`'s `_raise_if_released` call, keeping the
typo fix. The six reds triaged earlier on 12c3858 came from the merge
base and their upstream fixes (#22802, #22754) are now in this branch.

Two checks are still red on 89cf698, neither of them from this change:

- `pull / android / run-emulator`: the emulator boots
(`sys.boot_completed` returns 1), and
`reactivecircus/android-emulator-runner` then fails on its own post-boot
`adb shell input keyevent 82` with `cmd: Failure calling service input:
Broken pipe (32)`, exit code 224. That step runs before the job script,
and the log carries no output from `scripts/run_android_emulator.sh`.
The same job also failed on `main` at efc7f2e when checked on
2026-10-06, and passed on the seven `main` runs before it.
- `MLTEC_elastic - GitHubPOC` (NXP Bamboo): outside this repository's
workflows, and red on other PRs too, not just this one: of eight open
PRs untouched since 2026-10-05, two carry this status and both are red.
Here the status went `pending` at 2026-10-05T07:01:25Z and `failure` one
second later, which reads as a trigger-side failure rather than anything
built from this branch, but the build log is on an internal host so I
cannot confirm that from here.

This change touches three Python files and adds one test.

cc @nil-is-all @digantdesai

Co-authored-by: Axel.Cffrd.Dnty <AxelNoun@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants