mll-status 3.61 KB
Newer Older
liangjing's avatar
liangjing committed
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
#!/usr/bin/awk -f
BEGIN {
    OFS="\t"
    if (ARGV[1] == "--header") {
        print_header()
        ARGV[1]=""              # tell awk that '--header' isn't a file name
    }
}

function print_header() {
    print("file", "gpus", "batch", "total", "converge", "init", "epoch1", "epoch_avg", "[epoch", "eval_time", "mAP]*")
}


function get_mll_string_val(line, key) {
    myregex= "\"" key "\": \"([^\"]*)\""
    match(line, myregex, result_array)
    return result_array[1]
}

function get_mll_int_val(line, key) {
    myregex= "\"" key "\": ([0-9]*)"
    match(line, myregex, result_array)
    return result_array[1]
}

function get_mll_float_val(line, key) {
    myregex= "\"" key "\": ([0-9.e+-]*)"
    match(line, myregex, result_array)
    return result_array[1]
}

function get_mll_time(line) {
    return get_mll_int_val(line, "time_ms")/1000
}

function get_mll_epoch_num(line) {
    return get_mll_int_val(line, "epoch_num")
}

BEGINFILE {
    stop_status = "notdone"
    last_eval_epoch = -1
    run_start_time = 0
    run_stop_time = 0
    avg_epoch_time = -1
    init_time = -1
    training_time = 0
    last_eval_time = 0
    delete eval_time
    delete eval_acc
    delete time_at_epoch
    ranks = 0
    global_batch = -1
}

# make sure all the relevant lines have the fields in the positions we expect
# them (sometimes the parallel output causes multiple (or none) "0: " at the
# beginning instead of the single one expected, just make it none)
/:::MLL/ {
    sub(/^.*:::MLL/, ":::MLL")
}

/:::MLL.*"key": "init_start"/ {
    ranks = ranks+1
}

/:::MLL.*"key": "global_batch_size"/ {
    global_batch = get_mll_int_val($0, "value")
}

/:::MLL.*"key": "epoch_start"/ {
    epoch_num = get_mll_epoch_num($0)
    epoch_start_time = get_mll_time($0)
    time_at_epoch[epoch_num] = epoch_start_time
    if (epoch_num == 1) {
        init_time=epoch_start_time-run_start_time
    }
}

/:::MLL.*"key": "epoch_stop"/ {
    epoch_num = get_mll_epoch_num($0)
    current_time = get_mll_time($0)
    training_time = training_time + (current_time-time_at_epoch[epoch_num])
    if (epoch_num > 1 && epoch_num <= 39) {
        avg_epoch_time = (current_time - time_at_epoch[2])/(epoch_num-1)
    }
}

/:::MLL.*"key": "eval_start"/ {
    epoch_num = get_mll_epoch_num($0)
    current_time = get_mll_time($0)
    eval_time[epoch_num] = current_time
    last_eval_time = current_time
}

/:::MLL.*"key": "eval_accuracy"/ {
    eval_acc[get_mll_epoch_num($0)] = get_mll_float_val($0, "value")
}

/:::MLL.*"key": "eval_stop"/ {
    epoch_num = get_mll_epoch_num($0)
    eval_time[epoch_num] = get_mll_time($0) - eval_time[epoch_num]
    last_eval_epoch = epoch_num
}


/:::MLL.*"key": "run_start"/ {
    run_start_time=get_mll_time($0)
}

function printall(fname, total_time, last_eval_epoch, init_time, avg_epoch_time, eval_time, eval_acc) {
    if (ranks > 0) {
        local_batch=global_batch/ranks
    } else {
        local_batch = -1
    }
    printf("%s\t%d\t%d\t%.2f\t%s\t%.4f\t%.4f\t%.4f\t%.2f\t%.2f", fname, ranks, local_batch, total_time, last_eval_epoch, init_time, time_at_epoch[2]-time_at_epoch[1], avg_epoch_time, training_time, last_eval_time)
    for (i in eval_time) {
        printf("\t%d\t%.4f\t%.4f", i, eval_time[i], eval_acc[i])
    }
    printf("\n")
}

/:::MLL.*"key": "run_stop"/ {
    stop_status = get_mll_string_val($0, "status")
    run_stop_time = get_mll_time($0)
    if (last_eval_time > 0) {
        last_eval_time = run_stop_time-last_eval_time
    }
    if (stop_status == "success") {
        stop_status = last_eval_epoch
    }
}

ENDFILE {
    printall(FILENAME, run_stop_time-run_start_time, stop_status, init_time, avg_epoch_time, eval_time, eval_acc)
}