SPB Git

spb/wp28_uqo

Public
2.8 KB · 33 lines python
1#!/usr/bin/env python32"""Benchmark figures: (a) exchange rate — local phase vs synchronized rounds by protocol at p = 8 and p = 64 (16 hosts);3(b) hosts scaling of the (2,1) protocol at K = 16 workers.  Source: results/processed/benchmarks_summary.csv."""4import sys, pathlib5import numpy as np, pandas as pd6import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot as plt7sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "experiments")); from process_results import _setup, PAL, INK, INK2, FIG, PROC8_setup(); g = pd.read_csv(PROC / "benchmarks_summary.csv")9order8 = [("cmp_r4q0", "(4,0)"), ("cmp_r3q1", "(3,1)"), ("hosts16", "(2,1)"), ("cmp_r2q1_stale", "(2,1) stale"), ("cmp_r2q1_single", "(2,1) single"), ("cmp_r1q2", "(1,2)")]10order64 = [("cmp_p64_r2q1", "(2,1)"), ("cmp_p64_r2q1_stale", "(2,1) stale"), ("cmp_p64_r1q2", "(1,2)")]11fig, axes = plt.subplots(1, 3, figsize=(9.6, 3.0), gridspec_kw={"width_ratios": [2.2, 1.3, 1.6]})12for ax, order, title in zip(axes[:2], (order8, order64), ("p = 8, 16 hosts, K = 16", "p = 64, 16 hosts, K = 16")):13    labs, loc, rnd = [], [], []14    for key, lab in order:15        r = g[g.label == key]16        if r.empty:17            continue18        labs.append(lab); loc.append(float(r.t_local.iloc[0])); rnd.append(float(r.t_rounds.iloc[0]))19    x = np.arange(len(labs)); w = 0.6220    ax.bar(x, loc, w, color=PAL["blue"], label="local phase (slowest worker)", edgecolor="white", linewidth=1.5)21    ax.bar(x, rnd, w, bottom=loc, color=PAL["orange"], label="synchronized derivative phases", edgecolor="white", linewidth=1.5)22    for xi, (a, b) in enumerate(zip(loc, rnd)):23        ax.text(xi, a + b, f"{a + b:.2f} s", ha="center", va="bottom", fontsize=7, color=INK)24    ax.set_xticks(x); ax.set_xticklabels(labs, rotation=20, ha="right", fontsize=7.5); ax.set_ylabel("wall-clock (s)"); ax.set_title(title, fontsize=8, loc="left")25    ax.set_ylim(0, 1.18 * max(a + b for a, b in zip(loc, rnd)))26axes[0].legend(fontsize=7, loc="upper center", bbox_to_anchor=(0.5, -0.32), ncol=1)27ax = axes[2]; h = g[g.label.str.startswith("hosts")].sort_values("hosts")28ax.plot(h.hosts, h.t_local, marker="o", color=PAL["blue"], label="local phase", markerfacecolor="white", markeredgewidth=1.2)29ax.plot(h.hosts, h.fit_mean, marker="s", color=PAL["aqua"], ls="--", label="mean worker fit", markerfacecolor="white", markeredgewidth=1.2)30ax.plot(h.hosts, h.t_rounds, marker="^", color=PAL["orange"], label="derivative phase", markerfacecolor="white", markeredgewidth=1.2)31ax.set_xscale("log", base=2); ax.set_xticks([1, 2, 4, 8, 16]); ax.set_xticklabels(["1", "2", "4", "8", "16"]); ax.set_xlabel("hosts (K = 16 workers)"); ax.set_ylabel("seconds"); ax.set_title("(2,1), p = 8: host scaling", fontsize=8, loc="left"); ax.legend(fontsize=7)32FIG.mkdir(parents=True, exist_ok=True); fig.savefig(FIG / "fig_bench_exchange.pdf"); print("ok")33
Files · 960926063a6ca5ed53de00e9616d11db178d3b22
Menu

Theme