ariG23498 HF Staff commited on
Commit
91c8e18
·
verified ·
1 Parent(s): b9815de

Create loading-plot.py

Browse files
Files changed (1) hide show
  1. loading-plot.py +66 -0
loading-plot.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+
4
+ # Set up the figure and axis
5
+ fig, ax = plt.subplots(figsize=(12, 7))
6
+
7
+ # Define categories and data
8
+ categories = ['v4.57.6\ndevice_map=auto\nThreadpool',
9
+ 'v4.57.6\ndevice_map=auto\nNormal',
10
+ 'v4.57.6\nTP',
11
+ 'v5\ndevice_map=auto\nAsync',
12
+ 'v5\ndevice_map=auto\nSync',
13
+ 'v5\nTP\nAsync',
14
+ 'v5\nTP\nSync']
15
+
16
+ times = [66.24, 67.29, np.nan, 20.71, 45.3, 10.1, 19.28]
17
+ colors = ['#3498db', '#2980b9', '#e74c3c', '#2ecc71', '#27ae60', '#f39c12', '#e67e22']
18
+
19
+ # Create bar positions
20
+ x_pos = np.arange(len(categories))
21
+
22
+ # Create bars
23
+ bars = ax.bar(x_pos, times, color=colors, alpha=0.8, edgecolor='black', linewidth=1.2)
24
+
25
+ # Add value labels on top of bars
26
+ for i, (bar, time) in enumerate(zip(bars, times)):
27
+ if np.isnan(time):
28
+ # Mark OOM with text
29
+ ax.text(bar.get_x() + bar.get_width()/2, 5, 'OOM',
30
+ ha='center', va='bottom', fontsize=12, fontweight='bold', color='red')
31
+ else:
32
+ ax.text(bar.get_x() + bar.get_width()/2, time + 1.5, f'{time}s',
33
+ ha='center', va='bottom', fontsize=10, fontweight='bold')
34
+
35
+ # Customize the plot
36
+ ax.set_xlabel('Configuration', fontsize=12, fontweight='bold')
37
+ ax.set_ylabel('Loading Time (seconds)', fontsize=12, fontweight='bold')
38
+ ax.set_title('Model Loading Benchmark: Qwen/Qwen1.5-110B-Chat\nGPU: 1x A100 (80 GB)',
39
+ fontsize=14, fontweight='bold', pad=20)
40
+
41
+ ax.set_xticks(x_pos)
42
+ ax.set_xticklabels(categories, fontsize=9, ha='center')
43
+ ax.set_ylim(0, max([t for t in times if not np.isnan(t)]) * 1.15)
44
+
45
+ # Add grid for better readability
46
+ ax.yaxis.grid(True, linestyle='--', alpha=0.3)
47
+ ax.set_axisbelow(True)
48
+
49
+ # Add a note about the versions
50
+ # note_text = ('Transformers v4.57.6:\n'
51
+ # ' • Threadpool: HF_ENABLE_PARALLEL_LOADING\n'
52
+ # ' • Normal: no threadpool\n'
53
+ # '\n'
54
+ # 'Transformers v5:\n'
55
+ # ' • Async: default behavior\n'
56
+ # ' • Sync: HF_DEACTIVATE_ASYNC_LOAD')
57
+
58
+ # ax.text(1.02, 0.5, note_text, transform=ax.transAxes,
59
+ # fontsize=9, verticalalignment='center',
60
+ # bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.3))
61
+
62
+ plt.tight_layout()
63
+ plt.savefig('loading_benchmark.png', dpi=300, bbox_inches='tight')
64
+ plt.show()
65
+
66
+ print("Plot saved as 'loading_benchmark.png'")