Skip to content

Commit 97bc972

Browse files
Merge branch 'main' into change-1031069
2 parents 884e7f4 + 5aa127e commit 97bc972

File tree

318 files changed

+11956
-2548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+11956
-2548
lines changed

.ci/scripts/setup-vulkan-linux-deps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install_swiftshader() {
2323

2424
export VK_ICD_FILENAMES="${_swiftshader_dir}/swiftshader/build/Linux/vk_swiftshader_icd.json"
2525
export LD_LIBRARY_PATH="${_swiftshader_dir}/swiftshader/build/Linux/"
26+
export ETVK_USING_SWIFTSHADER=1
2627
}
2728

2829
install_vulkan_sdk() {

.ci/scripts/test_llama_lora.sh

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@ DOWNLOADED_PATH=$(
4848
--model_id "${HF_MODEL_REPO}" \
4949
--files "adapter_config.json" "adapter_model.pt" "consolidated.00.pth" "params.json" "tokenizer.model"
5050
)
51-
EXPORTED_MODEL_NAME="llama_3_2_1B_lora.pte"
52-
# Export model.
51+
# Build llama runner.
52+
cmake_install_executorch_libraries
53+
cmake_build_llama_runner
54+
55+
# Constants.
56+
RUNTIME_ARGS="--tokenizer_path=${DOWNLOADED_PATH}/tokenizer.model --temperature=0 --seq_len=20 --warmup=1"
57+
PROMPT="What happens if you eat watermelon seeds?"
58+
EXPECTED_PREFIX="What happens if you eat watermelon seeds? Watermelon seeds are a good source of vitamin C,"
59+
60+
# Export LoRA PTE file.
61+
MODEL_NAME="llama_3_2_1B_lora"
5362
$PYTHON_EXECUTABLE -m extension.llm.export.export_llm \
5463
base.checkpoint="${DOWNLOADED_PATH}/consolidated.00.pth" \
5564
base.params="${DOWNLOADED_PATH}/params.json" \
@@ -61,36 +70,64 @@ $PYTHON_EXECUTABLE -m extension.llm.export.export_llm \
6170
model.dtype_override="fp32" \
6271
backend.xnnpack.enabled=true \
6372
backend.xnnpack.extended_ops=true \
64-
export.output_name="${EXPORTED_MODEL_NAME}"
65-
66-
# Build llama runner.
67-
cmake_install_executorch_libraries
68-
cmake_build_llama_runner
73+
export.output_name="${MODEL_NAME}.pte"
6974

70-
PROMPT="What happens if you eat watermelon seeds?"
7175
# Run llama runner
72-
RUNTIME_ARGS="--model_path=${EXPORTED_MODEL_NAME} --tokenizer_path=${DOWNLOADED_PATH}/tokenizer.model --temperature=0 --seq_len=20 --warmup=1"
73-
7476
NOW=$(date +"%H:%M:%S")
7577
echo "Starting to run llama runner at ${NOW}"
7678
# shellcheck source=/dev/null
77-
cmake-out/examples/models/llama/llama_main --prompt="${PROMPT}" ${RUNTIME_ARGS} > result.txt
79+
cmake-out/examples/models/llama/llama_main --model_path=${MODEL_NAME}.pte --prompt="${PROMPT}" ${RUNTIME_ARGS} > result.txt
7880
NOW=$(date +"%H:%M:%S")
7981
echo "Finished at ${NOW}"
8082

8183
RESULT=$(cat result.txt)
82-
EXPECTED_PREFIX="What happens if you eat watermelon seeds? Watermelon seeds are a good source of vitamin C,"
83-
8484
if [[ "${RESULT}" == "${EXPECTED_PREFIX}"* ]]; then
8585
echo "Expected result prefix: ${EXPECTED_PREFIX}"
8686
echo "Actual result: ${RESULT}"
87+
# Do not clean up files if test passes, as they're re-used in the next test.
8788
echo "Success"
88-
cleanup_files
8989
else
9090
echo "Expected result prefix: ${EXPECTED_PREFIX}"
9191
echo "Actual result: ${RESULT}"
9292
echo "Failure; results not the same"
93+
cleanup_files
94+
exit 1
95+
fi
9396

97+
# Export LoRA PTE, PTD file.
98+
MODEL_SEPARATE="${MODEL_NAME}_separate"
99+
$PYTHON_EXECUTABLE -m extension.llm.export.export_llm \
100+
base.checkpoint="${DOWNLOADED_PATH}/consolidated.00.pth" \
101+
base.params="${DOWNLOADED_PATH}/params.json" \
102+
base.adapter_checkpoint="${DOWNLOADED_PATH}/adapter_model.pt" \
103+
base.adapter_config="${DOWNLOADED_PATH}/adapter_config.json" \
104+
base.tokenizer_path="${DOWNLOADED_PATH}/tokenizer.model" \
105+
model.use_kv_cache=true \
106+
model.use_sdpa_with_kv_cache=true \
107+
model.dtype_override="fp32" \
108+
backend.xnnpack.enabled=true \
109+
backend.xnnpack.extended_ops=true \
110+
export.output_name="${MODEL_SEPARATE}.pte" \
111+
export.foundation_weights_file="${MODEL_SEPARATE}.ptd"
112+
113+
# Run llama runner.
114+
NOW=$(date +"%H:%M:%S")
115+
echo "Starting to run llama runner at ${NOW}"
116+
# shellcheck source=/dev/null
117+
cmake-out/examples/models/llama/llama_main --model_path=${MODEL_SEPARATE}.pte --data_path=${MODEL_SEPARATE}.ptd --prompt="${PROMPT}" ${RUNTIME_ARGS} > result2.txt
118+
NOW=$(date +"%H:%M:%S")
119+
echo "Finished at ${NOW}"
120+
121+
RESULT2=$(cat result2.txt)
122+
if [[ "${RESULT2}" == "${EXPECTED_PREFIX}"* ]]; then
123+
echo "Expected result prefix: ${EXPECTED_PREFIX}"
124+
echo "Actual result: ${RESULT2}"
125+
echo "Success"
126+
cleanup_files
127+
else
128+
echo "Expected result prefix: ${EXPECTED_PREFIX}"
129+
echo "Actual result: ${RESULT2}"
130+
echo "Failure; results not the same"
94131
cleanup_files
95132
exit 1
96133
fi

.ci/scripts/test_model.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ test_model_with_qnn() {
201201
EXPORT_SCRIPT=bert
202202
elif [[ "${MODEL_NAME}" == "conv_former" ]]; then
203203
EXPORT_SCRIPT=conv_former
204-
EXTRA_FLAGS="--dataset imagenet-mini/val"
205204
elif [[ "${MODEL_NAME}" == "cvt" ]]; then
206205
EXPORT_SCRIPT=cvt
207206
elif [[ "${MODEL_NAME}" == "distilbert" ]]; then

.ci/scripts/test_qnn_static_llama.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ echo "Creating tokenizer.bin"
3333
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin
3434

3535
set +e
36-
# Compile only as weight sharing is not applicable on x86
37-
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-android/ --executorch_root . --artifact_dir . --llama_artifacts . --compile_only
36+
# Compile only as weight sharing is not applicable on x86.
37+
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-android/ --executorch_root . --artifact_dir ./stories_110m_pte_size --llama_artifacts . --compile_only
3838
exit_code1=$?
3939

4040
# Checks accuracy with weight sharing disabled since x86 does not support weight sharing.
41-
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir . --llama_artifacts . --enable_x86_64
41+
$PYTHON_EXECUTABLE backends/qualcomm/tests/test_qnn_delegate.py -k TestExampleLLMScript.test_llama_stories_110m --model SM8650 --build_folder build-x86/ --executorch_root . --artifact_dir ./stories_110m_accuracy --llama_artifacts . --enable_x86_64
4242
exit_code2=$?
4343

4444
# Check BC
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Add Open External Contributor PRs and Issues to PyTorch Org Project 136
2+
3+
on:
4+
schedule:
5+
- cron: '0 * * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
add_to_project:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors)
13+
uses: actions/github-script@v7
14+
with:
15+
github-token: ${{ secrets.PYTORCH_PROJECT_PAT }}
16+
script: |
17+
const projectId = "PVT_kwDOAUB9vs4A_PUL"; // PyTorch org project 136
18+
const owner = 'pytorch';
19+
const repo = 'executorch';
20+
21+
// List of authors to exclude
22+
const excludedAuthors = new Set([
23+
"nil-is-all", "cbilgin", "KimishPatel", "psiddh", "digantdesai", "SS-JIA", "ahmtox", "mcr229", "shoumikhin",
24+
"manuelcandales", "metascroy", "cccclai", "rohansjoshi", "kirklandsign", "abhinaykukkadapu", "JacobSzwejbka",
25+
"Conarnar", "lucylq", "larryliu0820", "BujSet", "Gasoonjia", "Juntian777", "guangy10", "jackzhxng",
26+
"GregoryComer", "leafs1", "swolchok", "mergennachin", "tarun292", "byjlw", "jathu", "Jack-Khuu", "georgehong",
27+
"zhenyan-zhang-meta", "silverguo", "dbort", "jorgep31415", "huydhn", "mcremon-meta", "trivedivivek", "angelayi",
28+
"helunwencser", "hsharma35", "zhxchen17", "iseeyuan", "svekars", "nathanaelsee", "dulinriley", "jerryzh168",
29+
"cmodi-meta", "bigfootjon", "sxu", "ydwu4", "Riandy", "tugsbayasgalan", "bsoyluoglu", "yangw-dev", "YIWENX14",
30+
"namanahuja", "yushangdi", "limintang", "pianpwk", "viveknayakatmeta", "andreanicastro", "JakeStevens",
31+
"gmagogsfm", "zonglinpeng", "eigen-k", "derekxu", "salilsdesai", "skrtskrtfb", "pssrawat", "r-barnes", "pytorchbot",
32+
"pytorchmergebot", "pytorchupdatebot", "facebook-github-bot", "Erik-Lundell", "zingo", "AdrianLundell",
33+
"oscarandersson8218", "per", "Sebastian-Larsson", "SaoirseARM", "robell", "mansnils", "martinlsm", "freddan80",
34+
"YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov", "fumchin", "wwwind", "haowhsu-quic", "shewu-quic",
35+
"winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "cymbalrush", "DenisVieriu97", "billmguo",
36+
"StrycekSimon", "jirioc", "robert-kalmar", "skywall", "neuropilot-captain"
37+
]);
38+
39+
async function addItem(contentId, type, number) {
40+
try {
41+
await github.graphql(`
42+
mutation {
43+
addProjectV2ItemById(input: {projectId: "${projectId}", contentId: "${contentId}"}) {
44+
item { id }
45+
}
46+
}
47+
`);
48+
console.log(`Added ${type} #${number} to project`);
49+
} catch (error) {
50+
if (error.message && error.message.includes("A project item already exists for this content")) {
51+
// Ignore if already exists
52+
console.log(`${type} #${number} already in project`);
53+
} else {
54+
console.log(`Error adding ${type} #${number}: ${error.message}`);
55+
}
56+
}
57+
}
58+
59+
try {
60+
// Add open issues (not PRs) and exclude by author
61+
const issues = await github.paginate(
62+
github.rest.issues.listForRepo,
63+
{
64+
owner,
65+
repo,
66+
state: 'open',
67+
filter: 'all'
68+
}
69+
);
70+
for (const issue of issues) {
71+
if (!issue.pull_request && !excludedAuthors.has(issue.user.login)) {
72+
await addItem(issue.node_id, 'issue', issue.number);
73+
}
74+
}
75+
76+
// Add open, non-draft PRs (regardless of review state), exclude by author
77+
const prs = await github.paginate(
78+
github.rest.pulls.list,
79+
{
80+
owner,
81+
repo,
82+
state: 'open',
83+
draft: false,
84+
}
85+
);
86+
for (const pr of prs) {
87+
if (!excludedAuthors.has(pr.user.login)) {
88+
await addItem(pr.node_id, 'pr', pr.number);
89+
}
90+
}
91+
} catch (error) {
92+
core.setFailed(`Workflow failed: ${error.message}`);
93+
}

.github/workflows/build-presets.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
branches:
77
- main
88
- release/*
9-
paths:
10-
- .github/workflows/build-presets.yml
119
workflow_dispatch:
1210

1311
concurrency:

.github/workflows/pull.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ jobs:
315315
bash examples/models/moshi/mimi/install_requirements.sh
316316
317317
# reinstall executorch
318-
bash ./install_executorch.sh
318+
bash ./install_executorch.sh --minimal
319319
320320
# run python unittest
321321
python -m unittest examples.models.moshi.mimi.test_mimi
@@ -801,6 +801,8 @@ jobs:
801801
id-token: write
802802
contents: read
803803
strategy:
804+
matrix:
805+
enable-etdump: ['', '--enable-etdump']
804806
fail-fast: false
805807
with:
806808
runner: linux.2xlarge
@@ -820,7 +822,7 @@ jobs:
820822
source .ci/scripts/setup-emscripten.sh
821823
822824
# Test selective build
823-
bash scripts/build_wasm_tests.sh
825+
bash scripts/build_wasm_tests.sh ${{ matrix.enable-etdump }}
824826
825827
# Install Jest
826828
cd cmake-out-wasm/extension/wasm/test
@@ -862,6 +864,43 @@ jobs:
862864
PYTHON_EXECUTABLE=python bash examples/nxp/run_aot_example.sh
863865
864866
867+
test-vulkan-models-linux:
868+
name: test-vulkan-models-linux
869+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
870+
permissions:
871+
id-token: write
872+
contents: read
873+
with:
874+
runner: linux.2xlarge
875+
docker-image: ci-image:executorch-ubuntu-22.04-clang12
876+
submodules: 'recursive'
877+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
878+
timeout: 90
879+
script: |
880+
set -eux
881+
882+
# The generic Linux job chooses to use base env, not the one setup by the image
883+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
884+
conda activate "${CONDA_ENV}"
885+
886+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
887+
source .ci/scripts/setup-vulkan-linux-deps.sh
888+
889+
# Setup python
890+
PYTHON_EXECUTABLE=python \
891+
CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON" \
892+
.ci/scripts/setup-linux.sh --build-tool "cmake"
893+
894+
PYTHON_EXECUTABLE=python bash backends/vulkan/test/scripts/test_model.sh --build
895+
896+
# Test models serially
897+
models="mv2 mv3 edsr resnet18 resnet50 dl3"
898+
for model in $models; do
899+
python -m examples.vulkan.export --model_name=$model --test
900+
done
901+
902+
903+
865904
nxp-build-test:
866905
name: nxp-build-test
867906
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main

0 commit comments

Comments
 (0)