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: 2 additions & 0 deletions lightllm/server/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def init_metrics(self, args):
self.create_histogram("lightllm_cache_ratio", ratio_buckets)

mtp_avg_token_per_step_buckets = [i / 10.0 + 1.0 for i in range(0, 10 * args.mtp_step)]
if args.mtp_step == 0:
mtp_avg_token_per_step_buckets = [1.0, 2.0]
Comment on lines +99 to +100
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This correctly handles the case where args.mtp_step is 0. However, the current implementation first computes a list on line 98 (which will be empty if args.mtp_step is 0) and then immediately overwrites it. For better efficiency and readability, it would be preferable to use an if/else block to avoid the unnecessary computation.

You could refactor lines 98-100 like this:

        if args.mtp_step == 0:
            mtp_avg_token_per_step_buckets = [1.0, 2.0]
        else:
            mtp_avg_token_per_step_buckets = [i / 10.0 + 1.0 for i in range(0, 10 * args.mtp_step)]

This makes the logic more direct and avoids the redundant operation.

self.create_histogram("lightllm_request_mtp_avg_token_per_step", mtp_avg_token_per_step_buckets)

def create_histogram(self, name, buckets, labelnames=None):
Expand Down