diff --git a/hep_tfds b/hep_tfds index 6878e5e0b..88738ac97 160000 --- a/hep_tfds +++ b/hep_tfds @@ -1 +1 @@ -Subproject commit 6878e5e0b183384b80b7fec4bd5fb69f70cda38e +Subproject commit 88738ac97942dab4a192fdadd81eaf034aa22ed6 diff --git a/mlpf/data/prepare_args.py b/mlpf/data/prepare_args.py index df91ddcae..87f9cc243 100644 --- a/mlpf/data/prepare_args.py +++ b/mlpf/data/prepare_args.py @@ -5,15 +5,15 @@ outdir = "/hdfs/local/joosep/mlpf/gen" samples = [ "SinglePiFlatPt0p7To10_cfi", - #"SingleTauFlatPt2To150_cfi", - #"SingleMuFlatPt0p7To10_cfi", - #"SingleElectronFlatPt1To100_pythia8_cfi", - #"SingleGammaFlatPt10To100_pythia8_cfi", - #"SinglePi0E10_pythia8_cfi", + "SingleTauFlatPt2To150_cfi", + "SingleMuFlatPt0p7To10_cfi", + "SingleElectronFlatPt1To100_pythia8_cfi", + "SingleGammaFlatPt10To100_pythia8_cfi", + "SinglePi0E10_pythia8_cfi", ] samples_pu = [ - #"TTbar_14TeV_TuneCUETP8M1_cfi", + "TTbar_14TeV_TuneCUETP8M1_cfi", ] if __name__ == "__main__": @@ -24,11 +24,10 @@ os.makedirs(outdir + "/" + s + "/raw", exist_ok=True) os.makedirs(outdir + "/" + s + "/root", exist_ok=True) - #for iseed in range(1,51): - for iseed in range(51,2001): + for iseed in range(1,2001): if not os.path.isfile(outdir+"/"+s+"/raw/pfntuple_{}.pkl".format(iseed)): if is_pu: - print("sbatch genjob_tallinn_pu.sh {} {}".format(s, iseed)) + print("sbatch mlpf/tallinn/genjob_pu.sh {} {}".format(s, iseed)) else: - print("sbatch genjob_tallinn.sh {} {}".format(s, iseed)) + print("sbatch mlpf/tallinn/genjob.sh {} {}".format(s, iseed)) diff --git a/mlpf/data/pu_files.txt b/mlpf/data/pu_files.txt new file mode 100644 index 000000000..f8700a2d1 --- /dev/null +++ b/mlpf/data/pu_files.txt @@ -0,0 +1,6 @@ +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/932b9bde-6ae4-44cb-b1db-66dab83ab7d1.root +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/33b2fbd9-2544-44af-8652-c9a19edfa400.root +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/936b7b11-5eec-4f97-83ff-48be106b100d.root +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/f052be2f-f604-48e6-b484-1e412f0391f6.root +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/5ac1ea44-a5e0-4454-8945-45fd29c2947f.root +file:/scratch-persistent/joosep/store/relval/CMSSW_11_2_0_pre8/RelValMinBias_14TeV/GEN-SIM/112X_mcRun3_2021_realistic_v10-v1/00000/ae4379b2-d002-4adc-a168-e782ee296f91.root diff --git a/mlpf/tallinn/genjob.sh b/mlpf/tallinn/genjob.sh new file mode 100644 index 000000000..22fa3d581 --- /dev/null +++ b/mlpf/tallinn/genjob.sh @@ -0,0 +1,21 @@ +#!/bin/bash +#SBATCH -p main +#SBATCH --mem-per-cpu=4G +#SBATCH --cpus-per-task=1 + +env +df -h + +WORKDIR=/scratch/$USER/${SLURM_JOB_ID} +SAMPLE=$1 +SEED=$2 + +mkdir -p $WORKDIR +cd $WORKDIR + +/home/joosep/particleflow/mlpf/data/genjob.sh $SAMPLE $SEED + +cp $WORKDIR/$SAMPLE/$SEED/pfntuple_*.root /hdfs/local/joosep/mlpf/gen/$SAMPLE/root/ +cp $WORKDIR/$SAMPLE/$SEED/pfntuple_*.pkl /hdfs/local/joosep/mlpf/gen/$SAMPLE/raw/ + +rm -Rf $WORKDIR diff --git a/mlpf/tallinn/genjob_pu.sh b/mlpf/tallinn/genjob_pu.sh new file mode 100644 index 000000000..c60502ed0 --- /dev/null +++ b/mlpf/tallinn/genjob_pu.sh @@ -0,0 +1,21 @@ +#!/bin/bash +#SBATCH -p main +#SBATCH --mem-per-cpu=4G +#SBATCH --cpus-per-task=1 + +env +df -h + +WORKDIR=/scratch/$USER/${SLURM_JOB_ID} +SAMPLE=$1 +SEED=$2 + +mkdir -p $WORKDIR +cd $WORKDIR + +/home/joosep/particleflow/mlpf/data/genjob_pu.sh $SAMPLE $SEED + +cp $WORKDIR/$SAMPLE/$SEED/pfntuple_*.root /hdfs/local/joosep/mlpf/gen/$SAMPLE/root/ +cp $WORKDIR/$SAMPLE/$SEED/pfntuple_*.pkl /hdfs/local/joosep/mlpf/gen/$SAMPLE/raw/ + +rm -Rf $WORKDIR diff --git a/mlpf/tfmodel/model_setup.py b/mlpf/tfmodel/model_setup.py index 117b0c375..b5251a24c 100644 --- a/mlpf/tfmodel/model_setup.py +++ b/mlpf/tfmodel/model_setup.py @@ -391,7 +391,7 @@ def plot_eff_and_fake_rate( plt.xlabel(xlabel) plt.ylabel("Fraction of particles / bin") - image_path = str(cp_dir / "eff_fake_cls{}.png".format(icls)) + image_path = str(cp_dir / "eff_fake_cls{}_ivar{}.png".format(icls, ivar)) plt.savefig(image_path, bbox_inches="tight") plt.close("all") @@ -454,6 +454,7 @@ def on_epoch_end(self, epoch, logs=None): if icls!=0: self.plot_eff_and_fake_rate(epoch, icls, msk, ypred_id, cp_dir_cls) + self.plot_eff_and_fake_rate(epoch, icls, msk, ypred_id, cp_dir_cls, ivar=2, bins=np.linspace(-5,5,100)) for variable in ["pt", "eta", "sin_phi", "cos_phi", "energy"]: self.plot_reg_distribution(epoch, cp_dir_cls, ypred, ypred_id, icls, variable) diff --git a/mlpf/tfmodel/timing.py b/mlpf/tfmodel/timing.py index 149e300a8..eaebf425b 100644 --- a/mlpf/tfmodel/timing.py +++ b/mlpf/tfmodel/timing.py @@ -1,26 +1,38 @@ import numpy as np import time -import subprocess -import shlex +import pynvml #pip install only onnxruntime_gpu, not onnxruntime! import onnxruntime if __name__ == "__main__": - EP_list = ['CUDAExecutionProvider'] + pynvml.nvmlInit() + handle = pynvml.nvmlDeviceGetHandleByIndex(0) - nvidia_smi_call = "nvidia-smi --query-gpu=timestamp,name,pci.bus_id,pstate,power.draw,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used --format=csv -l 1 -f nvidia_smi_log.csv" - p = subprocess.Popen(shlex.split(nvidia_smi_call)) + EP_list = ['CUDAExecutionProvider'] time.sleep(5) + + mem = pynvml.nvmlDeviceGetMemoryInfo(handle) + mem_initial = mem.used/1000/1000 + print("mem_initial", mem_initial) + onnx_sess = onnxruntime.InferenceSession("model.onnx", providers=EP_list) + time.sleep(5) + + mem = pynvml.nvmlDeviceGetMemoryInfo(handle) + mem_onnx = mem.used/1000/1000 + print("mem_onnx", mem_initial) - for num_elems in [3200, 6400, 12800, 25600, 12800, 6400, 3200]: + for num_elems in range(1600, 25600, 320): times = [] - for i in range(250): + mem_used = [] + + #average over 100 events + for i in range(100): #allocate array in system RAM - X = np.array(np.random.randn(1, num_elems, 15), np.float32) + X = np.array(np.random.randn(1, num_elems, 18), np.float32) #transfer data to GPU, run model, transfer data back t0 = time.time() @@ -28,8 +40,8 @@ t1 = time.time() dt = t1 - t0 times.append(dt) + mem = pynvml.nvmlDeviceGetMemoryInfo(handle) + mem_used.append(mem.used/1000/1000) - print("Nelem={} mean_time={:.2f}ms stddev_time={:.2f} ms".format(num_elems, 1000.0*np.mean(times), 1000.0*np.std(times))) + print("Nelem={} mean_time={:.2f} ms stddev_time={:.2f} ms mem_used={:.0f} MB".format(num_elems, 1000.0*np.mean(times), 1000.0*np.std(times), np.max(mem_used))) time.sleep(5) - - p.terminate() \ No newline at end of file diff --git a/notebooks/cms-mlpf.ipynb b/notebooks/cms-mlpf.ipynb index ede718f36..1ab923415 100644 --- a/notebooks/cms-mlpf.ipynb +++ b/notebooks/cms-mlpf.ipynb @@ -104,7 +104,7 @@ "metadata": {}, "outputs": [], "source": [ - "path = \"../experiments/cms_20210907_200355_256734.gpu0.local/evaluation/\"" + "path = \"../experiments/cms_20210917_142344_403761.gpu0.local/evaluation/\"" ] }, { @@ -116,7 +116,7 @@ "source": [ "Xs = []\n", "yvals = {}\n", - "for fi in list(glob.glob(path + \"/pred_batch*.npz\"))[:100]:\n", + "for fi in list(glob.glob(path + \"/pred_batch*.npz\")):\n", " dd = np.load(fi)\n", " Xs.append(dd[\"X\"])\n", " \n", @@ -235,7 +235,7 @@ "outputs": [], "source": [ "plot_distribution(\"true\", np.linspace(-5,5,61), \"eta\", \"PF\", CLASS_NAMES_CMS[1:])\n", - "plt.ylim(top=1.2*1e6)" + "plt.ylim(top=4*1e5)" ] }, { @@ -246,7 +246,7 @@ "outputs": [], "source": [ "plot_distribution(\"pred\", np.linspace(-5,5,61), \"eta\", \"MLPF\", CLASS_NAMES_CMS[1:])\n", - "plt.ylim(top=1.2*1e6)" + "plt.ylim(top=4*1e5)" ] }, { @@ -312,7 +312,8 @@ " plt.xlabel(\"number of PFCandidates\")\n", " plt.ylabel(\"number of MLPFCandidates\")\n", " cms_label(x2=0.6, y=0.89)\n", - " plt.savefig(\"num_cls{}.pdf\".format(icls))\n" + " plt.savefig(\"num_cls{}.pdf\".format(icls), bbox_inches=\"tight\")\n", + " plt.savefig(\"num_cls{}.png\".format(icls), bbox_inches=\"tight\", dpi=300)\n" ] }, { @@ -351,6 +352,7 @@ "def plot_eff_and_fake_rate(\n", " icls,\n", " ivar=4,\n", + " ielem=1,\n", " bins=np.linspace(-3,6,100),\n", " xlabel=\"PFElement log[E/GeV]\", log=True\n", " ):\n", @@ -359,11 +361,11 @@ " if log:\n", " values = np.log(values)\n", " \n", - " hist_cand = np.histogram(values[(yvals_f[\"true_cls_id\"]==icls)], bins=bins);\n", - " hist_cand_true = np.histogram(values[(yvals_f[\"true_cls_id\"]==icls) & (yvals_f[\"pred_cls_id\"]==icls)], bins=bins);\n", + " hist_cand = np.histogram(values[(yvals_f[\"true_cls_id\"]==icls) & (X_f[:, 0]==ielem)], bins=bins);\n", + " hist_cand_true = np.histogram(values[(yvals_f[\"true_cls_id\"]==icls) & (yvals_f[\"pred_cls_id\"]==icls) & (X_f[:, 0]==ielem)], bins=bins);\n", "\n", - " hist_pred = np.histogram(values[(yvals_f[\"pred_cls_id\"]==icls)], bins=bins);\n", - " hist_pred_fake = np.histogram(values[(yvals_f[\"true_cls_id\"]!=icls) & (yvals_f[\"pred_cls_id\"]==icls)], bins=bins);\n", + " hist_pred = np.histogram(values[(yvals_f[\"pred_cls_id\"]==icls) & (X_f[:, 0]==ielem)], bins=bins);\n", + " hist_pred_fake = np.histogram(values[(yvals_f[\"true_cls_id\"]!=icls) & (yvals_f[\"pred_cls_id\"]==icls) & (X_f[:, 0]==ielem)], bins=bins);\n", "\n", " eff = hist_cand_true[0]/hist_cand[0]\n", " fake = hist_pred_fake[0]/hist_pred[0]\n", @@ -396,7 +398,9 @@ "source": [ "ax1, ax2 = plot_eff_and_fake_rate(1, bins=np.linspace(0, 300, 100), log=False)\n", "ax1.set_yscale(\"log\")\n", - "ax1.set_title(\"track, charged hadron predictions\")" + "ax1.set_title(\"track, charged hadron predictions\")\n", + "plt.savefig(\"trk_ch_had_eff_fake.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"trk_ch_had_eff_fake.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -406,31 +410,39 @@ "metadata": {}, "outputs": [], "source": [ - "ax1, ax2 = plot_eff_and_fake_rate(2, bins=np.linspace(0, 300, 100), log=False)\n", + "ax1, ax2 = plot_eff_and_fake_rate(2, ielem=5, bins=np.linspace(0, 300, 100), log=False)\n", "ax1.set_yscale(\"log\")\n", - "ax1.set_title(\"HCAL cluster, neutral hadron predictions\")" + "ax1.set_title(\"HCAL cluster, neutral hadron predictions\")\n", + "plt.savefig(\"hcal_n_had_eff_fake.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"hcal_n_had_eff_fake.png\", bbox_inches=\"tight\", dpi=300)" ] }, { "cell_type": "code", "execution_count": null, - "id": "characteristic-colleague", + "id": "810d7935", "metadata": {}, "outputs": [], "source": [ - "ax1, ax2 = plot_eff_and_fake_rate(3, bins=np.linspace(0, 300, 100), log=False)\n", - "ax1.set_yscale(\"log\")" + "ax1, ax2 = plot_eff_and_fake_rate(5, ielem=4, bins=np.linspace(0, 300, 21), log=False)\n", + "ax1.set_yscale(\"log\")\n", + "ax1.set_title(\"ECAL cluster, photon predictions\")\n", + "plt.savefig(\"ecal_photon_eff_fake.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"ecal_photon_eff_fake.png\", bbox_inches=\"tight\", dpi=300)" ] }, { "cell_type": "code", "execution_count": null, - "id": "composed-principal", + "id": "characteristic-colleague", "metadata": {}, "outputs": [], "source": [ - "ax1, ax2 = plot_eff_and_fake_rate(4, bins=np.linspace(0, 300, 100), log=False)\n", - "ax1.set_yscale(\"log\")" + "ax1, ax2 = plot_eff_and_fake_rate(6, ielem=6, bins=np.linspace(0, 300, 21), log=False)\n", + "ax1.set_yscale(\"log\")\n", + "ax1.set_title(\"GSF track, electron predictions\")\n", + "plt.savefig(\"gsf_electron_eff_fake.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"gsf_electron_eff_fake.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -503,7 +515,8 @@ "source": [ "p0 = loss_plot(history[\"loss\"].values, history[\"val_loss\"].values, margin=0.3)\n", "plt.ylabel(\"Total loss\")\n", - "plt.savefig(\"loss.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"loss.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"loss.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -513,9 +526,10 @@ "metadata": {}, "outputs": [], "source": [ - "p0 = loss_plot(history[\"cls_loss\"].values, history[\"val_cls_loss\"].values, margin=0.05)\n", + "p0 = loss_plot(history[\"cls_loss\"].values, history[\"val_cls_loss\"].values, margin=0.5)\n", "plt.ylabel(\"Multiclassification loss\")\n", - "plt.savefig(\"cls_loss.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"cls_loss.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"cls_loss.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -525,69 +539,12 @@ "metadata": {}, "outputs": [], "source": [ - "p0 = loss_plot(history[\"energy_loss\"].values, history[\"val_energy_loss\"].values, margin=0.01)\n", - "plt.ylabel(\"Energy loss\")\n", - "plt.savefig(\"energy_loss.pdf\", bbox_inches=\"tight\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "frank-alberta", - "metadata": {}, - "outputs": [], - "source": [ - "p0 = loss_plot(history[\"pt_loss\"].values, history[\"val_pt_loss\"].values, margin=0.02)\n", - "plt.ylabel(\"$p_T$ loss\")\n", - "plt.savefig(\"pt_loss.pdf\", bbox_inches=\"tight\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "significant-breeding", - "metadata": {}, - "outputs": [], - "source": [ - "p0 = loss_plot(history[\"sin_phi_loss\"].values, history[\"val_sin_phi_loss\"].values, margin=0.02)\n", - "plt.ylabel(\"$\\sin \\phi$ loss\")\n", - "plt.savefig(\"sin_phi_loss.pdf\", bbox_inches=\"tight\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "living-egyptian", - "metadata": {}, - "outputs": [], - "source": [ - "p0 = loss_plot(history[\"cos_phi_loss\"].values, history[\"val_cos_phi_loss\"].values, margin=0.01)\n", - "plt.ylabel(\"$\\cos \\phi$ loss\")\n", - "plt.savefig(\"cos_phi_loss.pdf\", bbox_inches=\"tight\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "healthy-willow", - "metadata": {}, - "outputs": [], - "source": [ - "p0 = loss_plot(history[\"eta_loss\"].values, history[\"val_eta_loss\"].values, margin=0.005)\n", - "plt.ylabel(\"$\\eta$ loss\")\n", - "plt.savefig(\"eta_loss.pdf\", bbox_inches=\"tight\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "accomplished-brave", - "metadata": {}, - "outputs": [], - "source": [ - "p0 = loss_plot(history[\"charge_loss\"].values, history[\"charge_loss\"].values, margin=0.005)\n", - "plt.ylabel(\"charge loss\")\n", - "plt.savefig(\"charge_loss.pdf\", bbox_inches=\"tight\")" + "reg_loss = sum([history[\"{}_loss\".format(l)].values for l in [\"energy\", \"pt\", \"eta\", \"sin_phi\", \"cos_phi\", \"charge\"]])\n", + "val_reg_loss = sum([history[\"val_{}_loss\".format(l)].values for l in [\"energy\", \"pt\", \"eta\", \"sin_phi\", \"cos_phi\", \"charge\"]])\n", + "p0 = loss_plot(reg_loss, val_reg_loss, margin=0.5)\n", + "plt.ylabel(\"Regression loss\")\n", + "plt.savefig(\"reg_loss.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"reg_loss.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -632,7 +589,8 @@ "plt.xlabel(\"Predicted PFCandidate\")\n", "plt.ylabel(\"True PFCandidate\")\n", "plt.title(\"MLPF trained on PF\", y=1.03)\n", - "plt.savefig(\"cm_normed.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"cm_normed.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"cm_normed.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -654,7 +612,8 @@ "plt.xlabel(\"Predicted PFCandidate\")\n", "plt.ylabel(\"True PFCandidate\")\n", "plt.title(\"MLPF trained on PF\", y=1.03)\n", - "plt.savefig(\"cm.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"cm.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"cm.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -683,7 +642,8 @@ " plt.xlabel(ivar)\n", " plt.ylabel(\"Number of particles / bin\")\n", " cms_label(x1=0.2, x2=0.6)\n", - " plt.savefig(\"distribution_icls{}_{}.pdf\".format(icls, ivar))" + " plt.savefig(\"distribution_icls{}_{}.pdf\".format(icls, ivar))\n", + " plt.savefig(\"distribution_icls{}_{}.png\".format(icls, ivar), dpi=300)" ] }, { @@ -740,7 +700,8 @@ "plot_particle_regression(ivar=\"energy\", icls=1, particle_label=\"Charged hadrons\")\n", "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", - "plt.savefig(\"energy_corr_cls1_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"energy_corr_cls1_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls1_log.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -753,7 +714,8 @@ "plot_particle_regression(ivar=\"energy\", icls=2, particle_label=\"Neutral hadrons\")\n", "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", - "plt.savefig(\"energy_corr_cls2_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"energy_corr_cls2_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls2_log.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -766,7 +728,8 @@ "plot_particle_regression(ivar=\"eta\", icls=1, particle_label=\"Charged hadrons\", log=False, minval=-4, maxval=4)\n", "plt.xlabel(\"PFCandidate $\\eta$\")\n", "plt.ylabel(\"MLPFCandidate $\\eta$\")\n", - "plt.savefig(\"eta_corr_cls1_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"eta_corr_cls1_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"eta_corr_cls1_log.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -779,7 +742,8 @@ "plot_particle_regression(ivar=\"eta\", icls=2, particle_label=\"Neutral hadrons\", log=False, minval=-4, maxval=4)\n", "plt.xlabel(\"PFCandidate $\\eta$\")\n", "plt.ylabel(\"MLPFCandidate $\\eta$\")\n", - "plt.savefig(\"eta_corr_cls2_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"eta_corr_cls2_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"eta_corr_cls2_log.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -792,7 +756,8 @@ "plot_particle_regression(ivar=\"energy\", icls=3, particle_label=\"HF\", minval=0.0, maxval=4)\n", "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", - "plt.savefig(\"energy_corr_cls3_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"energy_corr_cls3_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls3_log.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -805,7 +770,36 @@ "plot_particle_regression(ivar=\"energy\", icls=4, particle_label=\"HF\", minval=0.0, maxval=4)\n", "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", - "plt.savefig(\"energy_corr_cls4_log.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"energy_corr_cls4_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls4_log.png\", bbox_inches=\"tight\", dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eb29cd12", + "metadata": {}, + "outputs": [], + "source": [ + "plot_particle_regression(ivar=\"energy\", icls=5, particle_label=\"gamma\", minval=0.0, maxval=4)\n", + "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", + "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", + "plt.savefig(\"energy_corr_cls5_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls5_log.png\", bbox_inches=\"tight\", dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "56fc8943", + "metadata": {}, + "outputs": [], + "source": [ + "plot_particle_regression(ivar=\"energy\", icls=5, particle_label=\"gamma\", minval=0.0, maxval=4)\n", + "plt.xlabel(\"PFCandidate $\\log_{10}$ E/GeV\")\n", + "plt.ylabel(\"MLPFCandidate $\\log_{10}$ E/GeV\")\n", + "plt.savefig(\"energy_corr_cls5_log.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"energy_corr_cls5_log.png\", bbox_inches=\"tight\", dpi=300)" ] } ], diff --git a/notebooks/cmssw.ipynb b/notebooks/cmssw.ipynb index b762876a6..06b394476 100644 --- a/notebooks/cmssw.ipynb +++ b/notebooks/cmssw.ipynb @@ -12,9 +12,10 @@ "import mplhep\n", "import awkward\n", "import matplotlib.pyplot as plt\n", + "import matplotlib.patches as mpatches\n", "\n", "import uproot\n", - "import boost_histogram as bh" + "import boost_histogram as bh\n" ] }, { @@ -75,7 +76,7 @@ " \"qcd\": \"QCD\",\n", "}\n", "\n", - "def sample_label(ax, x=0.03, y=0.98, additional_text=\"\"):\n", + "def sample_label(ax, x=0.03, y=0.98, additional_text=\"\", physics_process=physics_process):\n", " plt.text(x, y,\n", " physics_process_str[physics_process]+additional_text,\n", " va=\"top\", ha=\"left\", size=10, transform=ax.transAxes)\n" @@ -167,6 +168,17 @@ " 13: \"purple\",\n", " 130: \"green\",\n", " 211: \"black\"\n", + "}\n", + "\n", + "particle_labels = {\n", + " 1: \"HFEM\",\n", + " 2: \"HFHAD\",\n", + " 11: \"$e^\\pm$\",\n", + " 22: \"$\\gamma$\",\n", + " 13: \"$\\mu$\",\n", + " 130: \"neutral hadron\",\n", + " 211: \"charged hadron\"\n", + " \n", "}" ] }, @@ -191,22 +203,26 @@ " pdgid_1 = np.abs(data_baseline[\"particleFlow\"][\"pdgId\"][iev])\n", " \n", " plt.figure(figsize=(5, 5))\n", + " ax = plt.axes()\n", " plt.scatter(eta_0, phi_0, marker=\".\", s=energy_0, c=[color_map[p] for p in pdgid_0], alpha=0.6)\n", - "# plt.scatter(\n", - "# data_mlpf[\"ak4PFJetsCHS\"][\"eta\"][iev],\n", - "# data_mlpf[\"ak4PFJetsCHS\"][\"phi\"][iev],\n", - "# s=data_mlpf[\"ak4PFJetsCHS\"][\"energy\"][iev], color=\"gray\", alpha=0.3\n", - "# )\n", + "\n", + " pids = [211,130,1,2,22,11,13]\n", + " for p in pids:\n", + " plt.plot([], [], color=color_map[p], lw=0, marker=\"o\", label=particle_labels[p])\n", + " plt.legend(loc=8, frameon=False, ncol=3, fontsize=8)\n", + "\n", " cms_label()\n", " sample_label(ax)\n", " plt.xlim(-6,6)\n", - " plt.ylim(-4,4)\n", + " plt.ylim(-5,4)\n", " plt.xlabel(\"PFCandidate $\\eta$\")\n", " plt.ylabel(\"PFCandidate $\\phi$\")\n", " plt.title(\"MLPF (trained on PF), CMSSW-ONNX inference\", y=1.05)\n", " plt.savefig(\"event_mlpf_{}_iev{}.pdf\".format(physics_process, iev), bbox_inches=\"tight\")\n", + " plt.savefig(\"event_mlpf_{}_iev{}.png\".format(physics_process, iev), bbox_inches=\"tight\", dpi=300)\n", " \n", " plt.figure(figsize=(5, 5))\n", + " ax = plt.axes()\n", " plt.scatter(eta_1, phi_1, marker=\".\", s=energy_1, c=[color_map[p] for p in pdgid_1], alpha=0.6)\n", "# plt.scatter(\n", "# data_baseline[\"ak4PFJetsCHS\"][\"eta\"][iev],\n", @@ -216,18 +232,27 @@ " cms_label()\n", " sample_label(ax)\n", " plt.xlim(-6,6)\n", - " plt.ylim(-4,4)\n", + " plt.ylim(-5,4)\n", " plt.xlabel(\"PFCandidate $\\eta$\")\n", " plt.ylabel(\"PFCandidate $\\phi$\")\n", " plt.title(\"Standard PF, CMSSW\", y=1.05)\n", - " plt.savefig(\"event_pf_{}_iev{}.pdf\".format(physics_process, iev), bbox_inches=\"tight\")" + " \n", + " pids = [211,130,1,2,22,11,13]\n", + " for p in pids:\n", + " plt.plot([], [], color=color_map[p], lw=0, marker=\"o\", label=particle_labels[p])\n", + " plt.legend(loc=8, frameon=False, ncol=3, fontsize=8)\n", + " \n", + " plt.savefig(\"event_pf_{}_iev{}.pdf\".format(physics_process, iev), bbox_inches=\"tight\")\n", + " plt.savefig(\"event_pf_{}_iev{}.png\".format(physics_process, iev), bbox_inches=\"tight\", dpi=300)" ] }, { "cell_type": "code", "execution_count": null, "id": "comfortable-albert", - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "draw_event(0)" @@ -255,20 +280,6 @@ "draw_event(2)" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "b0b8b3b4", - "metadata": { - "scrolled": false - }, - "outputs": [], - "source": [ - "for k in fi1.keys():\n", - " if \"DQMData/Run 1/JetMET/Run summary/Jet\" in k:\n", - " print(k)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -276,11 +287,6 @@ "metadata": {}, "outputs": [], "source": [ - "#k = \"DQMData/Run 1/ParticleFlow/Run summary/PFJetValidation/CompWithGenJet/average_delta_et_Over_et_VS_et_\"\n", - "#k = \"DQMData/Run 1/ParticleFlow/Run summary/PFMETValidation/CompWithGenMET/pt_\"\n", - "#k = \"DQMData/Run 1/ParticleFlow/Run summary/PFJetValidation/CompWithGenJet/mean_delta_et_Over_et_VS_et_\"\n", - "k = \"DQMData/Run 1/ParticleFlow/Run summary/PackedCandidates/HF_hadron/HF_hadronLog10Pt\"\n", - "\n", "def plot_dqm(key, title, rebin=None):\n", " h1 = fi1.get(key).to_boost()\n", " h2 = fi2.get(key).to_boost()\n", @@ -295,7 +301,7 @@ " mplhep.histplot(h2, yerr=0, label=\"MLPF\");\n", " plt.legend(frameon=False)\n", " plt.ylabel(\"Number of particles / bin\")\n", - " sample_label(ax=ax1, additional_text=\", \"+title)\n", + " sample_label(ax=ax1, additional_text=\", \"+title, physics_process=physics_process)\n", "\n", " plt.sca(ax2)\n", " ratio_hist = h2/h1\n", @@ -322,6 +328,10 @@ " \n", " (\"DQMData/Run 1/ParticleFlow/Run summary/PackedCandidates/neutralHadron/neutralHadronLog10Pt\",\n", " \"n.had.\", log10_pt, \"n_had_logpt\"),\n", + " (\"DQMData/Run 1/ParticleFlow/Run summary/PackedCandidates/neutralHadron/neutralHadronPtLow\",\n", + " \"n.had.\", \"$p_T$ [GeV]\", \"n_had_ptlow\"),\n", + " (\"DQMData/Run 1/ParticleFlow/Run summary/PackedCandidates/neutralHadron/neutralHadronPtMid\",\n", + " \"n.had.\", \"$p_T$ [GeV]\", \"n_had_ptmid\"),\n", " (\"DQMData/Run 1/ParticleFlow/Run summary/PackedCandidates/neutralHadron/neutralHadronEta\",\n", " \"n.had.\", eta, \"n_had_eta\"),\n", " \n", @@ -371,7 +381,8 @@ " rh = plot_dqm(key, title)\n", " plt.xlabel(xlabel)\n", " cms_label()\n", - " plt.savefig(\"dqm_{}.pdf\".format(plot_label), bbox_inches=\"tight\")" + " plt.savefig(\"dqm_{}_{}.pdf\".format(plot_label, physics_process), bbox_inches=\"tight\")\n", + " plt.savefig(\"dqm_{}_{}.png\".format(plot_label, physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -387,11 +398,12 @@ "#plt.xscale(\"log\")\n", "#plt.ylim(bottom=1, top=1e4)\n", "ax1.set_yscale(\"log\")\n", - "ax1.set_ylim(bottom=1, top=1e3)\n", - "ax2.set_ylim(0,5)\n", + "ax1.set_ylim(bottom=1, top=1e5)\n", + "#ax2.set_ylim(0,5)\n", "\n", "cms_label()\n", - "plt.savefig(\"dqm_jet_pt.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"dqm_jet_pt_{}.pdf\".format(physics_process), bbox_inches=\"tight\")\n", + "plt.savefig(\"dqm_jet_pt_{}.png\".format(physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -407,11 +419,12 @@ "#plt.xscale(\"log\")\n", "#plt.ylim(bottom=1, top=1e4)\n", "ax1.set_yscale(\"log\")\n", - "ax1.set_ylim(bottom=1, top=1e3)\n", - "ax2.set_ylim(0,5)\n", + "ax1.set_ylim(bottom=1, top=1e5)\n", + "#ax2.set_ylim(0,5)\n", "\n", "cms_label()\n", - "plt.savefig(\"dqm_jet_pt_puppi.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"dqm_jet_pt_puppi_{}.pdf\".format(physics_process), bbox_inches=\"tight\")\n", + "plt.savefig(\"dqm_jet_pt_puppi_{}.png\".format(physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -427,11 +440,12 @@ "#plt.xscale(\"log\")\n", "#plt.ylim(bottom=1, top=1e4)\n", "#ax1.set_yscale(\"log\")\n", - "#ax1.set_ylim(bottom=0, top=20)\n", - "ax2.set_ylim(0,5)\n", + "ax1.set_ylim(bottom=0, top=1e3)\n", + "#ax2.set_ylim(0,5)\n", "\n", "cms_label()\n", - "plt.savefig(\"dqm_jet_eta.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"dqm_jet_eta_{}.pdf\".format(physics_process), bbox_inches=\"tight\")\n", + "plt.savefig(\"dqm_jet_eta_{}.png\".format(physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -447,11 +461,12 @@ "#plt.xscale(\"log\")\n", "#plt.ylim(bottom=1, top=1e4)\n", "#ax1.set_yscale(\"log\")\n", - "ax1.set_ylim(bottom=0, top=20)\n", - "ax2.set_ylim(0,5)\n", + "#ax1.set_ylim(bottom=0, top=20)\n", + "#ax2.set_ylim(0,5)\n", "\n", "cms_label()\n", - "plt.savefig(\"dqm_jet_eta_puppi.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"dqm_jet_eta_puppi_{}.pdf\".format(physics_process), bbox_inches=\"tight\")\n", + "plt.savefig(\"dqm_jet_eta_puppi_{}.png\".format(physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -497,9 +512,10 @@ "ax2.set_xlabel(\"$\\sum E_t$ [GeV]\")\n", "ax1.set_ylabel(\"number of events / bin\")\n", "#ax1.set_xscale(\"log\")\n", - "ax1.set_ylim(bottom=1, top=100)\n", + "ax1.set_ylim(bottom=1, top=1000)\n", "ax1.set_yscale(\"log\")\n", - "plt.savefig(\"dqm_met_sumet.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"dqm_met_sumet_{}.pdf\".format(physics_process), bbox_inches=\"tight\")\n", + "plt.savefig(\"dqm_met_sumet_{}.png\".format(physics_process), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -534,12 +550,194 @@ "# plt.savefig(\"dqm_met_delta_et_VS_et.pdf\", bbox_inches=\"tight\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "1d5a2b79", + "metadata": {}, + "outputs": [], + "source": [ + "timing_output = \"\"\"\n", + "Nelem=1600 mean_time=5.92 ms stddev_time=5.03 ms mem_used=1018 MB\n", + "Nelem=1920 mean_time=6.57 ms stddev_time=1.01 ms mem_used=1110 MB\n", + "Nelem=2240 mean_time=6.92 ms stddev_time=0.81 ms mem_used=1127 MB\n", + "Nelem=2560 mean_time=7.37 ms stddev_time=0.66 ms mem_used=1136 MB\n", + "Nelem=2880 mean_time=8.17 ms stddev_time=0.56 ms mem_used=1123 MB\n", + "Nelem=3200 mean_time=8.88 ms stddev_time=1.09 ms mem_used=1121 MB\n", + "Nelem=3520 mean_time=9.51 ms stddev_time=0.65 ms mem_used=1121 MB\n", + "Nelem=3840 mean_time=10.48 ms stddev_time=0.93 ms mem_used=1255 MB\n", + "Nelem=4160 mean_time=11.05 ms stddev_time=0.87 ms mem_used=1255 MB\n", + "Nelem=4480 mean_time=12.07 ms stddev_time=0.81 ms mem_used=1230 MB\n", + "Nelem=4800 mean_time=12.92 ms stddev_time=0.89 ms mem_used=1230 MB\n", + "Nelem=5120 mean_time=13.44 ms stddev_time=0.75 ms mem_used=1230 MB\n", + "Nelem=5440 mean_time=14.07 ms stddev_time=0.78 ms mem_used=1230 MB\n", + "Nelem=5760 mean_time=15.00 ms stddev_time=0.84 ms mem_used=1230 MB\n", + "Nelem=6080 mean_time=15.74 ms stddev_time=1.05 ms mem_used=1230 MB\n", + "Nelem=6400 mean_time=16.32 ms stddev_time=1.30 ms mem_used=1230 MB\n", + "Nelem=6720 mean_time=17.24 ms stddev_time=0.99 ms mem_used=1230 MB\n", + "Nelem=7040 mean_time=17.74 ms stddev_time=0.85 ms mem_used=1230 MB\n", + "Nelem=7360 mean_time=18.59 ms stddev_time=1.04 ms mem_used=1230 MB\n", + "Nelem=7680 mean_time=19.33 ms stddev_time=0.93 ms mem_used=1499 MB\n", + "Nelem=8000 mean_time=20.00 ms stddev_time=1.06 ms mem_used=1499 MB\n", + "Nelem=8320 mean_time=20.55 ms stddev_time=1.13 ms mem_used=1499 MB\n", + "Nelem=8640 mean_time=21.10 ms stddev_time=0.90 ms mem_used=1499 MB\n", + "Nelem=8960 mean_time=22.88 ms stddev_time=1.24 ms mem_used=1499 MB\n", + "Nelem=9280 mean_time=23.44 ms stddev_time=1.14 ms mem_used=1499 MB\n", + "Nelem=9600 mean_time=23.93 ms stddev_time=1.04 ms mem_used=1499 MB\n", + "Nelem=9920 mean_time=24.75 ms stddev_time=0.91 ms mem_used=1499 MB\n", + "Nelem=10240 mean_time=25.47 ms stddev_time=1.33 ms mem_used=1499 MB\n", + "Nelem=10560 mean_time=26.29 ms stddev_time=1.33 ms mem_used=1499 MB\n", + "Nelem=10880 mean_time=26.72 ms stddev_time=1.18 ms mem_used=1490 MB\n", + "Nelem=11200 mean_time=29.50 ms stddev_time=2.60 ms mem_used=1502 MB\n", + "Nelem=11520 mean_time=28.50 ms stddev_time=0.91 ms mem_used=1491 MB\n", + "Nelem=11840 mean_time=29.11 ms stddev_time=1.14 ms mem_used=1491 MB\n", + "Nelem=12160 mean_time=30.01 ms stddev_time=1.15 ms mem_used=1499 MB\n", + "Nelem=12480 mean_time=30.55 ms stddev_time=0.94 ms mem_used=1499 MB\n", + "Nelem=12800 mean_time=31.31 ms stddev_time=1.08 ms mem_used=1499 MB\n", + "Nelem=13120 mean_time=32.61 ms stddev_time=1.19 ms mem_used=1499 MB\n", + "Nelem=13440 mean_time=33.37 ms stddev_time=1.01 ms mem_used=1499 MB\n", + "Nelem=13760 mean_time=34.13 ms stddev_time=1.18 ms mem_used=1499 MB\n", + "Nelem=14080 mean_time=34.73 ms stddev_time=1.40 ms mem_used=1499 MB\n", + "Nelem=14400 mean_time=35.79 ms stddev_time=1.70 ms mem_used=2036 MB\n", + "Nelem=14720 mean_time=36.68 ms stddev_time=1.37 ms mem_used=2036 MB\n", + "Nelem=15040 mean_time=37.17 ms stddev_time=0.97 ms mem_used=2036 MB\n", + "Nelem=15360 mean_time=38.73 ms stddev_time=1.19 ms mem_used=2036 MB\n", + "Nelem=15680 mean_time=39.80 ms stddev_time=1.04 ms mem_used=2036 MB\n", + "Nelem=16000 mean_time=40.87 ms stddev_time=1.46 ms mem_used=1996 MB\n", + "Nelem=16320 mean_time=41.89 ms stddev_time=1.01 ms mem_used=1996 MB\n", + "Nelem=16640 mean_time=43.36 ms stddev_time=1.08 ms mem_used=1996 MB\n", + "Nelem=16960 mean_time=44.87 ms stddev_time=1.35 ms mem_used=1996 MB\n", + "Nelem=17280 mean_time=46.04 ms stddev_time=0.96 ms mem_used=1996 MB\n", + "Nelem=17600 mean_time=47.96 ms stddev_time=1.47 ms mem_used=1996 MB\n", + "Nelem=17920 mean_time=49.01 ms stddev_time=1.35 ms mem_used=1996 MB\n", + "Nelem=18240 mean_time=50.04 ms stddev_time=1.34 ms mem_used=1956 MB\n", + "Nelem=18560 mean_time=51.34 ms stddev_time=1.49 ms mem_used=1956 MB\n", + "Nelem=18880 mean_time=52.16 ms stddev_time=1.20 ms mem_used=1956 MB\n", + "Nelem=19200 mean_time=53.19 ms stddev_time=1.20 ms mem_used=1956 MB\n", + "Nelem=19520 mean_time=54.03 ms stddev_time=0.96 ms mem_used=1956 MB\n", + "Nelem=19840 mean_time=55.68 ms stddev_time=1.05 ms mem_used=1956 MB\n", + "Nelem=20160 mean_time=56.88 ms stddev_time=1.12 ms mem_used=1956 MB\n", + "Nelem=20480 mean_time=57.49 ms stddev_time=1.50 ms mem_used=1956 MB\n", + "Nelem=20800 mean_time=60.40 ms stddev_time=3.51 ms mem_used=1959 MB\n", + "Nelem=21120 mean_time=61.30 ms stddev_time=3.90 ms mem_used=1959 MB\n", + "Nelem=21440 mean_time=60.74 ms stddev_time=1.05 ms mem_used=1948 MB\n", + "Nelem=21760 mean_time=61.66 ms stddev_time=1.29 ms mem_used=1948 MB\n", + "Nelem=22080 mean_time=63.35 ms stddev_time=1.11 ms mem_used=1948 MB\n", + "Nelem=22400 mean_time=64.70 ms stddev_time=1.16 ms mem_used=1948 MB\n", + "Nelem=22720 mean_time=65.63 ms stddev_time=0.95 ms mem_used=1948 MB\n", + "Nelem=23040 mean_time=67.09 ms stddev_time=1.02 ms mem_used=1948 MB\n", + "Nelem=23360 mean_time=68.40 ms stddev_time=1.15 ms mem_used=1948 MB\n", + "Nelem=23680 mean_time=69.76 ms stddev_time=0.88 ms mem_used=1948 MB\n", + "Nelem=24000 mean_time=71.55 ms stddev_time=0.94 ms mem_used=1948 MB\n", + "Nelem=24320 mean_time=73.04 ms stddev_time=1.46 ms mem_used=1948 MB\n", + "Nelem=24640 mean_time=74.53 ms stddev_time=1.28 ms mem_used=1948 MB\n", + "Nelem=24960 mean_time=76.03 ms stddev_time=1.07 ms mem_used=1948 MB\n", + "Nelem=25280 mean_time=77.59 ms stddev_time=0.88 ms mem_used=1948 MB\n", + "\"\"\"" + ] + }, { "cell_type": "code", "execution_count": null, "id": "0d2ec496", "metadata": {}, "outputs": [], + "source": [ + "time_x = []\n", + "time_y = []\n", + "time_y_err = []\n", + "gpu_mem_use = []\n", + "for line in timing_output.split(\"\\n\"):\n", + " if len(line)>0:\n", + " spl = line.split()\n", + " time_x.append(int(spl[0].split(\"=\")[1]))\n", + " time_y.append(float(spl[1].split(\"=\")[1]))\n", + " time_y_err.append(float(spl[3].split(\"=\")[1]))\n", + " gpu_mem_use.append(float(spl[5].split(\"=\")[1]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "921ff392", + "metadata": {}, + "outputs": [], + "source": [ + "import glob\n", + "nelem = []\n", + "for fi in glob.glob(\"../data/TTbar_14TeV_TuneCUETP8M1_cfi/raw/*.pkl\"):\n", + " d = pickle.load(open(fi, \"rb\"))\n", + " for elem in d:\n", + " X = elem[\"Xelem\"][(elem[\"Xelem\"][\"typ\"]!=2)&(elem[\"Xelem\"][\"typ\"]!=3)]\n", + " nelem.append(X.shape[0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "986f0b2a", + "metadata": {}, + "outputs": [], + "source": [ + "plt.figure(figsize=(5,5))\n", + "ax = plt.axes()\n", + "plt.hist(nelem, bins=np.linspace(2000,6000,100));\n", + "plt.ylabel(\"Number of events / bin\")\n", + "plt.xlabel(\"PFElements per event\")\n", + "cms_label()\n", + "sample_label(ax, physics_process=\"ttbar\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eaf8a862", + "metadata": {}, + "outputs": [], + "source": [ + "plt.figure(figsize=(10, 3))\n", + "plt.errorbar(time_x, time_y, yerr=time_y_err, marker=\".\", label=\"MLPF\")\n", + "plt.axvline(np.mean(nelem)-np.std(nelem), color=\"black\", ls=\"--\", lw=1.0, label=r\"$t\\bar{t}$+PU Run 3\")\n", + "plt.axvline(np.mean(nelem)+np.std(nelem), color=\"black\", ls=\"--\", lw=1.0)\n", + "#plt.xticks(time_x, time_x);\n", + "plt.xlim(0,30000)\n", + "plt.ylim(0,100)\n", + "plt.ylabel(\"Average runtime per event [ms]\")\n", + "plt.xlabel(\"PFElements per event\")\n", + "plt.legend(frameon=False)\n", + "cms_label(x1=0.17, x2=0.8)\n", + "plt.savefig(\"runtime_scaling.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"runtime_scaling.png\", bbox_inches=\"tight\", dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84de50e8", + "metadata": {}, + "outputs": [], + "source": [ + "plt.figure(figsize=(10, 3))\n", + "plt.plot(time_x, gpu_mem_use, marker=\".\", label=\"MLPF\")\n", + "plt.axvline(np.mean(nelem)-np.std(nelem), color=\"black\", ls=\"--\", lw=1.0, label=r\"$t\\bar{t}$+PU Run 3\")\n", + "plt.axvline(np.mean(nelem)+np.std(nelem), color=\"black\", ls=\"--\", lw=1.0)\n", + "#plt.xticks(time_x, time_x);\n", + "plt.xlim(0,30000)\n", + "plt.ylim(0,3000)\n", + "plt.ylabel(\"Maximum GPU memory used [MB]\")\n", + "plt.xlabel(\"PFElements per event\")\n", + "plt.legend(frameon=False, loc=4)\n", + "cms_label(x1=0.17, x2=0.8)\n", + "plt.savefig(\"memory_scaling.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"memory_scaling.png\", bbox_inches=\"tight\", dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "777ba9f3", + "metadata": {}, + "outputs": [], "source": [] } ], diff --git a/notebooks/pfnet-debug.ipynb b/notebooks/pfnet-debug.ipynb index 7cb5864fe..d37af9248 100644 --- a/notebooks/pfnet-debug.ipynb +++ b/notebooks/pfnet-debug.ipynb @@ -1,5 +1,16 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "b159acf8", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "os.chdir(\"/home/joosep/particleflow\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -10,6 +21,7 @@ "import tensorflow as tf\n", "import numpy as np\n", "import sys\n", + "\n", "sys.path.append(\"/home/joosep/particleflow/mlpf\")\n", "import tfmodel.model\n", "import tfmodel.data\n", @@ -18,8 +30,6 @@ "import yaml\n", "import matplotlib.pyplot as plt\n", "import matplotlib \n", - "import os\n", - "os.chdir(\"/home/joosep/particleflow\")\n", "\n", "import pandas\n", "import networkx\n", @@ -54,57 +64,7 @@ { "cell_type": "code", "execution_count": null, - "id": "exact-landing", - "metadata": {}, - "outputs": [], - "source": [ - "cds = config[\"dataset\"]\n", - "\n", - "dataset_def = tfmodel.data.Dataset(\n", - " num_input_features=int(cds[\"num_input_features\"]),\n", - " num_output_features=int(cds[\"num_output_features\"]),\n", - " padded_num_elem_size=6400,\n", - " raw_path=cds.get(\"raw_path\", None),\n", - " raw_files=cds.get(\"raw_files\", None),\n", - " processed_path=cds[\"processed_path\"],\n", - " validation_file_path=\"data/TTbar_14TeV_TuneCUETP8M1_cfi/val/pfntuple_*.pkl.bz2\",\n", - " schema=cds[\"schema\"]\n", - ")\n", - "\n", - "dataset_transform = tfmodel.model_setup.targets_multi_output(config['dataset']['num_output_classes'])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "identified-header", - "metadata": {}, - "outputs": [], - "source": [ - "Xs = []\n", - "ygens = []\n", - "ycands = []\n", - "\n", - "for fi in dataset_def.val_filelist[:2]:\n", - " print(fi)\n", - " X, ygen, ycand = dataset_def.prepare_data(fi)\n", - "\n", - " Xs.append(np.concatenate(X))\n", - " ygens.append(np.concatenate(ygen))\n", - " ycands.append(np.concatenate(ycand))\n", - "\n", - "X_val = np.concatenate(Xs)\n", - "ygen_val = np.concatenate(ygens)\n", - "ycand_val = np.concatenate(ycands)\n", - "\n", - "X_val, ycand_val, _ = dataset_transform(X_val, ycand_val, None)\n", - "X_val, ygen_val, _ = dataset_transform(X_val, ygen_val, None)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "reduced-collar", + "id": "c4107771", "metadata": {}, "outputs": [], "source": [] @@ -112,34 +72,42 @@ { "cell_type": "code", "execution_count": null, - "id": "expensive-incidence", + "id": "exact-landing", "metadata": {}, "outputs": [], "source": [ - "np.std(ycand_val[\"energy\"][np.argmax(ycand_val[\"cls\"], axis=-1)==2].numpy().flatten())" + "cds = config[\"dataset\"]\n", + "\n", + "config[\"datasets\"][\"cms_pf_ttbar\"][\"batch_per_gpu\"] = 1\n", + "ds_val, ds_info = tfmodel.utils.get_heptfds_dataset(\n", + " \"cms_pf_ttbar\",\n", + " config, 1, \"test\", 100\n", + ")" ] }, { "cell_type": "code", "execution_count": null, - "id": "painful-delight", + "id": "collective-mounting", "metadata": {}, "outputs": [], "source": [ - "plt.hist((ycand_val[\"energy\"][np.argmax(ycand_val[\"cls\"], axis=-1)==2].numpy().flatten()-1/59)/1.3, bins=100);" + "ret = model.build((1, 6400, 18))\n", + "#model.set_trainable_classification()\n", + "model.load_weights(\"/home/joosep/particleflow/experiments/cms_20210917_142344_403761.gpu0.local/weights/weights-200-0.059240.hdf5\")" ] }, { "cell_type": "code", "execution_count": null, - "id": "collective-mounting", + "id": "aa7c2864", "metadata": {}, "outputs": [], "source": [ - "ret = model(X_val[:1])\n", - "#model.set_trainable_classification()\n", - "model.load_weights(\"/home/joosep/particleflow/experiments/cms_20210828_144012_433706.joosep-desktop//weights/weights-03-28.697701.hdf5\")\n", - "ret = model.predict(X_val, batch_size=1, verbose=1)" + "for X, y, w in ds_val:\n", + " X_val = X.numpy()\n", + " ret = model.predict_on_batch(X)\n", + " break" ] }, { @@ -183,10 +151,11 @@ "\n", " plt.figure(figsize=(4,4))\n", " plt.scatter(eta, phi, c=[colorlist[bi] for bi in bin_idx], marker=\".\", s=energy)\n", - " plt.xlabel(\"eta\")\n", - " plt.ylabel(\"phi\")\n", + " plt.xlabel(\"PFElement $\\eta$\")\n", + " plt.ylabel(\"PFElement $\\phi$\")\n", " plt.title(\"Binning in {}\".format(layer_name))\n", - " plt.savefig(\"bins_{}.pdf\".format(layer_name))" + " plt.savefig(\"bins_{}.pdf\".format(layer_name), bbox_inches=\"tight\")\n", + " plt.savefig(\"bins_{}.png\".format(layer_name), bbox_inches=\"tight\", dpi=300)" ] }, { @@ -209,16 +178,6 @@ "plot_binning_in_layer(\"cg_1\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "cardiac-regression", - "metadata": {}, - "outputs": [], - "source": [ - "plot_binning_in_layer(\"cg_2\")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -239,16 +198,6 @@ "plot_binning_in_layer(\"cg_energy_1\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "upper-rapid", - "metadata": {}, - "outputs": [], - "source": [ - "plot_binning_in_layer(\"cg_energy_2\")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -258,14 +207,16 @@ "source": [ "def plot_dms(dms):\n", " fig = plt.figure(figsize=(4*4, 3*4))\n", - " for i in range(len(dms)):\n", - " ax = plt.subplot(4,4,i+1)\n", + " for i in range(min(len(dms), 49)):\n", + " ax = plt.subplot(7,7,i+1)\n", " plt.axes(ax)\n", " plt.imshow(dms[i], interpolation=\"none\", norm=matplotlib.colors.Normalize(vmin=0, vmax=1), cmap=\"Blues\")\n", - " plt.colorbar()\n", + " #plt.colorbar()\n", " plt.title(\"bin {}\".format(i))\n", " #plt.xlabel(\"elem index $i$\")\n", " #plt.ylabel(\"elem index $j$\")\n", + " plt.xticks([])\n", + " plt.yticks([])\n", " plt.tight_layout()" ] }, @@ -276,21 +227,16 @@ "metadata": {}, "outputs": [], "source": [ - "for layer in ['cg_0', 'cg_1', 'cg_2']:\n", - " dm_vals = ret[layer]['dm'].flatten()\n", - " plt.hist(dm_vals[dm_vals!=0], bins=np.linspace(0,1,100), density=True, alpha=0.8, lw=2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "streaming-license", - "metadata": {}, - "outputs": [], - "source": [ - "for layer in ['cg_energy_0', 'cg_energy_1', 'cg_energy_2']:\n", + "for layer in ['cg_0', 'cg_1', 'cg_energy_0', 'cg_energy_1']:\n", " dm_vals = ret[layer]['dm'].flatten()\n", - " plt.hist(dm_vals[dm_vals!=0], bins=np.linspace(0,1,100), density=True, alpha=0.8, lw=2)" + " plt.hist(dm_vals[dm_vals!=0], bins=np.linspace(0,1,100), density=True, lw=2, histtype=\"step\", label=layer)\n", + "plt.yscale(\"log\")\n", + "plt.legend(loc=\"best\", frameon=False, ncol=2)\n", + "plt.xlabel(\"Element-to-element distance\")\n", + "plt.ylabel(\"Number of elements\")\n", + "\n", + "plt.savefig(\"dm.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"dm.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -302,8 +248,10 @@ "source": [ "dmn = ret['cg_0']['dm'][0, :, :, :, 0]\n", "plot_dms(dmn)\n", + "plt.tight_layout()\n", "plt.suptitle(\"Learned adjacency, cg_0\", y=1.01)\n", - "plt.savefig(\"dm_cg_0.pdf\")" + "plt.savefig(\"dm_cg_0.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"dm_cg_0.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -316,20 +264,8 @@ "dmn = ret['cg_1']['dm'][0, :, :, :, 0]\n", "plot_dms(dmn)\n", "plt.suptitle(\"Learned adjacency, cg_1\", y=1.01)\n", - "plt.savefig(\"dm_cg_1.pdf\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "prostate-spider", - "metadata": {}, - "outputs": [], - "source": [ - "dmn = ret['cg_2']['dm'][0, :, :, :, 0]\n", - "plot_dms(dmn)\n", - "plt.suptitle(\"Learned adjacency, cg_2\", y=1.01)\n", - "plt.savefig(\"dm_cg_2.pdf\")" + "plt.savefig(\"dm_cg_1.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"dm_cg_1.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -342,7 +278,8 @@ "dmn = ret['cg_energy_0']['dm'][0, :, :, :, 0]\n", "plot_dms(dmn)\n", "plt.suptitle(\"Learned adjacency, cg_energy_0\", y=1.01)\n", - "plt.savefig(\"dm_cg_energy_0.pdf\")" + "plt.savefig(\"dm_cg_energy_0.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"dm_cg_energy_0.png\", bbox_inches=\"tight\", dpi=300)" ] }, { @@ -355,247 +292,14 @@ "dmn = ret['cg_energy_1']['dm'][0, :, :, :, 0]\n", "plot_dms(dmn)\n", "plt.suptitle(\"Learned adjacency, cg_energy_1\", y=1.01)\n", - "plt.savefig(\"dm_cg_energy_1.pdf\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "superb-explorer", - "metadata": {}, - "outputs": [], - "source": [ - "dmn = ret['cg_energy_2']['dm'][0, :, :, :, 0]\n", - "plot_dms(dmn)\n", - "plt.suptitle(\"Learned adjacency, cg_energy_2\", y=1.01)\n", - "plt.savefig(\"dm_cg_energy_2.pdf\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "organized-unemployment", - "metadata": {}, - "outputs": [], - "source": [ - "msk = X_val[0][:, 0]!=0\n", - "sel = ret['dec_output'][0][msk]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "competitive-flashing", - "metadata": {}, - "outputs": [], - "source": [ - "plt.scatter(sel[:, 40], sel[:, 60], marker=\".\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "maritime-beaver", - "metadata": {}, - "outputs": [], - "source": [ - "np.array(X_val[:1, :, 0]!=0, np.float32)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "acting-combat", - "metadata": {}, - "outputs": [], - "source": [ - "ret['dec_output_energy'].shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "governmental-height", - "metadata": {}, - "outputs": [], - "source": [ - "pred_debug1 = model.output_dec([\n", - " X_val,\n", - " ret['dec_output'],\n", - " ret['dec_output_energy'],\n", - " np.array(X_val[:, :, 0:1]!=0, np.float32)],\n", - " training=False\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "worse-album", - "metadata": {}, - "outputs": [], - "source": [ - "true_id = np.argmax(ycand_val[\"cls\"], axis=-1)\n", - "pred_id1 = np.argmax(pred_debug1[\"cls\"], axis=-1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "combined-convention", - "metadata": {}, - "outputs": [], - "source": [ - "plt.figure(figsize=(4,4))\n", - "msk1 = (X_val[:, :, 0]!=0) & (true_id==2)\n", - "plt.scatter(\n", - " pred_debug1[\"energy\"][msk1][:, 0].numpy(),\n", - " ycand_val[\"energy\"][msk1][:, 0].numpy(),\n", - " marker=\".\", alpha=0.4\n", - ")\n", - "\n", - "#plt.plot([-1,1], [-1,1], color=\"black\")\n", - "\n", - "plt.plot([0,6], [0,6], color=\"black\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "caroline-afghanistan", - "metadata": {}, - "outputs": [], - "source": [ - "model.cg[0].trainable = False\n", - "model.cg[1].trainable = False\n", - "model.cg[2].trainable = False\n", - "\n", - "# model.cg_energy[0].trainable = False\n", - "# model.cg_energy[1].trainable = False\n", - "# model.cg_energy[2].trainable = False\n", - "\n", - "model.output_dec.ffn_id.trainable = False\n", - "model.output_dec.ffn_charge.trainable = False\n", - "model.output_dec.ffn_phi.trainable = False\n", - "model.output_dec.ffn_eta.trainable = False\n", - "model.output_dec.ffn_pt.trainable = False\n", - "model.output_dec.ffn_energy.trainable = True\n", - "\n", - "model.output_dec.layernorm.trainable = False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "later-hudson", - "metadata": {}, - "outputs": [], - "source": [ - "[w.name for w in model.trainable_weights]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "contemporary-peeing", - "metadata": {}, - "outputs": [], - "source": [ - "class_weights = tf.constant([0.0, 0.01, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "scheduled-proposal", - "metadata": {}, - "outputs": [], - "source": [ - "loss = tf.keras.losses.Huber()\n", - "optimizer = tf.keras.optimizers.Adam(lr=1e-4)\n", - "for epoch in range(100):\n", - " with tf.GradientTape() as tape:\n", - " y_pred = model(X_val[:2], training=True)\n", - " pred_cls = tf.argmax(y_pred[\"cls\"], axis=-1)\n", - " true_cls = tf.argmax(ycand_val[\"cls\"][:2], axis=-1)\n", - " msk_loss = tf.expand_dims(tf.cast((pred_cls==true_cls) & (true_cls!=0), tf.float32), axis=-1)\n", - " sample_weights = tf.keras.activations.softmax(ycand_val[\"cls\"][:2]*100)*class_weights\n", - " sample_weights = tf.reduce_sum(class_weights, axis=-1, keepdims=True)\n", - " loss_val = loss(ycand_val[\"energy\"][:2]*msk_loss, y_pred[\"energy\"][:2]*msk_loss, sample_weight=sample_weights)\n", - " print(loss_val)\n", - " trainable_vars = model.trainable_variables\n", - " gradients = tape.gradient(loss_val, trainable_vars)\n", - " optimizer.apply_gradients(zip(gradients, trainable_vars))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "acoustic-opening", - "metadata": {}, - "outputs": [], - "source": [ - "y_pred = model(X_val[2:6], training=False)\n", - "\n", - "true_id = tf.argmax(ycand_val[\"cls\"][2:6], axis=-1)\n", - "pred_id = tf.argmax(y_pred[\"cls\"], axis=-1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "accompanied-musical", - "metadata": {}, - "outputs": [], - "source": [ - "sklearn.metrics.confusion_matrix(true_id.numpy().flatten(), pred_id.numpy().flatten())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ahead-literature", - "metadata": {}, - "outputs": [], - "source": [ - "plt.figure(figsize=(4,4))\n", - "cls = 3\n", - "print(np.sum((true_id==cls) & (pred_id==cls)))\n", - "plt.scatter(\n", - " y_pred[\"energy\"][(true_id==cls) & (pred_id==cls)],\n", - " ycand_val[\"energy\"][2:6][(true_id==cls) & (pred_id==cls)],\n", - " marker=\".\"\n", - ")\n", - "plt.plot([0,6], [0,6], color=\"black\")\n", - "plt.xlim(0,6)\n", - "plt.ylim(0,6)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "progressive-auckland", - "metadata": {}, - "outputs": [], - "source": [ - "vals = y_pred[\"energy\"][(true_id!=0)] - ycand_val[\"energy\"][2:6][(true_id!=0)]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "lesser-grant", - "metadata": {}, - "outputs": [], - "source": [ - "plt.hist(vals.numpy().flatten(), bins=np.linspace(-2,2,100));\n", - "plt.yscale(\"log\")" + "plt.savefig(\"dm_cg_energy_1.pdf\", bbox_inches=\"tight\")\n", + "plt.savefig(\"dm_cg_energy_1.png\", bbox_inches=\"tight\", dpi=300)" ] }, { "cell_type": "code", "execution_count": null, - "id": "deluxe-twenty", + "id": "c853c865", "metadata": {}, "outputs": [], "source": [] @@ -603,7 +307,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -617,7 +321,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.10" } }, "nbformat": 4, diff --git a/parameters/cms.yaml b/parameters/cms.yaml index 5856c4c05..e86f262d3 100644 --- a/parameters/cms.yaml +++ b/parameters/cms.yaml @@ -52,8 +52,8 @@ setup: weights: weights_config: lr: 1e-4 - num_events_validation: 100 - num_epochs: 1000 + num_events_validation: 1000 + num_epochs: 200 dtype: float32 trainable: classification_loss_type: sigmoid_focal_crossentropy @@ -101,24 +101,12 @@ parameters: type: NodePairGaussianKernel dist_mult: 0.1 clip_value_low: 0.0 - #kernel: - # type: NodePairTrainableKernel - # output_dim: 4 - # hidden_dim_pair: 32 - # hidden_dim_node: 128 - # num_layers: 1 num_node_messages: 1 node_message: type: GHConvDense output_dim: 256 activation: elu normalize_degrees: yes - #node_message: - # type: NodeMessageLearnable - # output_dim: 128 - # hidden_dim: 128 - # num_layers: 1 - # activation: gelu activation: elu num_graph_layers_common: 2 num_graph_layers_energy: 2 @@ -224,9 +212,19 @@ raytune: training_datasets: - cms_pf_ttbar + - cms_pf_single_pi + - cms_pf_single_pi0 + - cms_pf_single_gamma + - cms_pf_single_electron + - cms_pf_single_mu testing_datasets: - cms_pf_ttbar + - cms_pf_single_pi + - cms_pf_single_pi0 + - cms_pf_single_gamma + - cms_pf_single_electron + - cms_pf_single_mu validation_dataset: cms_pf_ttbar @@ -240,14 +238,29 @@ datasets: version: 1.1.0 data_dir: manual_dir: - batch_per_gpu: 50 + batch_per_gpu: 100 + cms_pf_single_pi0: + version: 1.1.0 + data_dir: + manual_dir: + batch_per_gpu: 100 cms_pf_single_tau: version: 1.1.0 data_dir: manual_dir: - batch_per_gpu: 50 + batch_per_gpu: 100 cms_pf_single_electron: version: 1.1.0 data_dir: manual_dir: - batch_per_gpu: 50 + batch_per_gpu: 100 + cms_pf_single_mu: + version: 1.1.0 + data_dir: + manual_dir: + batch_per_gpu: 100 + cms_pf_single_gamma: + version: 1.1.0 + data_dir: + manual_dir: + batch_per_gpu: 100 diff --git a/scripts/onnxruntime.singularity b/scripts/onnxruntime.singularity new file mode 100644 index 000000000..b620511a1 --- /dev/null +++ b/scripts/onnxruntime.singularity @@ -0,0 +1,20 @@ +Bootstrap: docker + +From: nvcr.io/nvidia/cuda:11.0.3-cudnn8-devel-ubuntu20.04 + +%post + apt update -y + DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends tzdata + apt install -y python3 python3-dev python3-pip python3-venv + apt install -y language-pack-en + + python3 -m pip install --upgrade pip + + python3 -m pip install numpy==1.19 + python3 -m pip install onnxruntime-gpu + python3 -m pip install nvidia-ml-py3 + +%environment + +%runscript + /bin/bash