File size: 1,687 Bytes
49d3710 |
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 |
import matplotlib.pyplot as plt
import numpy as np
# -----------------------------
# Data
# -----------------------------
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
# -----------------------------
# Plot
# -----------------------------
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"
)
# -----------------------------
# Labels & title
# -----------------------------
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)
# -----------------------------
# Grid styling
# -----------------------------
plt.grid(
axis="y",
linestyle="--",
linewidth=0.8,
alpha=0.6
)
# -----------------------------
# Annotate bars
# -----------------------------
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)
# -----------------------------
# Layout
# -----------------------------
plt.tight_layout()
plt.savefig("kernels.png")
|