Skip to content
Merged
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 lightllm/common/basemodel/cuda_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, max_batch_size=8, max_len_in_batch=8192):
graph_split_batch_size = self.args.graph_split_batch_size * (self.mtp_step + 1)
graph_grow_step_size = self.args.graph_grow_step_size * (self.mtp_step + 1)

batch_sizes = [i * (self.mtp_step + 1) for i in range(1, graph_split_batch_size + 1)]
batch_sizes = [i * (self.mtp_step + 1) for i in range(1, self.args.graph_split_batch_size + 1)]
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.

medium

While this line correctly fixes the bug, its logic can be expressed more directly and readably. You are generating a sequence of batch sizes that are multiples of (self.mtp_step + 1), up to graph_split_batch_size. This can be achieved more concisely using range() with a step. This approach also has the benefit of reusing the graph_split_batch_size variable defined on line 33, improving code clarity.

Suggested change
batch_sizes = [i * (self.mtp_step + 1) for i in range(1, self.args.graph_split_batch_size + 1)]
batch_sizes = list(range(self.mtp_step + 1, graph_split_batch_size + 1, self.mtp_step + 1))

for _batch_size in range(graph_split_batch_size + graph_grow_step_size, max_batch_size, graph_grow_step_size):
batch_sizes.append(_batch_size)

Expand Down
Loading