Skip to content

Commit

Permalink
Move tokenizer.py to the folder of lmdeploy (#543)
Browse files Browse the repository at this point in the history
* move tokenizer

* remove Tokenizer in init

* update deploy.py
  • Loading branch information
q.yao authored Oct 16, 2023
1 parent f4422fa commit c261b49
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 29 deletions.
3 changes: 2 additions & 1 deletion benchmark/profile_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
nvmlInit, nvmlShutdown, nvmlSystemGetDriverVersion)
from tqdm import tqdm

from lmdeploy.turbomind import Tokenizer, TurboMind
from lmdeploy.tokenizer import Tokenizer
from lmdeploy.turbomind import TurboMind


def infer(model, session_id: int, input_ids: str, output_seqlen: int,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/profile_restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import requests

from lmdeploy.turbomind.tokenizer import Tokenizer
from lmdeploy.tokenizer import Tokenizer
from lmdeploy.utils import get_logger


Expand Down
2 changes: 1 addition & 1 deletion benchmark/profile_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

from lmdeploy.serve.turbomind.chatbot import Chatbot
from lmdeploy.turbomind.tokenizer import Tokenizer
from lmdeploy.tokenizer import Tokenizer


def infer(chatbot, session_id: int, req_que: mp.Queue, res_que: mp.Queue):
Expand Down
3 changes: 2 additions & 1 deletion benchmark/profile_throughput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import fire

from lmdeploy.turbomind import Tokenizer, TurboMind
from lmdeploy.tokenizer import Tokenizer
from lmdeploy.turbomind import TurboMind


def sample_requests(
Expand Down
2 changes: 1 addition & 1 deletion lmdeploy/serve/async_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AsyncEngine:

def __init__(self, model_path, instance_num=32, tp=1) -> None:
from lmdeploy import turbomind as tm
from lmdeploy.turbomind.tokenizer import Tokenizer
from lmdeploy.tokenizer import Tokenizer
tokenizer_model_path = osp.join(model_path, 'triton_models',
'tokenizer')
tokenizer = Tokenizer(tokenizer_model_path)
Expand Down
8 changes: 4 additions & 4 deletions lmdeploy/serve/turbomind/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def deploy_llama(model_name: str, model_path: str, tokenizer_path: str,
shutil.copy(tokenizer_path,
osp.join(triton_models_path, 'tokenizer/tokenizer.model'))
with get_package_root_path() as root_path:
shutil.copy(osp.join(root_path, 'turbomind/tokenizer.py'),
shutil.copy(osp.join(root_path, 'tokenizer.py'),
osp.join(triton_models_path, 'tokenizer'))
else:
print(f'tokenizer model {tokenizer_path} does not exist')
Expand Down Expand Up @@ -435,7 +435,7 @@ def deploy_hf(model_name: str, model_path: str, tokenizer_path: str,
shutil.copy(json_path,
osp.join(triton_models_path, 'tokenizer', _file))
with get_package_root_path() as root_path:
shutil.copy(osp.join(root_path, 'turbomind/tokenizer.py'),
shutil.copy(osp.join(root_path, 'tokenizer.py'),
osp.join(triton_models_path, 'tokenizer'))
else:
print(f'tokenizer model {tokenizer_path} does not exist')
Expand Down Expand Up @@ -601,7 +601,7 @@ def deploy_awq(model_name: str, model_path: str, tokenizer_path: str,
shutil.copy(json_path,
osp.join(triton_models_path, 'tokenizer', _file))
with get_package_root_path() as root_path:
shutil.copy(osp.join(root_path, 'turbomind/tokenizer.py'),
shutil.copy(osp.join(root_path, 'tokenizer.py'),
osp.join(triton_models_path, 'tokenizer'))
else:
print(f'tokenizer model {tokenizer_path} does not exist')
Expand Down Expand Up @@ -831,7 +831,7 @@ def deploy_qwen(model_name: str, model_path: str, tokenizer_path: str,
shutil.copy(json_path,
osp.join(triton_models_path, 'tokenizer', _file))
with get_package_root_path() as root_path:
shutil.copy(osp.join(root_path, 'turbomind/tokenizer.py'),
shutil.copy(osp.join(root_path, 'tokenizer.py'),
osp.join(triton_models_path, 'tokenizer'))
else:
print(f'tokenizer model {tokenizer_path} does not exist')
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions lmdeploy/turbomind/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .tokenizer import Tokenizer
from .turbomind import TurboMind

__all__ = ['Tokenizer', 'TurboMind']
__all__ = ['TurboMind']
2 changes: 1 addition & 1 deletion lmdeploy/turbomind/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from lmdeploy import turbomind as tm
from lmdeploy.model import MODELS
from lmdeploy.turbomind.tokenizer import Tokenizer
from lmdeploy.tokenizer import Tokenizer

os.environ['TM_LOG_LEVEL'] = 'ERROR'

Expand Down
2 changes: 1 addition & 1 deletion lmdeploy/turbomind/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch

from lmdeploy import turbomind as tm
from lmdeploy.turbomind.tokenizer import Tokenizer
from lmdeploy.tokenizer import Tokenizer

os.environ['TM_LOG_LEVEL'] = 'ERROR'

Expand Down
2 changes: 1 addition & 1 deletion lmdeploy/turbomind/turbomind.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import lmdeploy
from lmdeploy.model import MODELS
from lmdeploy.turbomind import Tokenizer
from lmdeploy.tokenizer import Tokenizer
from lmdeploy.utils import get_logger

# TODO: find another way import _turbomind
Expand Down
15 changes: 0 additions & 15 deletions tests/python/test_tokenizer.py

This file was deleted.

0 comments on commit c261b49

Please sign in to comment.