Skip to content

Commit b4a6174

Browse files
author
ssjia
committed
Update
[ghstack-poisoned]
2 parents 8fb1164 + 6c74651 commit b4a6174

File tree

14 files changed

+503
-231
lines changed

14 files changed

+503
-231
lines changed

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

backends/vulkan/test/scripts/test_model.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ build_core_libraries_and_devtools() {
117117
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
118118
-DEXECUTORCH_BUILD_VULKAN=ON \
119119
-DEXECUTORCH_BUILD_XNNPACK=ON \
120-
-DEXECUTORCH_BUILD_TESTS=ON \
121120
-Bcmake-out && \
122121
cmake --build cmake-out -j64 --target install
123122

docs/source/llm/export-llm.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
Instead of needing to manually write code to call torch.export(), use ExecuTorch's assortment of lowering APIs, or even interact with TorchAO quantize_ APIs for quantization, we have provided an out of box experience which performantly exports a selection of supported models to ExecuTorch.
44

5+
## Prerequisites
6+
7+
The LLM export functionality requires the `pytorch_tokenizers` package. If you encounter a `ModuleNotFoundError: No module named 'pytorch_tokenizers'` error, install it from the ExecutorTorch source code:
8+
9+
```bash
10+
pip install -e ./extension/llm/tokenizers/
11+
```
12+
13+
## Supported Models
14+
515
As of this doc, the list of supported LLMs include the following:
616
- Llama 2/3/3.1/3.2
717
- Qwen 2.5/3

docs/source/using-executorch-faqs.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ sudo apt install python<version>-dev
1414
```
1515
if you are using Ubuntu, or use an equivalent install command.
1616

17+
### ModuleNotFoundError: No module named 'pytorch_tokenizers'
18+
19+
The `pytorch_tokenizers` package is required for LLM export functionality. Install it from the ExecutorTorch source code:
20+
```
21+
pip install -e ./extension/llm/tokenizers/
22+
```
23+
1724
## Export
1825

1926
### Missing out variants: { _ }

examples/vulkan/aot_compiler.py

Lines changed: 0 additions & 204 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
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+
9+
#include <executorch/kernels/portable/cpu/scalar_utils.h>
10+
#include <executorch/kernels/portable/cpu/util/copy_ops_util.h>
11+
#include <executorch/runtime/kernel/kernel_includes.h>
12+
13+
namespace torch {
14+
namespace executor {
15+
namespace native {
16+
17+
using Tensor = executorch::aten::Tensor;
18+
19+
template <typename T>
20+
using OptionalArrayRef = executorch::aten::OptionalArrayRef<T>;
21+
22+
/**
23+
* _clone_dim_order.out(Tensor self, *, bool non_blocking=False, int[]?
24+
* dim_order=None, Tensor(a!) out) -> Tensor(a!)
25+
*
26+
* Clones via element-wise copy while preserving dim_order.
27+
*/
28+
Tensor& _clone_dim_order_out(
29+
KernelRuntimeContext& ctx,
30+
const Tensor& self,
31+
bool non_blocking,
32+
OptionalArrayRef<int64_t> dim_order,
33+
Tensor& out) {
34+
(void)ctx;
35+
36+
// Ensure input and output dtype match.
37+
ET_KERNEL_CHECK(
38+
ctx, self.scalar_type() == out.scalar_type(), InvalidArgument, out);
39+
40+
// Ensure output has the same layout as input or matches dim_order.
41+
ET_KERNEL_CHECK(
42+
ctx,
43+
check__to_dim_order_copy_args(self, non_blocking, dim_order, out),
44+
InvalidArgument,
45+
out);
46+
47+
// Ensure input and output shapes match, resizing if necessary.
48+
ET_KERNEL_CHECK(
49+
ctx,
50+
resize_tensor(out, self.sizes()) == torch::executor::Error::Ok,
51+
InvalidArgument,
52+
out);
53+
54+
if (self.numel() == 0) {
55+
return out;
56+
}
57+
58+
// Select the correct input dtype and copy the tensors.
59+
ET_SWITCH_REALHBBF16_TYPES(
60+
self.scalar_type(),
61+
ctx,
62+
"dim_order_ops::_clone_dim_order.out",
63+
CTYPE,
64+
[&] { _to_dim_order_copy_impl<CTYPE, CTYPE>(self, out); });
65+
66+
return out;
67+
}
68+
69+
Tensor& _clone_dim_order_out(
70+
const Tensor& self,
71+
bool non_blocking,
72+
OptionalArrayRef<int64_t> dim_order,
73+
Tensor& out) {
74+
executorch::ET_RUNTIME_NAMESPACE::KernelRuntimeContext context{};
75+
return _clone_dim_order_out(context, self, non_blocking, dim_order, out);
76+
}
77+
78+
} // namespace native
79+
} // namespace executor
80+
} // namespace torch

kernels/portable/cpu/op__to_dim_order_copy.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,6 @@ using OptionalArrayRef = executorch::aten::OptionalArrayRef<T>;
2929
template <typename T>
3030
using Optional = std::optional<T>;
3131

32-
namespace {
33-
34-
template <typename SELF_CTYPE, typename OUT_CTYPE>
35-
void _to_dim_order_copy_impl(const Tensor& self, Tensor& out) {
36-
auto self_data = self.mutable_data_ptr<SELF_CTYPE>();
37-
auto out_data = out.mutable_data_ptr<OUT_CTYPE>();
38-
39-
// Here we make a slightly off-label use of
40-
// BroadcastIndexesRange. It always assumes it doesn't have to care
41-
// about different dim_order between input and output, but we can
42-
// just force it to respect strides (and thus dim_order) for its
43-
// inputs using support_noncontiguous_input_tensors=true, and then pretend
44-
// the output is just another input.
45-
for (const auto [unused_index, self_data_index, out_data_index] :
46-
BroadcastIndexesRange<2, /*support_noncontiguous_input_tensors=*/true>(
47-
/*dummy output*/ self, self, out)) {
48-
(void)unused_index;
49-
out_data[out_data_index] =
50-
static_cast<OUT_CTYPE>(self_data[self_data_index]);
51-
}
52-
}
53-
} // namespace
54-
5532
// _to_dim_order_copy.out(Tensor self, *, bool non_blocking=False, int[]?
5633
// dim_order=None, Tensor(a!) out) -> Tensor(a!)
5734
Tensor& _to_dim_order_copy_out(

0 commit comments

Comments
 (0)