File tree Expand file tree Collapse file tree 15 files changed +71
-24
lines changed
extension/benchmark/apple/Benchmark/Tests/LLaMA
shim/xplat/executorch/build Expand file tree Collapse file tree 15 files changed +71
-24
lines changed Original file line number Diff line number Diff line change 22
22
# have already been installed, so we use PyTorch build from source here instead
23
23
# of nightly. This allows CI to test against latest commits from PyTorch
24
24
install_executorch " use-pt-pinned-commit"
25
- build_executorch_runner " ${BUILD_TOOL} "
25
+ build_executorch_runner " ${BUILD_TOOL} " " ${2 :- Release} "
26
26
27
27
if [[ " ${GITHUB_BASE_REF:- } " == * main* || " ${GITHUB_BASE_REF:- } " == * gh* ]]; then
28
28
do_not_use_nightly_on_ci
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ install_pytorch_and_domains
136
136
# We build PyTorch from source here instead of using nightly. This allows CI to test against
137
137
# the pinned commit from PyTorch
138
138
install_executorch " use-pt-pinned-commit"
139
- build_executorch_runner " ${BUILD_TOOL} "
139
+ build_executorch_runner " ${BUILD_TOOL} " " ${2 :- Release} "
140
140
141
141
if [[ " ${GITHUB_BASE_REF:- } " == * main* || " ${GITHUB_BASE_REF:- } " == * gh* ]]; then
142
142
do_not_use_nightly_on_ci
Original file line number Diff line number Diff line change 14
14
exit 1
15
15
fi
16
16
17
+ BUILD_MODE=$2
18
+ if [[ " ${BUILD_MODE:- } " =~ ^(Debug| Release)$ ]]; then
19
+ echo " Running tests in build mode ${BUILD_MODE} ..."
20
+ else
21
+ echo " Unsupported build mode ${BUILD_MODE} , options are Debug or Release."
22
+ exit 1
23
+ fi
24
+
17
25
# The generic Linux job chooses to use base env, not the one setup by the image
18
26
eval " $( conda shell.bash hook) "
19
27
CONDA_ENV=$( conda env list --json | jq -r " .envs | .[-1]" )
@@ -25,7 +33,7 @@ source .ci/scripts/setup-vulkan-linux-deps.sh
25
33
PYTHON_EXECUTABLE=python \
26
34
EXECUTORCH_BUILD_PYBIND=ON \
27
35
CMAKE_ARGS=" -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
28
- .ci/scripts/setup-linux.sh " $BUILD_TOOL "
36
+ .ci/scripts/setup-linux.sh " $BUILD_TOOL " " $BUILD_MODE "
29
37
30
38
# Install llama3_2_vision dependencies.
31
39
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
Original file line number Diff line number Diff line change 14
14
exit 1
15
15
fi
16
16
17
+ BUILD_MODE=$2
18
+ if [[ $BUILD_MODE =~ ^(Debug| Release)$ ]]; then
19
+ echo " Running tests in build mode ${BUILD_MODE} ..."
20
+ else
21
+ echo " Unsupported build mode ${BUILD_MODE} , options are Debug or Release."
22
+ exit 1
23
+ fi
24
+
17
25
bash .ci/scripts/setup-conda.sh
18
26
eval " $( conda shell.bash hook) "
19
27
@@ -27,7 +35,7 @@ PYTHON_EXECUTABLE=python \
27
35
EXECUTORCH_BUILD_PYBIND=ON \
28
36
CMAKE_ARGS=" -DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
29
37
${CONDA_RUN} --no-capture-output \
30
- .ci/scripts/setup-macos.sh cmake
38
+ .ci/scripts/setup-macos.sh " ${BUILD_TOOL} " " ${BUILD_MODE} "
31
39
32
40
# Install llama3_2_vision dependencies.
33
41
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ build_executorch_runner_cmake() {
109
109
pushd " ${CMAKE_OUTPUT_DIR} " || return
110
110
# This command uses buck2 to gather source files and buck2 could crash flakily
111
111
# on MacOS
112
- retry cmake -DPYTHON_EXECUTABLE=" ${PYTHON_EXECUTABLE} " -DCMAKE_BUILD_TYPE=Release ..
112
+ retry cmake -DPYTHON_EXECUTABLE=" ${PYTHON_EXECUTABLE} " -DCMAKE_BUILD_TYPE=" ${1 :- Release} " ..
113
113
popd || return
114
114
115
115
if [ " $( uname) " == " Darwin" ]; then
@@ -124,7 +124,7 @@ build_executorch_runner() {
124
124
if [[ $1 == " buck2" ]]; then
125
125
build_executorch_runner_buck2
126
126
elif [[ $1 == " cmake" ]]; then
127
- build_executorch_runner_cmake
127
+ build_executorch_runner_cmake " $2 "
128
128
else
129
129
echo " Invalid build tool $1 . Only buck2 and cmake are supported atm"
130
130
exit 1
Original file line number Diff line number Diff line change @@ -229,21 +229,22 @@ def extract_ios_metric(
229
229
230
230
elif method == "forward" :
231
231
if metric_name == "Clock Monotonic Time, s" :
232
- benchmark_result ["metric" ] = (
233
- "generate_time(ms)"
234
- if "llama" in test_name
235
- else "avg_inference_latency(ms)"
236
- )
232
+ benchmark_result ["metric" ] = "avg_inference_latency(ms)"
237
233
benchmark_result ["actualValue" ] = metric_value * 1000
238
234
239
235
elif metric_name == "Memory Peak Physical, kB" :
240
236
# NB: Showing the value in mB is friendlier IMO
241
237
benchmark_result ["metric" ] = "peak_inference_mem_usage(mb)"
242
238
benchmark_result ["actualValue" ] = metric_value / 1024
243
239
244
- elif method == "generate" and metric_name == "Tokens Per Second, t/s" :
245
- benchmark_result ["metric" ] = "token_per_sec"
246
- benchmark_result ["actualValue" ] = metric_value
240
+ elif method == "generate" :
241
+ if metric_name == "Clock Monotonic Time, s" :
242
+ benchmark_result ["metric" ] = "generate_time(ms)"
243
+ benchmark_result ["actualValue" ] = metric_value * 1000
244
+
245
+ elif metric_name == "Tokens Per Second, t/s" :
246
+ benchmark_result ["metric" ] = "token_per_sec"
247
+ benchmark_result ["actualValue" ] = metric_value
247
248
248
249
return benchmark_result
249
250
Original file line number Diff line number Diff line change 7
7
required : true
8
8
type : string
9
9
description : Name of the docker image to use.
10
+ build-mode :
11
+ required : true
12
+ type : string
13
+ description : Build mode to use, Debug or Release.
10
14
build-tool :
11
15
required : true
12
16
type : string
30
34
timeout : 90
31
35
script : |
32
36
set -eux
33
- .ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}"
37
+ .ci/scripts/unittest-linux.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
34
38
35
39
macos :
36
40
uses : pytorch/test-infra/.github/workflows/macos_job.yml@main
41
45
ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
42
46
script : |
43
47
set -eux
44
- .ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}"
48
+ .ci/scripts/unittest-macos.sh "${{ inputs.build-tool }}" "${{ inputs.build-mode }}"
Original file line number Diff line number Diff line change @@ -367,6 +367,7 @@ jobs:
367
367
id-token : write
368
368
contents : read
369
369
with :
370
+ build-mode : Debug
370
371
build-tool : cmake
371
372
docker-image : executorch-ubuntu-22.04-clang12
372
373
@@ -376,6 +377,7 @@ jobs:
376
377
id-token : write
377
378
contents : read
378
379
with :
380
+ build-mode : Debug
379
381
build-tool : buck2
380
382
docker-image : executorch-ubuntu-22.04-clang12
381
383
Original file line number Diff line number Diff line change @@ -489,3 +489,13 @@ jobs:
489
489
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
490
490
# Test llama2
491
491
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh -model stories110M -build_tool "${BUILD_TOOL}" -mode "${MODE}" -dtype "${DTYPE}" -pt2e_quantize "${PT2E_QUANTIZE}"
492
+
493
+ unittest-release :
494
+ uses : ./.github/workflows/_unittest.yml
495
+ permissions :
496
+ id-token : write
497
+ contents : read
498
+ with :
499
+ build-mode : Release
500
+ build-tool : cmake
501
+ docker-image : executorch-ubuntu-22.04-clang12
Original file line number Diff line number Diff line change @@ -95,11 +95,8 @@ runtime.command_alias(
95
95
)
96
96
97
97
runtime.python_library(
98
- name = "export_library ",
98
+ name = "source_transformation ",
99
99
srcs = [
100
- "export_llama.py",
101
- "export_llama_lib.py",
102
- "model.py",
103
100
"source_transformation/apply_spin_quant_r1_r2.py",
104
101
"source_transformation/attention.py",
105
102
"source_transformation/lora.py",
@@ -114,6 +111,15 @@ runtime.python_library(
114
111
"source_transformation/vulkan_rope.py",
115
112
"source_transformation/attention_sink.py",
116
113
],
114
+ )
115
+
116
+ runtime.python_library(
117
+ name = "export_library",
118
+ srcs = [
119
+ "export_llama.py",
120
+ "export_llama_lib.py",
121
+ "model.py",
122
+ ],
117
123
_is_external_target = True,
118
124
base_module = "executorch.examples.models.llama",
119
125
visibility = [
@@ -123,6 +129,7 @@ runtime.python_library(
123
129
"@EXECUTORCH_CLIENTS",
124
130
],
125
131
deps = [
132
+ ":source_transformation",
126
133
"//ai_codesign/gen_ai/fast_hadamard_transform:fast_hadamard_transform",
127
134
"//caffe2:torch",
128
135
"//executorch/backends/vulkan/_passes:vulkan_passes",
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ @implementation LLaMATests
82
82
return ;
83
83
}
84
84
TokensPerSecondMetric *tokensPerSecondMetric = [TokensPerSecondMetric new ];
85
- [testCase measureWithMetrics: @[ tokensPerSecondMetric, [XCTMemoryMetric new ] ]
85
+ [testCase measureWithMetrics: @[ tokensPerSecondMetric, [XCTClockMetric new ], [ XCTMemoryMetric new ] ]
86
86
block: ^{
87
87
tokensPerSecondMetric.tokenCount = 0 ;
88
88
const auto status = runner->generate (
Original file line number Diff line number Diff line change @@ -59,8 +59,13 @@ class Result final {
59
59
* a non-Ok value.
60
60
*/
61
61
/* implicit */ Result(Error error)
62
- : error_(error == Error::Ok ? Error::Internal : error),
63
- hasValue_ (false ) {}
62
+ : error_(error == Error::Ok ? Error::Internal : error), hasValue_(false ) {
63
+ if ET_UNLIKELY (error == Error::Ok) {
64
+ ET_LOG (
65
+ Debug,
66
+ " Attempted to create Result from Error::Ok, this has been converted to Error::Internal." );
67
+ }
68
+ }
64
69
65
70
// / Value copy constructor.
66
71
/* implicit */ Result(const T& val) : value_(val), hasValue_(true ) {}
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ TEST(ErrorHandlingTest, ResultBasic) {
110
110
}
111
111
112
112
TEST (ErrorHandlingTest, OkErrorNotPossible) {
113
+ executorch::runtime::runtime_init ();
113
114
Result<uint32_t > r (Error::Ok);
114
115
ASSERT_FALSE (r.ok ());
115
116
ASSERT_NE (r.error (), Error::Ok);
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ def _patch_kwargs_common(kwargs):
171
171
# don't pick up unexpected clients while things are still in flux.
172
172
if not kwargs .pop ("_is_external_target" , False ):
173
173
for target in kwargs .get ("visibility" , []):
174
- if not (target .startswith ("//executorch" ) or target .startswith ("@" )):
174
+ if not (target .startswith ("//executorch" ) or target .startswith ("//pytorch/tokenizers" ) or target . startswith ( " @" )):
175
175
fail ("Please manage all external visibility using the " +
176
176
"EXECUTORCH_CLIENTS list in " +
177
177
"//executorch/build/fb/clients.bzl. " +
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def define_common_targets():
21
21
],
22
22
visibility = [
23
23
"//executorch/..." ,
24
+ "//pytorch/tokenizers/..." ,
24
25
"@EXECUTORCH_CLIENTS" ,
25
26
],
26
27
deps = [
You can’t perform that action at this time.
0 commit comments