Skip to content

Add Python runtime end-to-end tests for XNNPACK on Linux#18703

Open
Lidang-Jiang wants to merge 1 commit intopytorch:mainfrom
Lidang-Jiang:feat/python-e2e-xnnpack
Open

Add Python runtime end-to-end tests for XNNPACK on Linux#18703
Lidang-Jiang wants to merge 1 commit intopytorch:mainfrom
Lidang-Jiang:feat/python-e2e-xnnpack

Conversation

@Lidang-Jiang
Copy link
Copy Markdown

Summary

Add Python runtime end-to-end tests for the XNNPACK backend on Linux — the first batch for the testing gap described in #11225.

Each test exports a small model with XNNPACK delegation, saves it as .pte, loads it via executorch.runtime.Runtime, and compares the output against PyTorch eager mode. This covers the "developer exports a model, tests it in Python" flow that was previously untested.

Models tested:

  • test_add — element-wise addition
  • test_linear — single Linear layer (fp32)
  • test_conv2d_relu — Conv2d + ReLU
  • test_mlp — multi-layer perceptron (Linear → ReLU → Linear)
  • test_depthwise_separable_conv — depthwise + pointwise conv (MobileNet building block)
  • test_classifier_head — AdaptiveAvgPool2d + Flatten + Linear
  • test_conv_bn — Conv2d + BatchNorm2d + ReLU (skipped: FuseBatchNormPass crashes; TODO to re-enable)

The test file lives in test/end2end/ and is already picked up by pytest.ini (the test/ testpath covers it).

Part of #11225 (Linux XNNPACK)

Test output
$ python -m pytest test/end2end/test_python_runtime_xnnpack.py -v

test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_add PASSED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_classifier_head PASSED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_conv2d_relu PASSED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_conv_bn SKIPPED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_depthwise_separable_conv PASSED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_linear PASSED
test_python_runtime_xnnpack.py::TestPythonRuntimeXNNPACK::test_mlp PASSED

6 passed, 1 skipped in 11.47s

Test plan

  • 6 XNNPACK models exported and verified through Python runtime
  • test_conv_bn skipped with TODO — FuseBatchNormPass has a known bug on Sequential(Conv2d, BN) export
  • ruff check and ruff format pass
  • New file is auto-discovered by pytest.ini via the test/ testpath

cc @jathu @larryliu0820

This PR was authored with the help of Claude.

Export small models (add, linear, conv2d+relu, MLP, depthwise separable
conv, classifier head) with XNNPACK delegation and verify correctness
through the Python runtime (executorch.runtime.Runtime).

This is the Linux XNNPACK portion of the Python runtime test gap
described in the issue.  Each test exports a model to .pte, loads it
via Runtime, and asserts that the output matches PyTorch eager mode.

Part of pytorch#11225

Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 6, 2026

🔗 Helpful Links

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

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

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 Apr 6, 2026
@Lidang-Jiang
Copy link
Copy Markdown
Author

@pytorchbot label "release notes: xnnpack"

@pytorch-bot pytorch-bot bot added the release notes: xnnpack Changes to the XNNPack backend delegate label Apr 6, 2026
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. release notes: xnnpack Changes to the XNNPack backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants