Skip to content
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

update log #527

Merged
merged 1 commit into from
Sep 5, 2024
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
5 changes: 4 additions & 1 deletion lightllm/server/httpserver/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ async def generate(
is_first_token = False

yield sub_req_id, out_str, metadata, finish_status

# 如果有子请求完成,就更新计数
if finish_status.is_finished():
unfinished_count -= 1
Expand All @@ -209,6 +208,8 @@ async def generate(
mean_per_token_cost_time_ms = (total_cost_time_ms - first_token_cost_ms) / out_token_counter
x_request_id = request.headers.get("X-Request-Id", "")
x_session_id = request.headers.get("X-Session-Id", "")
prompt_cache_len = metadata.pop("prompt_cache_len", 0)
prompt_cache_ratio = prompt_cache_len / prompt_tokens
format_start_time = datetime.datetime.fromtimestamp(start_time).strftime("%Y-%m-%d %H:%M:%S")
logger.info(
f"X-Request-Id:{x_request_id} "
Expand All @@ -217,6 +218,8 @@ async def generate(
f"total_cost_time:{total_cost_time_ms}ms,out_token_counter:{out_token_counter} "
f"mean_per_token_cost_time: {mean_per_token_cost_time_ms}ms "
f"prompt_token_num:{prompt_tokens} "
f"prompt_cache_len:{prompt_cache_len} "
f"prompt_cache_ratio:{prompt_cache_ratio} "
)
self.metric_client.histogram_observe(
"lightllm_request_validation_duration", verify_time_end - verify_time_begin
Expand Down
1 change: 1 addition & 0 deletions lightllm/server/io_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, request_id, prompt_ids, sample_params: SamplingParams, multim
self.cur_kv_len = 0 # 当前已经占用掉 token 的 kv len 长度
self.cur_output_len = 0 # 当前已经生成token 长度
self.start_time = 0 # 请求开始时间
self.prompt_cache_len = 0 # cache 命中长度
return

def to_rpc_obj(self):
Expand Down
12 changes: 7 additions & 5 deletions lightllm/server/router/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ async def _init_batch(self, batch: Batch):
for req in batch.reqs:
prompt_cache_len = req.cur_kv_len
prompt_cache_ratio = req.cur_kv_len / req.input_len
req.prompt_cache_len = prompt_cache_len
self.metric_client.histogram_observe("lightllm_cache_length", prompt_cache_len)
self.metric_client.histogram_observe("lightllm_cache_ratio", prompt_cache_ratio)
logger.info(
f"lightllm_req_id:{req.request_id} "
f"prompt_cache_len:{prompt_cache_len} "
f"prompt_cache_ratio:{prompt_cache_ratio} "
)
# logger.info(
# f"lightllm_req_id:{req.request_id} "
# f"prompt_cache_len:{prompt_cache_len} "
# f"prompt_cache_ratio:{prompt_cache_ratio} "
# )
logger.debug(f"Init Batch: {batch.simple_log()} \n")
return

Expand Down Expand Up @@ -402,6 +403,7 @@ def _send_to_detokenization_proc(self, batch: Batch, req_ans):
req = batch.id_to_reqs[req_id]
for idx, (new_token_id, new_gen_metadata) in enumerate(token_info_list):
# req.finish_status 传输 value值 不传送对象,可以减少序列化对象的大小。
new_gen_metadata["prompt_cache_len"] = req.prompt_cache_len
if idx == len(token_info_list) - 1:
batch_out.reqs_infs.append((req_id, new_token_id, new_gen_metadata, req.finish_status.value))
else:
Expand Down
Loading