Sources of Randomness in APEBenchยค
This tutorial is work in progress
import apebench
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
advection_scenario = apebench.scenarios.difficulty.Advection(
optim_config="adam;1000;constant;3e-4",
record_loss_every=1,
)
data_run_0, nets_run_0 = advection_scenario()
data_run_1, nets_run_1 = advection_scenario()
loss_df_1 = apebench.melt_loss(data_run_0)
loss_df_2 = apebench.melt_loss(data_run_1)
loss_df_1["run"] = 0
loss_df_2["run"] = 1
loss_df = pd.concat([loss_df_1, loss_df_2])
sns.lineplot(data=loss_df, x="update_step", y="train_loss", hue="run")
plt.yscale("log")
plt.ylim(1e-5, 1e-4)
Activate Determinismยค
Rerun the notebook but starting with the cells below
import os
os.environ[
"XLA_FLAGS"
] = "--xla_gpu_deterministic_ops=true" # --xla_gpu_autotune_level=0"
# os.environ["TF_DETERMINISTIC_OPS"] = "1"
advection_scenario = apebench.scenarios.difficulty.Advection(
optim_config="adam;1000;constant;3e-4",
record_loss_every=1,
)
data_run_0_deterministic, nets_run_0_deterministic = advection_scenario()
data_run_1_deterministic, nets_run_1_deterministic = advection_scenario()
loss_df_1_deterministic = apebench.melt_loss(data_run_0_deterministic)
loss_df_2_deterministic = apebench.melt_loss(data_run_1_deterministic)
loss_df_1_deterministic["run"] = 0
loss_df_2_deterministic["run"] = 1
loss_df_deterministic = pd.concat([loss_df_1_deterministic, loss_df_2_deterministic])
sns.lineplot(data=loss_df_deterministic, x="update_step", y="train_loss", hue="run")
plt.yscale("log")
plt.ylim(1e-5, 1e-4)