|
|
import matplotlib.pyplot as plt |
|
|
import numpy as np |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
batch_sizes = [32, 64, 128] |
|
|
time_kernels = [11.9, 12.6, 16.6] |
|
|
time_no_kernels = [58.2, 113.5, 224.0] |
|
|
|
|
|
x = np.arange(len(batch_sizes)) |
|
|
width = 0.35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.figure(figsize=(10, 6)) |
|
|
|
|
|
bars1 = plt.bar( |
|
|
x - width / 2, |
|
|
time_kernels, |
|
|
width, |
|
|
label="Use kernels", |
|
|
color="#4C72B0" |
|
|
) |
|
|
|
|
|
bars2 = plt.bar( |
|
|
x + width / 2, |
|
|
time_no_kernels, |
|
|
width, |
|
|
label="No kernels", |
|
|
color="#DD8452" |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.title( |
|
|
"Generation Time Comparison for openai/gpt-oss-20b\n(256 tokens generated)", |
|
|
fontsize=14, |
|
|
weight="bold" |
|
|
) |
|
|
plt.xlabel("Batch size", fontsize=12) |
|
|
plt.ylabel("Time (seconds)", fontsize=12) |
|
|
|
|
|
plt.xticks(x, batch_sizes) |
|
|
plt.legend(fontsize=11) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.grid( |
|
|
axis="y", |
|
|
linestyle="--", |
|
|
linewidth=0.8, |
|
|
alpha=0.6 |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def annotate_bars(bars): |
|
|
for bar in bars: |
|
|
height = bar.get_height() |
|
|
plt.annotate( |
|
|
f"{height:.1f}s", |
|
|
xy=(bar.get_x() + bar.get_width() / 2, height), |
|
|
xytext=(0, 3), |
|
|
textcoords="offset points", |
|
|
ha="center", |
|
|
va="bottom", |
|
|
fontsize=10 |
|
|
) |
|
|
|
|
|
annotate_bars(bars1) |
|
|
annotate_bars(bars2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.tight_layout() |
|
|
plt.savefig("kernels.png") |
|
|
|