Skip to content

Commit 7f3a084

Browse files
committed
Update base for Update on "make operator name consistent before and after serde"
Differential Revision: [D78380855](https://our.internmc.facebook.com/intern/diff/D78380855/) [ghstack-poisoned]
2 parents fc5f924 + 4744ff5 commit 7f3a084

File tree

27 files changed

+1299
-699
lines changed

27 files changed

+1299
-699
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

.ci/scripts/setup-emscripten.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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.
17

28
set -ex
39

.github/workflows/apple.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ jobs:
149149
VERSION="${{ needs.set-version.outputs.version }}"
150150
FRAMEWORKS=(
151151
"executorch"
152+
"executorch_llm"
152153
"backend_coreml"
153154
"backend_mps"
154155
"backend_xnnpack"

Package.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ let products = deliverables([
6969
"c++",
7070
],
7171
],
72+
"executorch_llm": [
73+
"targets": [
74+
"executorch",
75+
],
76+
],
7277
"kernels_llm": [:],
7378
"kernels_optimized": [
7479
"frameworks": [

backends/apple/coreml/compiler/coreml_preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def preprocess_model(
365365

366366
match model_type:
367367
case CoreMLBackend.MODEL_TYPE.COMPILED_MODEL:
368-
shutil.rmtree(str(model_path.resolve()), ignore_errors=True)
368+
shutil.rmtree(str(model_path.resolve()))
369369
model_path = model_dir_path / MODEL_PATHS.COMPILED_MODEL.value
370370
compiled_model_path = mlmodel.get_compiled_model_path()
371371
shutil.move(
@@ -396,7 +396,7 @@ def preprocess_model(
396396
for key, value in model_debug_info.debugSymbolToHandles.items()
397397
}
398398

399-
shutil.rmtree(str(dir_path.resolve()), ignore_errors=True)
399+
shutil.rmtree(str(dir_path.resolve()))
400400
return PreprocessResult(
401401
processed_bytes=processed_bytes,
402402
debug_handle_map=debug_handle_map,

backends/arm/test/passes/test_decompose_cosine_similarity_pass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def test_decompose_cosine_similarity_tosa_BI(module):
3434
"executorch_exir_dialects_edge__ops_aten_mul_Tensor": 5,
3535
"executorch_exir_dialects_edge__ops_aten_sum_dim_IntList": 3,
3636
"executorch_exir_dialects_edge__ops_aten_pow_Tensor_Scalar": 2,
37-
"executorch_exir_dialects_edge__ops_aten_full_like_default": 1,
37+
# TODO(masnesral): uncomment after https://github.com/pytorch/pytorch/pull/144765
38+
# "executorch_exir_dialects_edge__ops_aten_full_default": 1,
3839
"executorch_exir_dialects_edge__ops_aten_maximum_default": 2,
3940
"executorch_exir_dialects_edge__ops_aten_reciprocal_default": 1,
4041
}

devtools/bundled_program/CMakeLists.txt

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
set(
8-
_schema_files
9-
bundled_program_schema.fbs
10-
scalar_type.fbs
11-
)
7+
set(_schema_files bundled_program_schema.fbs scalar_type.fbs)
128

139
set(_schema_outputs)
1410
foreach(schema_file ${_schema_files})
15-
list(APPEND _bundled_program_schema__srcs "${CMAKE_CURRENT_SOURCE_DIR}/schema/${schema_file}")
11+
list(APPEND _bundled_program_schema__srcs
12+
"${CMAKE_CURRENT_SOURCE_DIR}/schema/${schema_file}"
13+
)
1614

1715
string(REGEX REPLACE "[.]fbs$" "_generated.h" generated "${schema_file}")
18-
list(APPEND _schema_outputs "${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/bundled_program/schema/${generated}")
16+
list(
17+
APPEND
18+
_schema_outputs
19+
"${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/bundled_program/schema/${generated}"
20+
)
1921
endforeach()
2022

2123
file(MAKE_DIRECTORY ${DEVTOOLS_INCLUDE_DIR}/executorch/devtools/bundled_program)
@@ -32,20 +34,13 @@ add_custom_command(
3234
)
3335

3436
add_library(
35-
bundled_program
36-
${_schema_outputs}
37-
${CMAKE_CURRENT_SOURCE_DIR}/bundled_program.cpp
38-
)
39-
target_link_libraries(
40-
bundled_program
41-
PUBLIC
42-
executorch
37+
bundled_program ${_schema_outputs}
38+
${CMAKE_CURRENT_SOURCE_DIR}/bundled_program.cpp
4339
)
40+
target_link_libraries(bundled_program PUBLIC executorch)
4441
target_include_directories(
45-
bundled_program
46-
PUBLIC
47-
${DEVTOOLS_INCLUDE_DIR}
48-
${PROJECT_SOURCE_DIR}/third-party/flatbuffers/include
42+
bundled_program PUBLIC ${DEVTOOLS_INCLUDE_DIR}
43+
${PROJECT_SOURCE_DIR}/third-party/flatbuffers/include
4944
)
5045

5146
install(

examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
03D151D62E0E9E43007A38BE /* ExecuTorchLLM */,
363363
);
364364
name = apple;
365-
path = ../../../../../../../../executorch/extension/llm/apple;
365+
path = ../../../../../../extension/llm/apple;
366366
sourceTree = "<group>";
367367
};
368368
F292B0842D88B0D200BE6839 /* tokenizers */ = {

examples/models/llama/static_attention.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,16 @@ def update(
138138

139139

140140
class StaticAttentionMask:
141-
def __init__(self, input_len, cache_len, style, mask_val=float("-inf")):
141+
def __init__(
142+
self, input_len, cache_len, style, mask_val=float("-inf"), dtype=torch.float32
143+
):
142144
self.input_len = input_len
143145
self.cache_len = cache_len
144146
assert style in ("shift_pointer", "smart_mask")
145147
self.style = style
146148
self.mask_val = mask_val
147149
self.unmasked_len = 0
148-
self.tensor = torch.zeros(1, input_len, input_len + cache_len)
150+
self.tensor = torch.zeros(1, input_len, input_len + cache_len, dtype=dtype)
149151
self.reset()
150152

151153
def reset(self):
@@ -200,44 +202,45 @@ def __init__(
200202
config: ModelArgs,
201203
input_len: int,
202204
cache_len: int,
205+
dtype=torch.float32,
203206
style: str = "shift_pointer",
204207
mask_val: float = float("-inf"),
205208
):
206209
self.mask = StaticAttentionMask(
207-
input_len, cache_len, style=style, mask_val=mask_val
210+
input_len, cache_len, style=style, mask_val=mask_val, dtype=dtype
208211
)
209212

210213
rope = Rope(config)
211214
freqs = rope.get_freqs(None, config.max_seq_len)
212-
self.freqs_cos = freqs[0]
213-
self.freqs_sin = freqs[1]
215+
self.freqs_cos = freqs[0].to(dtype)
216+
self.freqs_sin = freqs[1].to(dtype)
214217

215218
split_mha = config.attention_type in ("static", "static_shas")
216219
if split_mha:
217220
self.k_caches = {
218221
StaticKVCache.calculate_cache_key(layer_id, head_id): torch.zeros(
219-
1, cache_len, config.head_dim
222+
1, cache_len, config.head_dim, dtype=dtype
220223
)
221224
for layer_id in range(config.n_layers)
222225
for head_id in range(config.n_kv_heads)
223226
}
224227
self.v_caches = {
225228
StaticKVCache.calculate_cache_key(layer_id, head_id): torch.zeros(
226-
1, cache_len, config.head_dim
229+
1, cache_len, config.head_dim, dtype=dtype
227230
)
228231
for layer_id in range(config.n_layers)
229232
for head_id in range(config.n_kv_heads)
230233
}
231234
else:
232235
self.k_caches = {
233236
StaticKVCache.calculate_cache_key(layer_id, 0): torch.zeros(
234-
1, config.n_kv_heads, cache_len, config.head_dim
237+
1, config.n_kv_heads, cache_len, config.head_dim, dtype=dtype
235238
)
236239
for layer_id in range(config.n_layers)
237240
}
238241
self.v_caches = {
239242
StaticKVCache.calculate_cache_key(layer_id, 0): torch.zeros(
240-
1, config.n_kv_heads, cache_len, config.head_dim
243+
1, config.n_kv_heads, cache_len, config.head_dim, dtype=dtype
241244
)
242245
for layer_id in range(config.n_layers)
243246
}

0 commit comments

Comments
 (0)