Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backends/arm/test/models/test_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
TosaPipelineBI,
TosaPipelineMI,
)

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.export_llama_lib import (
build_args_parser,
get_llama_model,
)

from executorch.extension.llm.export.config.llm_config import LlmConfig

input_t = Tuple[torch.Tensor]

# Add project dir to sys path to workaround importlib.import_module() conditions in model_factory.py
Expand Down
4 changes: 2 additions & 2 deletions examples/apple/mps/scripts/mps_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from executorch.devtools.bundled_program.serialize import (
serialize_from_bundled_program_to_flatbuffer,
)

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.exir import (
EdgeCompileConfig,
EdgeProgramManager,
Expand All @@ -31,6 +29,8 @@
from executorch.exir.capture._config import ExecutorchBackendConfig
from executorch.extension.export_util.utils import export_to_edge, save_pte_program

from executorch.extension.llm.export.config.llm_config import LlmConfig

from ....models import MODEL_NAME_TO_MODEL
from ....models.model_factory import EagerModelFactory

Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ runtime.python_library(
"//caffe2:torch",
"//executorch/examples/models:model_base",
"//executorch/examples/models/llama:llama_transformer",
"//executorch/examples/models/llama/config:llm_config",
"//executorch/extension/llm/export/config:llm_config",
"//executorch/examples/models:checkpoint",
],
)
Expand Down Expand Up @@ -150,7 +150,7 @@ runtime.python_library(
":source_transformation",
"//ai_codesign/gen_ai/fast_hadamard_transform:fast_hadamard_transform",
"//caffe2:torch",
"//executorch/examples/models/llama/config:llm_config",
"//executorch/extension/llm/export/config:llm_config",
"//executorch/backends/vulkan/_passes:vulkan_passes",
"//executorch/exir/passes:init_mutable_pass",
"//executorch/examples/models:model_base",
Expand Down
15 changes: 1 addition & 14 deletions examples/models/llama/config/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")

def define_common_targets():
runtime.python_library(
name = "llm_config",
srcs = [
"llm_config.py",
],
_is_external_target = True,
base_module = "executorch.examples.models.llama.config",
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
)

python_unittest(
name = "test_llm_config",
srcs = [
"test_llm_config.py",
],
deps = [
":llm_config",
"//executorch/extension/llm/export/config:llm_config",
],
)
2 changes: 1 addition & 1 deletion examples/models/llama/config/test_llm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import unittest

from executorch.examples.models.llama.config.llm_config import (
from executorch.extension.llm.export.config.llm_config import (
BackendConfig,
BaseConfig,
CoreMLComputeUnit,
Expand Down
6 changes: 3 additions & 3 deletions examples/models/llama/eval_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def gen_eval_wrapper(
"""
# If llm_config is not provided, convert args to llm_config
if llm_config is None:
from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.extension.llm.export.config.llm_config import LlmConfig

llm_config = LlmConfig.from_args(args)

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

llm_config = LlmConfig.from_args(args)

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

llm_config = LlmConfig.from_args(args)

Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama/export_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
from executorch.devtools.backend_debug import print_delegation_info

from executorch.devtools.etrecord import generate_etrecord as generate_etrecord_func

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.hf_download import (
download_and_convert_hf_checkpoint,
)
from executorch.exir.passes.init_mutable_pass import InitializedMutableBufferPass

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

from executorch.extension.llm.export.config.llm_config import LlmConfig

from executorch.extension.llm.export.partitioner_lib import (
get_coreml_partitioner,
get_mps_partitioner,
Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
get_checkpoint_dtype,
get_default_model_resource_dir,
)

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.llama_transformer import construct_transformer
from executorch.examples.models.llama.model_args import ModelArgs
from executorch.examples.models.llama.rope import Rope

from executorch.extension.llm.export.config.llm_config import LlmConfig
from torchao.utils import TorchAOBaseTensor

try:
Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama/runner/eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
from typing import Optional, Type

import torch

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.export_llama_lib import (
_prepare_for_llama_export,
build_args_parser as _build_args_parser,
)
from executorch.examples.models.llama.runner.generation import LlamaRunner
from executorch.extension.llm.export.builder import LLMEdgeManager

from executorch.extension.llm.export.config.llm_config import LlmConfig


class EagerLlamaRunner(LlamaRunner):
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama/tests/test_export_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import unittest

from executorch.devtools.backend_debug import get_delegation_info
from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.export_llama_lib import (
_export_llama,
build_args_parser,
)
from executorch.extension.llm.export.config.llm_config import LlmConfig

UNWANTED_OPS = [
"aten_permute_copy_default",
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama3_2_vision/runner/eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from typing import Optional

import torch
from executorch.examples.models.llama.config.llm_config import LlmConfig

from executorch.examples.models.llama.export_llama_lib import _prepare_for_llama_export
from executorch.examples.models.llama.runner.eager import execute_runner
from executorch.examples.models.llama3_2_vision.runner.generation import (
TorchTuneLlamaRunner,
)
from executorch.extension.llm.export import LLMEdgeManager
from executorch.extension.llm.export.config.llm_config import LlmConfig


class EagerLlamaRunner(TorchTuneLlamaRunner):
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llava/export_llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
get_symmetric_quantization_config,
XNNPACKQuantizer,
)
from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.export_llama_lib import (
get_quantizer_and_quant_params,
)
Expand Down Expand Up @@ -44,6 +43,7 @@
HintBasedSymShapeEvalPass,
)
from executorch.extension.llm.export.builder import DType, LLMEdgeManager
from executorch.extension.llm.export.config.llm_config import LlmConfig
from executorch.util.activation_memory_profiler import generate_memory_trace
from pytorch_tokenizers.llama2c import Llama2cTokenizer as Tokenizer
from torch.export import Dim
Expand Down
2 changes: 1 addition & 1 deletion extension/llm/export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Please refer to the docs for some of our example suported models ([Llama](https:

## Configuration Options

For a complete reference of all available configuration options, see the [LlmConfig class definition](../../../examples/models/llama/config/llm_config.py) which documents all supported parameters for base, model, export, quantization, backend, and debug configurations.
For a complete reference of all available configuration options, see the [LlmConfig class definition](config/llm_config.py) which documents all supported parameters for base, model, export, quantization, backend, and debug configurations.

## Further Reading

Expand Down
5 changes: 5 additions & 0 deletions extension/llm/export/config/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load(":targets.bzl", "define_common_targets")

oncall("executorch")

define_common_targets()
15 changes: 15 additions & 0 deletions extension/llm/export/config/targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.python_library(
name = "llm_config",
srcs = [
"llm_config.py",
],
_is_external_target = True,
base_module = "executorch.extension.llm.export.config",
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
)
4 changes: 2 additions & 2 deletions extension/llm/export/export_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
from typing import Any, List, Tuple

import hydra

from executorch.examples.models.llama.config.llm_config import LlmConfig
from executorch.examples.models.llama.export_llama_lib import export_llama

from executorch.extension.llm.export.config.llm_config import LlmConfig
from hydra.core.config_store import ConfigStore
from omegaconf import OmegaConf

Expand Down
Loading