Skip to content

Fix wheel build and smoke test #4429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed

Conversation

kirklandsign
Copy link
Contributor

@kirklandsign kirklandsign commented Jul 25, 2024

Test Plan:

  1. Label ciflow/binaries to build wheel
  2. CI and OSS CI. This makes sure that smoke test can pass, and a portable model can export and run E2E. Python 3.9 is not supported for now.
  3. Run these helps validate unittest failure for quantized ops
pip uninstall executorch -y
rm dist/*.whl
source build/packaging/env_var_script_m1.sh # or Linux
python setup.py bdist_wheel
pip install dist/*.whl

Then in Python, try

from executorch.extension.pybindings import portable_lib
from executorch.exir.dialects._ops import ops
import executorch.kernels.quantized
ops.edge.quantized_decomposed.add.default.to_out_variant().name()

Copy link

pytorch-bot bot commented Jul 25, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 371b022 with merge base 76f0b61 (image):

UNSTABLE - The following jobs failed but were likely due to flakiness present on trunk and has been marked as unstable:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-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 25, 2024
@kirklandsign
Copy link
Contributor Author

Also need to fix rpath for custom_ops

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@dbort dbort left a comment

Choose a reason for hiding this comment

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

This is looking so much better! Thank you for figuring out the dependency stuff.

CMakeLists.txt Outdated
@@ -755,6 +753,16 @@ if(EXECUTORCH_BUILD_PYBIND)
# the torch libs are in `site-packages/torch/lib`.
BUILD_RPATH "@loader_path/../../../torch/lib"
INSTALL_RPATH "@loader_path/../../../torch/lib"
BUILD_RPATH "@loader_path/../../"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment explaining these two new RPATH lines, since the "site-packages/torch-lib" comment doesn't apply to them.

CMakeLists.txt Outdated
portable_lib
PROPERTIES # Assume that this library will be installed in
# `site-packages/executorch/extension/pybindings`, and that
# the custom_ops_aot_lib should be found with relative path.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that custom_ops_aot_lib.so will be installed in the root of the executorch pip package? I'd rather install it in the same directory as portable_lib, or under something like /data/lib.

Copy link
Contributor

Choose a reason for hiding this comment

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

it should be under site-packages/executorch/extension/llm/custom_ops/

setup.py Outdated
Comment on lines 576 to 583
"executorch",
)
)
ext_modules.append(
# Install the prebuilt library for quantized ops required by custom ops.
BuiltFile(
"kernels/quantized/libquantized_ops_aot_lib.*",
"executorch",
Copy link
Contributor

Choose a reason for hiding this comment

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

The second arg to BuiltFile is the name of the destination file or directory. If the intent is to install to a directory, then the destination should end in a / character. But please see if "executorch/data/lib/" works: that would address my comment above about not installing these in the root of the pip package, though you'd also need to update the RPATH. Or you could try setting the dest to executorch/extension/pybindings/ so that the libs end up in the same directory as _portable_lib.so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your script works! Yes the trailing / makes a difference

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines 32 to 40
try:
from pathlib import Path
libs = list(Path(__file__).parent.parent.parent.resolve().glob("**/libquantized_ops_aot_lib.*"))
del Path
assert len(libs) == 1, f"Expected 1 library but got {len(libs)}"
_torch.ops.load_library(libs[0])
except:
pass

Copy link
Contributor

Choose a reason for hiding this comment

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

So we probably don't want this code to live here. We should load it whenever we need it. I think we should add this code in init.py under this directory, so that you can import it in the unittest here

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.


libs = list(
Path(__file__)
.parent.parent.parent.resolve()
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally the so file should just under the same directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I copied to the same directory so Path(file).parent should be good.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@dbort dbort left a comment

Choose a reason for hiding this comment

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

The latest changes look good.

Please update the PR description with a Test Plan: section explaining how you have been testing all of this. It will be very useful to have the next time we need to mess with wheel issues.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@kirklandsign merged this pull request in bf477e4.

mcr229 pushed a commit to mcr229/executorch that referenced this pull request Aug 7, 2024
Summary: Pull Request resolved: pytorch#4429

Test Plan:
1. Label `ciflow/binaries` to build wheel
2. CI and OSS CI. This makes sure that smoke test can pass, and a portable model can export and run E2E. Python 3.9 is not supported for now.
3. Run these helps validate unittest failure for quantized ops

```
pip uninstall executorch -y
rm dist/*.whl
source build/packaging/env_var_script_m1.sh # or Linux
python setup.py bdist_wheel
pip install dist/*.whl
```

Then in Python, try
```
from executorch.extension.pybindings import portable_lib
from executorch.exir.dialects._ops import ops
import executorch.kernels.quantized
ops.edge.quantized_decomposed.add.default.to_out_variant().name()
```

Reviewed By: larryliu0820

Differential Revision: D60694247

Pulled By: kirklandsign

fbshipit-source-id: 4da77493c0e7a868f86b583c9c33d54d08c3e48b
@kirklandsign kirklandsign deleted the fix-wheel-smoke-test branch August 8, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/binaries CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants