Skip to content

Commit 53dff25

Browse files
authored
Move LlmConfig to extension/llm
Differential Revision: D77338897 Pull Request resolved: #11872
1 parent 0fa73fd commit 53dff25

File tree

17 files changed

+43
-36
lines changed

17 files changed

+43
-36
lines changed

backends/arm/test/models/test_llama.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
TosaPipelineBI,
2323
TosaPipelineMI,
2424
)
25-
26-
from executorch.examples.models.llama.config.llm_config import LlmConfig
2725
from executorch.examples.models.llama.export_llama_lib import (
2826
build_args_parser,
2927
get_llama_model,
3028
)
3129

30+
from executorch.extension.llm.export.config.llm_config import LlmConfig
31+
3232
input_t = Tuple[torch.Tensor]
3333

3434
# Add project dir to sys path to workaround importlib.import_module() conditions in model_factory.py

examples/apple/mps/scripts/mps_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
from executorch.devtools.bundled_program.serialize import (
2020
serialize_from_bundled_program_to_flatbuffer,
2121
)
22-
23-
from executorch.examples.models.llama.config.llm_config import LlmConfig
2422
from executorch.exir import (
2523
EdgeCompileConfig,
2624
EdgeProgramManager,
@@ -31,6 +29,8 @@
3129
from executorch.exir.capture._config import ExecutorchBackendConfig
3230
from executorch.extension.export_util.utils import export_to_edge, save_pte_program
3331

32+
from executorch.extension.llm.export.config.llm_config import LlmConfig
33+
3434
from ....models import MODEL_NAME_TO_MODEL
3535
from ....models.model_factory import EagerModelFactory
3636

examples/models/llama/TARGETS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ runtime.python_library(
6767
"//caffe2:torch",
6868
"//executorch/examples/models:model_base",
6969
"//executorch/examples/models/llama:llama_transformer",
70-
"//executorch/examples/models/llama/config:llm_config",
70+
"//executorch/extension/llm/export/config:llm_config",
7171
"//executorch/examples/models:checkpoint",
7272
],
7373
)
@@ -150,7 +150,7 @@ runtime.python_library(
150150
":source_transformation",
151151
"//ai_codesign/gen_ai/fast_hadamard_transform:fast_hadamard_transform",
152152
"//caffe2:torch",
153-
"//executorch/examples/models/llama/config:llm_config",
153+
"//executorch/extension/llm/export/config:llm_config",
154154
"//executorch/backends/vulkan/_passes:vulkan_passes",
155155
"//executorch/exir/passes:init_mutable_pass",
156156
"//executorch/examples/models:model_base",

examples/models/llama/config/targets.bzl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
22
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
33

44
def define_common_targets():
5-
runtime.python_library(
6-
name = "llm_config",
7-
srcs = [
8-
"llm_config.py",
9-
],
10-
_is_external_target = True,
11-
base_module = "executorch.examples.models.llama.config",
12-
visibility = [
13-
"//executorch/...",
14-
"@EXECUTORCH_CLIENTS",
15-
],
16-
)
17-
185
python_unittest(
196
name = "test_llm_config",
207
srcs = [
218
"test_llm_config.py",
229
],
2310
deps = [
24-
":llm_config",
11+
"//executorch/extension/llm/export/config:llm_config",
2512
],
2613
)

examples/models/llama/config/test_llm_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import unittest
1010

11-
from executorch.examples.models.llama.config.llm_config import (
11+
from executorch.extension.llm.export.config.llm_config import (
1212
BackendConfig,
1313
BaseConfig,
1414
CoreMLComputeUnit,

examples/models/llama/eval_llama_lib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def gen_eval_wrapper(
175175
"""
176176
# If llm_config is not provided, convert args to llm_config
177177
if llm_config is None:
178-
from executorch.examples.models.llama.config.llm_config import LlmConfig
178+
from executorch.extension.llm.export.config.llm_config import LlmConfig
179179

180180
llm_config = LlmConfig.from_args(args)
181181

@@ -306,7 +306,7 @@ def eval_llama(
306306
args: argparse.ArgumentParser,
307307
) -> None:
308308
# Convert args to LlmConfig
309-
from executorch.examples.models.llama.config.llm_config import LlmConfig
309+
from executorch.extension.llm.export.config.llm_config import LlmConfig
310310

311311
llm_config = LlmConfig.from_args(args)
312312

@@ -340,7 +340,7 @@ def eval_llama_with_attention_sink(model_name: str, args: argparse.ArgumentParse
340340
This is mostly copied from https://github.com/mit-han-lab/streaming-llm/blob/main/examples/eval_long_ppl.py
341341
"""
342342
# Convert args to LlmConfig
343-
from executorch.examples.models.llama.config.llm_config import LlmConfig
343+
from executorch.extension.llm.export.config.llm_config import LlmConfig
344344

345345
llm_config = LlmConfig.from_args(args)
346346

examples/models/llama/export_llama_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
from executorch.devtools.backend_debug import print_delegation_info
2828

2929
from executorch.devtools.etrecord import generate_etrecord as generate_etrecord_func
30-
31-
from executorch.examples.models.llama.config.llm_config import LlmConfig
3230
from executorch.examples.models.llama.hf_download import (
3331
download_and_convert_hf_checkpoint,
3432
)
3533
from executorch.exir.passes.init_mutable_pass import InitializedMutableBufferPass
3634

3735
from executorch.extension.llm.export.builder import DType, LLMEdgeManager
3836

37+
from executorch.extension.llm.export.config.llm_config import LlmConfig
38+
3939
from executorch.extension.llm.export.partitioner_lib import (
4040
get_coreml_partitioner,
4141
get_mps_partitioner,

examples/models/llama/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
get_checkpoint_dtype,
1616
get_default_model_resource_dir,
1717
)
18-
19-
from executorch.examples.models.llama.config.llm_config import LlmConfig
2018
from executorch.examples.models.llama.llama_transformer import construct_transformer
2119
from executorch.examples.models.llama.model_args import ModelArgs
2220
from executorch.examples.models.llama.rope import Rope
21+
22+
from executorch.extension.llm.export.config.llm_config import LlmConfig
2323
from torchao.utils import TorchAOBaseTensor
2424

2525
try:

examples/models/llama/runner/eager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
from typing import Optional, Type
1010

1111
import torch
12-
13-
from executorch.examples.models.llama.config.llm_config import LlmConfig
1412
from executorch.examples.models.llama.export_llama_lib import (
1513
_prepare_for_llama_export,
1614
build_args_parser as _build_args_parser,
1715
)
1816
from executorch.examples.models.llama.runner.generation import LlamaRunner
1917
from executorch.extension.llm.export.builder import LLMEdgeManager
2018

19+
from executorch.extension.llm.export.config.llm_config import LlmConfig
20+
2121

2222
class EagerLlamaRunner(LlamaRunner):
2323
"""

examples/models/llama/tests/test_export_llama_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import unittest
88

99
from executorch.devtools.backend_debug import get_delegation_info
10-
from executorch.examples.models.llama.config.llm_config import LlmConfig
1110
from executorch.examples.models.llama.export_llama_lib import (
1211
_export_llama,
1312
build_args_parser,
1413
)
14+
from executorch.extension.llm.export.config.llm_config import LlmConfig
1515

1616
UNWANTED_OPS = [
1717
"aten_permute_copy_default",

0 commit comments

Comments
 (0)