-
Notifications
You must be signed in to change notification settings - Fork 752
[ET-VK][CI] Add vulkan CI to test exporting and running models #13295
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3558453
Update
SS-JIA 4d13668
Update
SS-JIA bbfacb0
Update
SS-JIA cfcae8d
Update
SS-JIA 8fb1164
Update
SS-JIA 3d8cf97
Update
SS-JIA b4a6174
Update
5f3fdb1
Update
eadf7ea
Update
SS-JIA e904823
Update
SS-JIA 4a11f91
Update
SS-JIA 1b33081
Update
SS-JIA b1a4048
Update
SS-JIA 429eb4c
Update
SS-JIA 930a82b
Update
SS-JIA 56f2e32
Update
SS-JIA fb3083d
Update
5730a1d
Update
5a2e920
Update
165eab2
Update
f1ed16a
Update
2048d61
Update
3713a3f
Update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| set -exu | ||
|
|
||
| # Initialize variables | ||
| RUN_BUILD=false | ||
| RUN_CORRECTNESS_TEST=false | ||
| RUN_CLEAN=false | ||
| RUN_RECOMPILE=false | ||
| MODEL_NAME="" | ||
| OUTPUT_DIRECTORY="." | ||
|
|
||
| # Parse arguments | ||
| SKIP_NEXT=false | ||
| for i in $(seq 1 $#); do | ||
| if [[ "$SKIP_NEXT" == true ]]; then | ||
| SKIP_NEXT=false | ||
| continue | ||
| fi | ||
|
|
||
| arg="${!i}" | ||
| case $arg in | ||
| --build|-b) | ||
| RUN_BUILD=true | ||
| ;; | ||
| --clean|-c) | ||
| RUN_CLEAN=true | ||
| ;; | ||
| --recompile|-rc) | ||
| RUN_RECOMPILE=true | ||
| ;; | ||
| --output_directory|-o) | ||
| next_i=$((i + 1)) | ||
| if [[ $next_i -le $# ]]; then | ||
| OUTPUT_DIRECTORY="${!next_i}" | ||
| SKIP_NEXT=true | ||
| else | ||
| echo "Error: --output_directory|-o requires a value" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| --*|-*) | ||
| echo "Unknown argument: $arg" | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| if [[ -z "$MODEL_NAME" ]]; then | ||
| MODEL_NAME="$arg" | ||
| else | ||
| echo "Multiple model names provided: $MODEL_NAME and $arg" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Determine execution mode based on parsed arguments | ||
| if [[ "$RUN_BUILD" == true ]] && [[ -z "$MODEL_NAME" ]]; then | ||
| # Build-only mode | ||
| RUN_CORRECTNESS_TEST=false | ||
| elif [[ "$RUN_BUILD" == true ]] && [[ -n "$MODEL_NAME" ]]; then | ||
| # Build and test mode | ||
| RUN_CORRECTNESS_TEST=true | ||
| elif [[ "$RUN_BUILD" == false ]] && [[ -n "$MODEL_NAME" ]]; then | ||
| # Test-only mode | ||
| RUN_CORRECTNESS_TEST=true | ||
| else | ||
| echo "Invalid argument combination. Usage:" | ||
| echo " $0 --build|-b [--clean|-c] [--recompile|-rc] [-o|--output_directory DIR] # Build-only mode" | ||
| echo " $0 model_name [--build|-b] [--clean|-c] [--recompile|-rc] [-o|--output_directory DIR] # Test mode or build+test mode" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then | ||
| PYTHON_EXECUTABLE=python3 | ||
| fi | ||
| which "${PYTHON_EXECUTABLE}" | ||
|
|
||
| CMAKE_OUTPUT_DIR=cmake-out | ||
|
|
||
| # Only set EXPORTED_MODEL if running correctness test | ||
| if [[ "${RUN_CORRECTNESS_TEST}" == true ]]; then | ||
| EXPORTED_MODEL=${MODEL_NAME}_vulkan | ||
| fi | ||
|
|
||
|
|
||
| clean_build_directory() { | ||
| echo "Cleaning build directory: ${CMAKE_OUTPUT_DIR}" | ||
| rm -rf ${CMAKE_OUTPUT_DIR} | ||
| } | ||
|
|
||
| recompile() { | ||
| cmake --build cmake-out -j64 --target install | ||
| } | ||
|
|
||
| build_core_libraries_and_devtools() { | ||
| echo "Building core libraries and devtools with comprehensive Vulkan support..." | ||
|
|
||
| # Build core libraries with all required components | ||
| cmake . \ | ||
| -DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
| -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \ | ||
| -DEXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=ON \ | ||
| -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \ | ||
| -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \ | ||
| -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ | ||
| -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \ | ||
| -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ | ||
| -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ | ||
| -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \ | ||
| -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ | ||
| -DEXECUTORCH_BUILD_DEVTOOLS=ON \ | ||
| -DEXECUTORCH_BUILD_VULKAN=ON \ | ||
| -DEXECUTORCH_BUILD_XNNPACK=ON \ | ||
| -Bcmake-out && \ | ||
| cmake --build cmake-out -j64 --target install | ||
|
|
||
| # Build devtools example runner | ||
| cmake examples/devtools \ | ||
| -DCMAKE_INSTALL_PREFIX=cmake-out \ | ||
| -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \ | ||
| -DEXECUTORCH_BUILD_VULKAN=ON \ | ||
| -Bcmake-out/examples/devtools && \ | ||
| cmake --build cmake-out/examples/devtools -j16 --config Release | ||
| } | ||
|
|
||
| run_example_runner() { | ||
| ./${CMAKE_OUTPUT_DIR}/examples/devtools/example_runner -bundled_program_path "${OUTPUT_DIRECTORY}/${EXPORTED_MODEL}.bpte" -output_verification | ||
| } | ||
|
|
||
| test_bundled_model_with_vulkan() { | ||
| # Export model as bundled program with Vulkan backend | ||
| "${PYTHON_EXECUTABLE}" -m examples.vulkan.export --model_name="${MODEL_NAME}" --output_dir="${OUTPUT_DIRECTORY}" --bundled | ||
|
|
||
| # Update exported model name for bundled program | ||
| EXPORTED_MODEL="${MODEL_NAME}_vulkan" | ||
|
|
||
| # Verify the exported bundled model exists | ||
| if [[ ! -f "${OUTPUT_DIRECTORY}/${EXPORTED_MODEL}.bpte" ]]; then | ||
| echo "Error: Failed to export bundled model ${MODEL_NAME} with Vulkan backend" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Note: Running bundled programs may require different executor runner | ||
| echo "Bundled program created successfully. Use appropriate bundled program runner to test." | ||
|
|
||
| run_example_runner | ||
| } | ||
|
|
||
|
|
||
| # Main execution | ||
| if [[ "${RUN_BUILD}" == true ]]; then | ||
| if [[ "${RUN_CLEAN}" == true ]]; then | ||
| clean_build_directory | ||
| fi | ||
| build_core_libraries_and_devtools | ||
| fi | ||
|
|
||
| if [[ "${RUN_RECOMPILE}" == true ]]; then | ||
| recompile | ||
| fi | ||
|
|
||
| if [[ "${RUN_CORRECTNESS_TEST}" == true ]]; then | ||
| echo "Testing ${MODEL_NAME} with Vulkan backend..." | ||
| # Always use bundled program testing | ||
| test_bundled_model_with_vulkan | ||
|
|
||
| # Check if test completed successfully | ||
| if [[ $? -eq 0 ]]; then | ||
| echo "Vulkan model test completed successfully!" | ||
| else | ||
| echo "Vulkan model test failed!" | ||
| exit 1 | ||
| fi | ||
| fi |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: plan to add more models to this list as I verify what is currently working