forked from guanbaoy/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterationParser.pl
More file actions
145 lines (134 loc) · 4.03 KB
/
iterationParser.pl
File metadata and controls
145 lines (134 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# my $inputFile = "vllm_server_log_scheinfo.log";
# my $model = "qwen2.5-32b";
#my $model = "llama3-70b";
my $inputFile = $ARGV[0];
my $model = $ARGV[1];
my $numGPUs = $ARGV[2];
my $weightBits = $ARGV[3];
print "inputFile: $inputFile\n";
print "model: $model\n";
my $cmdPrefix = "python ../llama3/main.py 1 -m $model -d bmg24 -g $numGPUs -w $weightBits -v \"0.3 0.8 0.7 0.85\" ";
# my $cmdPrefix = "python ../llama3/main.py 1 -m $model -d bmg24 -g $numGPUs -w $weightBits ";
my $iteration = 0;
my @projetedTimeData = ();
my @actualTimeData = ();
my @contextData = ();
my @tokenData = ();
my @cmdPrefixData = ();
sub findNext;
open FIN, $inputFile;
while (1)
{
my $requests = findNext "total_requests_num:\\s*\\d+";
if (!defined($requests))
{
last;
}
$requests =~ m/\d+$/;
$requests = $&;
#print "Request: $requests\n";
if ($requests > 0)
{
my $end = 0;
my @lengths = ();
my @contexts = ();
for (my $i = 0; $i < $requests; $i++)
{
my $requestID = findNext "request id:\\s*.+\$";
if (!defined($requestID))
{
$end = 1;
last;
}
$requestID =~ s/request id:\s*//g;
#print "RequestID: $requestID\n";
my $context = findNext "context_len:\\s*\\d+";
if (!defined($context))
{
$end = 1;
last;
}
$context =~ m/\d+$/;
$context = $&;
my $length = findNext "num_scheduled_token:\\s*\\d+";
if (!defined($length))
{
$end = 1;
last;
}
$length =~ m/\d+$/;
$length = $&;
push @contexts, $context;
push @lengths, $length;
}
if ($end == 1)
{
last;
}
my $actualTime = findNext "execution time:.+ms\$";
if (!defined($actualTime))
{
last;
}
$actualTime =~ s/execution time:\s*//g;
$actualTime =~ s/\s*ms//g;
$actualTime /= 1000;
push @actualTimeData, $actualTime;
my $contextStr = join " ", @contexts;
push @contextData, $contextStr;
my $lengthStr = join " ", @lengths;
push @tokenData, $lengthStr;
my $cmd = $cmdPrefix . "-c \"$contextStr\" -t \"$lengthStr\"";
push @cmdPrefixData, $cmd;
print STDERR "Calling $cmd\n";
my $result = `$cmd`;
my $projectedTime = "Not found";
my @lines = split /\n/, $result;
foreach my $tmpLine (@lines)
{
if ($tmpLine =~ m/total time:\s*[0-9\.]+/)
{
$projectedTime = $&;
$projectedTime =~ s/total time:\s*//;
}
}
print STDERR " Projected iteration time: $projectedTime\n";
push @projectedTimeData, $projectedTime;
$iteration++;
}
}
close FIN;
print STDOUT "Iteration,Efficiency,Projected,Actual,Context,Tokens,Command\n";
my $sumOfProjectedTime = 0;
my $sumOfActualTime = 0;
for (my $i = 0; $i < $iteration; $i++)
{
my $efficiency = $projectedTimeData[$i] / $actualTimeData[$i];
$sumOfProjectedTime += $projectedTimeData[$i];
$sumOfActualTime += $actualTimeData[$i];
print STDOUT "$i,$efficiency,$projectedTimeData[$i],$actualTimeData[$i],$contextData[$i],$tokenData[$i],$cmdPrefixData[$i]\n";
}
print STDOUT "==========================\n";
print STDOUT "Total,Efficiency,Projected,Actual\n";
my $overallEfficiency = $sumOfProjectedTime / $sumOfActualTime;
print STDOUT "$iteration,$overallEfficiency,$sumOfProjectedTime,$sumOfActualTime\n";
sub findNext
{
my $regex = $_[0];
#print "*************\nSearch for $regex\n";
while (1)
{
my $line = <FIN>;
if ($line eq "")
{
return undef;
}
chomp $line;
#print " Next line: $line\n";
if ($line =~ m/$regex/)
{
#print "Matched\n********************\n";
return $&;
}
}
}