Skip to content

Commit f5bcdcc

Browse files
committed
Update
[ghstack-poisoned]
2 parents b57678b + 05effc4 commit f5bcdcc

File tree

16 files changed

+1103
-483
lines changed

16 files changed

+1103
-483
lines changed

.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"

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
}

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
}

examples/wasm/test_build_wasm.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 -e
39

exir/tests/test_memory_planning.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -868,21 +868,23 @@ def forward(self, input, label):
868868

869869
ep.dump_executorch_program(True)
870870

871-
# 147 just so happens to be the index of the user_grad output arg of
871+
# 149 just so happens to be the index of the user_grad output arg of
872872
# convolution_backward.out. This is fairly fragile.
873873
# Check that the None output is not memory planned.
874-
self.assertEqual(
875-
ep.executorch_program.execution_plan[0]
876-
.values[147]
877-
.val.data_buffer_idx, # pyright: ignore
878-
0,
879-
)
880-
self.assertEqual(
881-
ep.executorch_program.execution_plan[0]
882-
.values[147]
883-
.val.allocation_info, # pyright: ignore
884-
None,
885-
)
874+
# TODO(masnesral): restore after https://github.com/pytorch/pytorch/pull/144765
875+
# self.assertEqual(len(ep.executorch_program.execution_plan[0].values), 151)
876+
# self.assertEqual(
877+
# ep.executorch_program.execution_plan[0]
878+
# .values[149]
879+
# .val.data_buffer_idx, # pyright: ignore
880+
# 0,
881+
# )
882+
# self.assertEqual(
883+
# ep.executorch_program.execution_plan[0]
884+
# .values[149]
885+
# .val.allocation_info, # pyright: ignore
886+
# None,
887+
# )
886888

887889

888890
def _get_specs(gm: torch.fx.GraphModule) -> set[TensorSpec]:

0 commit comments

Comments
 (0)