Skip to content

Remove old tokenizer/ directory in ExecuTorch #9728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2025
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
2 changes: 1 addition & 1 deletion .ci/scripts/test_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ $PYTHON_EXECUTABLE -m examples.models.llama.export_llama ${EXPORT_ARGS}

# Create tokenizer.bin.
echo "Creating tokenizer.bin"
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin


RUNTIME_ARGS="--model_path=${EXPORTED_MODEL_NAME} --tokenizer_path=tokenizer.bin --prompt=Once --temperature=0 --seq_len=10 --warmup=1"
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_llama_torchao_lowbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cmake --build cmake-out/examples/models/llama -j16 --config Release
download_stories_model_artifacts

echo "Creating tokenizer.bin"
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin

# Export model
LLAMA_CHECKPOINT=stories110M.pt
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_phi_3_mini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cmake_build_phi_3_mini() {
prepare_tokenizer() {
echo "Downloading and converting tokenizer.model"
wget -O tokenizer.model "https://huggingface.co/microsoft/Phi-3-mini-128k-instruct/resolve/main/tokenizer.model?download=true"
$PYTHON_EXECUTABLE -m executorch.extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin
}

# Export phi-3-mini model to pte
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_qnn_static_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pip install graphviz
# Download stories llama110m artifacts
download_stories_model_artifacts
echo "Creating tokenizer.bin"
$PYTHON_EXECUTABLE -m extension.llm.tokenizer.tokenizer -t tokenizer.model -o tokenizer.bin
$PYTHON_EXECUTABLE -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin

set +e
# Compile only as weight sharing is not applicable on x86
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
endif()

if(EXECUTORCH_BUILD_EXTENSION_LLM)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/tokenizer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/tokenizers)
endif()

if(EXECUTORCH_BUILD_EXTENSION_MODULE)
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ runtime.python_library(
":export_library",
"//executorch/examples/models/llama/tokenizer:tiktoken_py",
"//executorch/extension/llm/export:export_lib",
"//executorch/extension/llm/tokenizer:tokenizer_py_lib",
"//pytorch/tokenizers/pytorch_tokenizers:tokenizers",
"//executorch/extension/pybindings:portable_lib",
],
)
Expand Down
8 changes: 3 additions & 5 deletions examples/models/llama/eval_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
from executorch.examples.models.llama.export_llama_lib import (
get_quantizer_and_quant_params,
)
from executorch.examples.models.llama.tokenizer.tiktoken import Tokenizer as Tiktoken

from executorch.extension.llm.export.builder import LLMEdgeManager
from executorch.extension.llm.tokenizer.tokenizer import (
Tokenizer as SentencePieceTokenizer,
)
from executorch.extension.llm.tokenizer.utils import get_tokenizer
from lm_eval.evaluator import simple_evaluate
from pytorch_tokenizers import get_tokenizer
from pytorch_tokenizers.llama2c import Llama2cTokenizer as SentencePieceTokenizer
from pytorch_tokenizers.tiktoken import TiktokenTokenizer as Tiktoken
from torch.nn import CrossEntropyLoss
from tqdm import tqdm

Expand Down
6 changes: 2 additions & 4 deletions examples/models/llama/evaluate/eager_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
from typing import Optional, Union

import torch
from executorch.examples.models.llama.tokenizer.tiktoken import Tokenizer as Tiktoken
from executorch.extension.llm.tokenizer.tokenizer import (
Tokenizer as SentencePieceTokenizer,
)

from lm_eval.models.huggingface import HFLM as eval_wrapper
from pytorch_tokenizers.llama2c import Llama2cTokenizer as SentencePieceTokenizer
from pytorch_tokenizers.tiktoken import TiktokenTokenizer as Tiktoken

from torch import nn

Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama/runner/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import torch

from executorch.extension.llm.tokenizer.utils import get_tokenizer
from pytorch_tokenizers import get_tokenizer


def sample_top_p(probs, p):
Expand Down
1 change: 0 additions & 1 deletion examples/models/llama/tokenizer/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def define_common_targets():
],
exported_deps = [
"//pytorch/tokenizers:tiktoken",
"//executorch/extension/llm/tokenizer:tiktoken", # TODO: remove
],
visibility = [
"@EXECUTORCH_CLIENTS",
Expand Down
10 changes: 5 additions & 5 deletions examples/models/llama/tokenizer/test/test_tiktoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <vector>

#include <executorch/extension/llm/tokenizer/tiktoken.h>
#include <pytorch/tokenizers/tiktoken.h>

#include <gtest/gtest.h>

Expand All @@ -21,9 +21,9 @@
using namespace ::testing;

using ::example::Version;
using ::executorch::extension::llm::Tokenizer;
using ::executorch::runtime::Error;
using ::executorch::runtime::Result;
using ::tokenizers::Error;
using ::tokenizers::Result;
using ::tokenizers::Tokenizer;

static std::string get_resource_path(const std::string& name) {
#ifdef EXECUTORCH_FB_BUCK
Expand All @@ -36,7 +36,7 @@ static std::string get_resource_path(const std::string& name) {
class MultimodalTiktokenV5ExtensionTest : public Test {
public:
void SetUp() override {
tokenizer_ = std::make_unique<executorch::extension::llm::Tiktoken>(
tokenizer_ = std::make_unique<tokenizers::Tiktoken>(
example::get_multimodal_special_tokens(), 0, 1);
modelPath_ = get_resource_path("test_tiktoken_tokenizer.model");
}
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 @@ -46,8 +46,8 @@
)

from executorch.extension.llm.export.builder import DType, LLMEdgeManager
from executorch.extension.llm.tokenizer.tokenizer import Tokenizer
from executorch.util.activation_memory_profiler import generate_memory_trace
from pytorch_tokenizers.llama2c import Llama2cTokenizer as Tokenizer
from torch.export import Dim
from torch.nn.attention import SDPBackend

Expand Down
4 changes: 2 additions & 2 deletions examples/qualcomm/oss_scripts/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree.

# model sharding with custom op
set(CUSTOM_OP_SRCS_FILE
set(CUSTOM_OP_SRCS_FILE
"${EXECUTORCH_SOURCE_DIR}/extension/llm/custom_ops/op_fallback.cpp"
)
add_library(custom_ops ${CUSTOM_OP_SRCS_FILE})
Expand Down Expand Up @@ -35,7 +35,7 @@ list(
list(
APPEND
_llama_runner__srcs
${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/tokenizer/tiktoken.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/tokenizers/src/tiktoken.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../../models/llama/tokenizer/llama_tiktoken.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion extension/llm/export/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ runtime.python_library(
"//executorch/exir:lib",
"//executorch/exir/backend:backend_details",
"//executorch/extension/export_util:export_util",
"//executorch/extension/llm/tokenizer:tokenizer_py_lib",
"//pytorch/tokenizers/pytorch_tokenizers:tokenizers",
],
)
2 changes: 1 addition & 1 deletion extension/llm/export/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from executorch.extension.export_util.utils import export_to_edge, save_pte_program

from executorch.extension.llm.export.export_passes import RemoveRedundantTransposes
from executorch.extension.llm.tokenizer.utils import get_tokenizer
from pytorch_tokenizers import get_tokenizer
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
from torch.ao.quantization.quantizer import Quantizer
from torch.ao.quantization.quantizer.composable_quantizer import ComposableQuantizer
Expand Down
62 changes: 0 additions & 62 deletions extension/llm/tokenizer/CMakeLists.txt

This file was deleted.

8 changes: 0 additions & 8 deletions extension/llm/tokenizer/TARGETS

This file was deleted.

Empty file.
Loading
Loading