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
20 changes: 13 additions & 7 deletions lightllm/common/basemodel/prefill_cuda_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ def __init__(self, decode_cuda_graph: CudaGraph, tp_world_size: int):
self.args = get_env_start_args()
self.enable_prefill_microbatch_overlap = self.args.enable_prefill_microbatch_overlap
self.max_handle_token_num = self.args.prefill_cudagraph_max_handle_token

graph_handle_token_nums = []
for i in range(2048):
token_num = int(2 ** (2 * i))
if 1 < token_num < self.max_handle_token_num:
graph_handle_token_nums.append(token_num)
if self.args.batch_max_tokens is not None:
self.max_handle_token_num = min(self.max_handle_token_num, self.args.batch_max_tokens)

graph_handle_token_nums = (
list(range(4, 33, 4))
+ list(range(48, 257, 16))
+ list(range(288, 513, 32))
+ list(range(576, 1024 + 1, 64))
+ list(range(1280, 4096 + 1, 256))
+ list(range(4608, self.max_handle_token_num + 1, 512))
)
graph_handle_token_nums = [e for e in graph_handle_token_nums if e <= self.max_handle_token_num]
graph_handle_token_nums.append(self.max_handle_token_num)

graph_handle_token_nums = list(set(graph_handle_token_nums))
graph_handle_token_nums = list(set[int](graph_handle_token_nums))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Using set[int](...) at runtime will raise a TypeError: 'types.GenericAlias' object is not callable in Python. Subscription of built-in types like set[...] is only for type annotations and cannot be instantiated directly. Use set(...) instead.

Suggested change
graph_handle_token_nums = list(set[int](graph_handle_token_nums))
graph_handle_token_nums = list(set(graph_handle_token_nums))

graph_handle_token_nums.sort()
if self.args.enable_tpsp_mix_mode:
graph_handle_token_nums = [
Expand Down
5 changes: 4 additions & 1 deletion lightllm/server/api_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ def make_argument_parser() -> argparse.ArgumentParser:
" currently only for llama and qwen model, not support ep moe model",
)
parser.add_argument(
"--prefill_cudagraph_max_handle_token", type=int, default=512, help="max handle token num for prefill cudagraph"
"--prefill_cudagraph_max_handle_token",
type=int,
default=8192,
help="max handle token num for prefill cudagraph",
)

parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion lightllm/server/core/objs/start_args_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class StartArgs:
enable_monitor_auth: bool = field(default=False)
disable_cudagraph: bool = field(default=False)
enable_prefill_cudagraph: bool = field(default=False)
prefill_cudagraph_max_handle_token: int = field(default=512)
prefill_cudagraph_max_handle_token: int = field(default=8192)
graph_max_batch_size: int = field(default=256)
graph_split_batch_size: int = field(default=32)
graph_grow_step_size: int = field(default=16)
Expand Down
Loading