Skip to content

Instantly share code, notes, and snippets.

View riga's full-sized avatar

Marcel Rieger riga

View GitHub Profile
@riga
riga / test.ipynb
Last active August 28, 2024 13:39
jax2xla2aot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@riga
riga / srvstatic
Last active June 7, 2024 11:57
static server
#!/usr/bin/env python
# coding: utf-8
# python imports
import os
import cherrypy
class Server(object):
@riga
riga / job.jdl
Last active February 8, 2024 19:19
htcondor test
universe = vanilla
executable = job.sh
log = /dev/null
should_transfer_files = YES
transfer_input_files = job.sh
when_to_transfer_output = ON_EXIT
output = out.txt
error = err.txt
notification = Never
initialdir = /afs/cern.ch/user/m/mrieger/htctest
@riga
riga / pytorch_grad_stop.py
Created October 30, 2023 09:15
Test partial gradient stopping in PyTorch
# coding: utf-8
"""
Setup via
> pip install torch torchvision
"""
from __future__ import annotations
from contextlib import contextmanager
@riga
riga / tasks.py
Last active August 26, 2023 18:21
Dynamic law workflows
# coding: utf-8
import law
class LongRunning(law.Task):
def output(self):
return law.LocalFileTarget("$PWD/data/long_running.json")
@riga
riga / evaluate_klub.py
Last active July 11, 2023 09:09
Evaluation script for KLUB samples
# coding: utf-8
from __future__ import annotations
import os
from fnmatch import fnmatch
from multiprocessing import Pool as ProcessPool
from typing import Any
from tqdm import tqdm
@riga
riga / nano_unique.py
Created July 5, 2023 09:18
Merge two NanoAOD files while removing duplicate events
#!/usr/bin/env python3
# coding: utf-8
"""
Script that merges the events tree of two NanoAOD files, removing duplicates identified
by event number, run number and luminosity block.
> nano_unique.py in1.root in2.root out.root
NOTE: This is just a first draft whose performance could surely be improved
# coding: utf-8
import dask_awkward as dak
import awkward as ak
# located at https://cernbox.cern.ch/remote.php/dav/public-files/rvipIIozKQAypwu/calib.parquet
input_path = "calib.parquet"
@riga
riga / met_phi_correction.py
Last active October 11, 2022 16:29
CMS MET Phi (Type II) correction
# coding: utf-8
"""
Lightweight Python implementation of the Run 2 MET phi (type II) correction, following
https://lathomas.web.cern.ch/lathomas/METStuff/XYCorrections/XYMETCorrection_withUL17andUL18andUL16.h,
taken from https://twiki.cern.ch/twiki/bin/view/CMS/MissingETRun2Corrections?rev=72.
Downloadable source at https://mrieger.web.cern.ch/snippets/met_phi_correction.py,
gist at https://gist.github.com/riga/951076bcde6ea7cb4da2bf7c7417379a.
@riga
riga / Makefile
Last active May 26, 2024 19:44
Accelerated Graph Evaluation with TensorFlow XLA AOT
INC = -I${TF_INSTALL_PATH}/include
LIB = -L${TF_INSTALL_PATH}/xla_aot_runtime_src
LIBS = -lpthread -ltf_xla_runtime
CXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0
.phony: all clean
all: test_model
test_model: test_model.cc my_model.o