File size: 2,217 Bytes
d4184d4
 
 
58b66fd
d4184d4
58b66fd
d4184d4
58b66fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4184d4
 
58b66fd
 
 
 
d4184d4
 
58b66fd
 
 
 
d4184d4
 
58b66fd
 
d4184d4
 
 
 
 
 
 
 
 
 
 
58b66fd
 
d4184d4
 
 
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
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

sns.set(font_scale=1.1)

batch_sizes = {
    "fp16_4": {
       "A100": [4.75, 3.26, 3.24, 3.10],  # those values are made up
       "A10": [13.94, 9.81, 10.01, 9.35],
       "T4": [38.81, 30.09, 29.74, 27.55],
       "V100": [9.84, 8.16, 8.09, 7.65],
       "3090": [10.04, 7.82, 7.89, 7.47],
       "3090TI": [9.07, 7.14, 7.15, 6.81],
    },
    "fp16_16": {
       "A100": [18.95, 13.57, 13.67, 12.25],
       "A10": [0, 37.55, 38.31, 36.81],
       "T4": [0, 111.47, 113.26, 106.93],
       "V100": [0, 30.29, 29.84, 28.22],
       "3090": [0, 29.06, 29.06, 28.2],
       "3090TI": [0, 26.1, 26.28, 25.46],
    },
    "fp32_4": {
       "A100": [16.56, 12.42, 12.2, 11.84],
       "A10": [34.77, 27.63, 22.77, 22.07],
       "T4": [0, 85.72, 85.78, 84.48],
       "V100": [0, 25.73, 25.31, 24.7],
       "3090": [22.69, 21.45, 18.67, 18.09],
       "3090TI": [20.32, 19.31, 16.9, 16.37],
    },
    "fp32_16": {
       "A100": [0, 47.08, 46.27, 44.8],
       "A10": [0, 116.49, 88.56, 86.64],
       "T4": [0, 276.47, 280.26, 270.93],  # numbers are made up
       "V100": [0, 84.99, 84.73, 82.55],
       "3090": [0, 85.35, 72.37, 70.25],
       "3090TI": [0, 75.37, 65.25, 64.32],
    },
}

batch_size = 16
dtype = "fp32"

key = f"{dtype}_{batch_size}"

methods = {
    "Vanilla Attention": [x[0] for x in batch_sizes[key].values()],
    "xFormers": [x[1] for x in batch_sizes[key].values()],
    "PyTorch2.0 SDPA": [x[2] for x in batch_sizes[key].values()],
    "SDPA + torch.compile": [x[3] for x in batch_sizes[key].values()],
}

x = np.arange(len(batch_sizes[key]))  # the label locations
width = 0.1  # the width of the bars
multiplier = 0

fig, ax = plt.subplots(constrained_layout=True)

for attribute, measurement in methods.items():
    offset = width * multiplier
    rects = ax.bar(x + offset, measurement, width, label=attribute)
    multiplier += 1

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Time (s)')
ax.set_title(f'Inference Speed at Batch Size={batch_size} for {dtype}')
ax.set_xticks(x + width, batch_sizes[key])
ax.legend(loc='upper left')

plt.show()