Skip to content

Commit 5044039

Browse files
committed
Add test for eager torchtune llama runner
1 parent b74e2c3 commit 5044039

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -exu
9+
10+
ENABLE_KV_CACHE="${1:-false}"
11+
12+
if [[ "${ENABLE_KV_CACHE}" != "true" && "${ENABLE_KV_CACHE}" != "false" ]]; then
13+
echo "Error: ENABLE_KV_CACHE must be 'true' or 'false'"
14+
exit 1
15+
fi
16+
17+
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
18+
PYTHON_EXECUTABLE=python3
19+
fi
20+
21+
download_dependencies() {
22+
bash examples/models/llama3_2_vision/install_requirements.sh
23+
tune download meta-llama/Llama-3.2-11B-Vision-Instruct --output-dir /tmp/Llama-3.2-11B-Vision-Instruct
24+
}
25+
26+
run_and_verify_eager() {
27+
NOW=$(date +"%H:%M:%S")
28+
echo "Starting to test llama3_2_vision text decoder at ${NOW}"
29+
if [[ ! -f "/tmp/Llama-3.2-11B-Vision-Instruct/original/consolidated.pth" ]]; then
30+
echo "checkpoint (consolidated.pth) is missing."
31+
exit 1
32+
fi
33+
if [[ ! -f "/tmp/Llama-3.2-11B-Vision-Instruct/original/tokenizer.model" ]]; then
34+
echo "tokenizer.model is missing."
35+
exit 1
36+
fi
37+
38+
EAGER_RUNNER_ARGS="$PYTHON_EXECUTABLE -m examples.models.llama3_2_vision.runner.eager \
39+
-c /tmp/Llama-3.2-11B-Vision-Instruct/original/consolidated.pth \
40+
-t /tmp/Llama-3.2-11B-Vision-Instruct/original/tokenizer.model \
41+
-d fp32 \
42+
--max_seq_length 32 \
43+
--temperature 0 \
44+
--show_tokens \
45+
--prompt \"Once upon a time,\" > result.txt"
46+
47+
if [[ "${ENABLE_KV_CACHE}" == "true" ]]; then
48+
EAGER_RUNNER_ARGS="${EAGER_RUNNER_ARGS} -kv"
49+
fi
50+
51+
# Verify result.txt
52+
RESULT=$(cat result.txt)
53+
EXPECTED_RESULT="727, 471, 263, 2217, 7826, 4257, 365, 2354, 29889, 2296, 18012, 304, 1708, 5377, 297, 278, 6575, 845, 457, 29889, 3118, 2462, 29892, 1183, 4446, 263"
54+
if [[ "${RESULT}" == *"${EXPECTED_RESULT}"* ]]; then
55+
echo "Actual result: ${RESULT}"
56+
echo "Success"
57+
exit 0
58+
else
59+
echo "Actual result: ${RESULT}"
60+
echo "Failure; results not the same"
61+
exit 1
62+
fi
63+
}
64+
65+
download_dependencies
66+
run_and_verify

.github/workflows/pull.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,31 @@ jobs:
502502
503503
# run llama runner in eager mode
504504
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama_runner_eager.sh
505+
506+
test-llama_3_2_vision_runner_eager-linux:
507+
name: test-llama_3_2_vision_runner_eager-linux
508+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
509+
strategy:
510+
matrix:
511+
enable_kv_cache: ["true", "false]
512+
fail-fast: false
513+
with:
514+
runner: linux.24xlarge
515+
docker-image: executorch-ubuntu-22.04-clang12
516+
submodules: 'true'
517+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
518+
timeout: 90
519+
script: |
520+
# The generic Linux job chooses to use base env, not the one setup by the image
521+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
522+
conda activate "${CONDA_ENV}"
523+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
524+
# install pybind
525+
bash install_requirements.sh
526+
# install llama requirements
527+
bash examples/models/llama/install_requirements.sh
528+
529+
ENABLE_KV_CACHE=${{ matrix.enable_kv_cache }}
530+
531+
# run llama runner in eager mode
532+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama_runner_eager.sh "${ENABLE_KV_CACHE}"

0 commit comments

Comments
 (0)