patrickvonplaten commited on
Commit
d4184d4
1 Parent(s): 2f0087d
Files changed (1) hide show
  1. plot_bench.py +51 -0
plot_bench.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+
5
+ batch_size_4 = {
6
+ "A100": [4.75, 3.26, 3.24, 3.10], # those values are made up
7
+ "A10": [13.94, 9.81, 10.01, 9.35],
8
+ "T4": [38.81, 30.09, 29.74, 27.55],
9
+ "V100": [9.84, 8.16, 8.09, 7.65],
10
+ "3090": [10.04, 7.82, 7.89, 7.47],
11
+ "3090TI": [9.07, 7.14, 7.15, 6.81],
12
+ }
13
+
14
+ batch_size_16 = {
15
+ "A100": [18.95, 13.57, 13.67, 12.25],
16
+ "A10": [0, 37.55, 38.31, 36.81],
17
+ "T4": [0, 111.47, 113.26, 106.93],
18
+ "V100": [0, 30.29, 29.84, 28.22],
19
+ "3090": [0, 29.06, 29.06, 28.2],
20
+ "3090TI": [0, 26.1, 26.28, 25.46],
21
+ }
22
+
23
+ batch_sizes = batch_size_16
24
+
25
+ methods = {
26
+ "Vanilla Attention": [x[0] for x in batch_sizes.values()],
27
+ "xFormers": [x[1] for x in batch_sizes.values()],
28
+ "PyTorch2.0 SDPA": [x[2] for x in batch_sizes.values()],
29
+ "SDPA + torch.compile": [x[3] for x in batch_sizes.values()],
30
+ }
31
+
32
+ x = np.arange(len(batch_size_4)) # the label locations
33
+ width = 0.15 # the width of the bars
34
+ multiplier = 0
35
+
36
+ fig, ax = plt.subplots(constrained_layout=True)
37
+
38
+ for attribute, measurement in methods.items():
39
+ offset = width * multiplier
40
+ rects = ax.bar(x + offset, measurement, width, label=attribute)
41
+ ax.bar_label(rects, padding=3)
42
+ multiplier += 1
43
+
44
+ # Add some text for labels, title and custom x-axis tick labels, etc.
45
+ ax.set_ylabel('Time (s)')
46
+ ax.set_title('Inference Speed at Batch Size=4')
47
+ ax.set_xticks(x + width, batch_size_4)
48
+ ax.legend(loc='upper left')
49
+ ax.set_ylim(0, 250)
50
+
51
+ plt.show()