Skip to content

Commit 45c28cd

Browse files
Kang-Mengliutongxuan
authored andcommitted
feat: fix rebase confict.
1 parent 1e2618f commit 45c28cd

File tree

9 files changed

+18
-80
lines changed

9 files changed

+18
-80
lines changed

xllm_service/chat_template/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ cc_library (
66
chat_template
77
HDRS
88
jinja_chat_template.h
9-
chat_template_factory.h
109
SRCS
1110
jinja_chat_template.cpp
12-
chat_template_factory.cpp
1311
DEPS
1412
:minja
1513
:tokenizer

xllm_service/chat_template/chat_template_factory.cpp

Lines changed: 0 additions & 50 deletions
This file was deleted.

xllm_service/chat_template/chat_template_factory.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

xllm_service/rpc_service/scheduler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <array>
55
#include <nlohmann/json.hpp>
66

7-
#include "chat_template/chat_template_factory.h"
7+
#include "chat_template/jinja_chat_template.h"
88
#include "common.pb.h"
99
#include "common/hash_util.h"
1010
#include "tokenizer/tokenizer_factory.h"
@@ -20,9 +20,9 @@ Scheduler::Scheduler(const RpcServiceConfig& rpc_config,
2020
: rpc_config_(rpc_config),
2121
model_config_(model_config),
2222
http_config_(http_config) {
23-
tokenizer_ = create_tokenizer(model_config_, &tokenizer_args_);
24-
chat_template_ =
25-
create_chat_template(model_config_.model_type, tokenizer_args_);
23+
tokenizer_ = TokenizerFactory::create_tokenizer(model_config_.tokenizer_path,
24+
&tokenizer_args_);
25+
chat_template_ = std::make_unique<JinjaChatTemplate>(tokenizer_args_);
2626

2727
etcd_client_ = std::make_shared<EtcdClient>(rpc_config_.etcd_addr);
2828

xllm_service/rpc_service/scheduler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <unordered_map>
88
#include <unordered_set>
99

10-
#include "chat_template/chat_template.h"
10+
#include "chat_template/jinja_chat_template.h"
1111
#include "common/hash_util.h"
1212
#include "common/macros.h"
1313
#include "common/types.h"
@@ -68,7 +68,7 @@ class Scheduler {
6868
HttpServiceConfig http_config_;
6969

7070
// chat template instance
71-
std::unique_ptr<ChatTemplate> chat_template_;
71+
std::unique_ptr<JinjaChatTemplate> chat_template_;
7272

7373
std::shared_ptr<EtcdClient> etcd_client_;
7474

xllm_service/tokenizer/tokenizer_args.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ std::optional<std::string> load_chat_template_file(const std::string& dir) {
2727
}
2828
} // namespace
2929

30-
bool load_tokenizer_args(const std::string& model_weights_path,
30+
void load_tokenizer_args(const std::string& model_weights_path,
3131
TokenizerArgs& tokenizer_args) {
3232
// tokenizer args from tokenizer_config.json
3333
JsonReader tokenizer_reader;
@@ -68,8 +68,6 @@ bool load_tokenizer_args(const std::string& model_weights_path,
6868
tokenizer_args.pad_token() = v.value();
6969
}
7070
}
71-
72-
return true;
7371
}
7472

7573
} // namespace xllm_service

xllm_service/tokenizer/tokenizer_args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ inline std::ostream& operator<<(std::ostream& os, const TokenizerArgs& args) {
9393
return os;
9494
}
9595

96-
bool load_tokenizer_args(const std::string& model_weights_path,
96+
void load_tokenizer_args(const std::string& model_weights_path,
9797
TokenizerArgs& tokenizer_args);
9898

9999
} // namespace xllm_service

xllm_service/tokenizer/tokenizer_factory.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,32 @@
22

33
#include <filesystem>
44

5+
#include "tokenizer_args.h"
6+
57
namespace xllm_service {
68

79
std::unique_ptr<Tokenizer> TokenizerFactory::create_tokenizer(
810
const std::string& model_weights_path,
9-
TokenizerArgs tokenizer_args) {
11+
TokenizerArgs* tokenizer_args) {
12+
load_tokenizer_args(model_weights_path, *tokenizer_args);
13+
1014
const std::string tokenizer_json_path =
1115
model_weights_path + "/tokenizer.json";
1216
if (std::filesystem::exists(tokenizer_json_path)) {
1317
// 1. fast tokenizer
1418
LOG(INFO) << "Create fast tokenizer.";
1519
return std::make_unique<FastTokenizer>(tokenizer_json_path);
16-
} else if (tokenizer_args.tokenizer_type() == "tiktoken" ||
17-
tokenizer_args.tokenizer_class() == "TikTokenTokenizer") {
20+
} else if (tokenizer_args->tokenizer_type() == "tiktoken" ||
21+
tokenizer_args->tokenizer_class() == "TikTokenTokenizer") {
1822
// 2. create tiktoken tokenizer
1923
LOG(INFO) << "Create Tiktoken tokenizer.";
2024
return std::make_unique<TiktokenTokenizer>(model_weights_path,
21-
tokenizer_args);
25+
*tokenizer_args);
2226
} else {
2327
// 3. create sentencepiece tokenizer
2428
LOG(INFO) << "Create SentencePiece tokenizer.";
2529
return std::make_unique<SentencePieceTokenizer>(model_weights_path,
26-
tokenizer_args);
30+
*tokenizer_args);
2731
}
2832
}
2933

xllm_service/tokenizer/tokenizer_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TokenizerFactory {
1111
public:
1212
static std::unique_ptr<Tokenizer> create_tokenizer(
1313
const std::string& model_weights_path,
14-
TokenizerArgs tokenizer_args);
14+
TokenizerArgs* tokenizer_args);
1515
};
1616

1717
} // namespace xllm_service

0 commit comments

Comments
 (0)