JustWhit3 / QUnfold

A module to perform the statistical unfolding / deconvolution / matrix-inversion problem using quantum annealing with D-Wave quantum computer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DOI
v0.3 license python
codeql docs docker build

Table of contents

Introduction

This package provides an implementation of a quantum-based solver for the statistical unfolding problem formulated as a Quadratic Unconstrained Binary Optimization (QUBO) problem. The code is written in Python and based on NumPy, but it allows to be used on ROOT data for application in High-Energy Physics (HEP).

The idea is inspired by the work done by Riccardo Di Sipio et al. which can be found here. For a more detailed description of the model, take a look at the Wiki page.

The package currently provides the following algorithms to solve the unfolding problem:

  • Simulated annealing: D-Wave implementation of the standard simulated annealing algorithm running on classical hardware resources
  • Hybrid solver: complex approach combining both classical computing (for the decomposition of the original problem into smaller sub-problems) and D-Wave quantum annealing on real hardware
  • Quantum annealing: quantum approach fully running on D-Wave quantum annealing hardware.

Documentation

(work in progress...)
  • Wiki page: description of the theoretical model and examples on how to use the package.
  • Read the Docs: API documentation for all the available features of the package.

Installation

User-mode

To install the QUnfold latest version released on PyPI in user-mode you can do:

pip install QUnfold

Developer-mode

To create a dedicated conda environment and install QUnfold in developer-mode you can do:

conda create --name qunfold-dev python==3.10
conda activate qunfold-dev
git clone https://github.com/JustWhit3/QUnfold.git
cd QUnfold
pip install -r requirements-dev.txt
pip install -e .

Usage example

Here is a simple code example showing how to use QUnfold:

from QUnfold import QUnfoldQUBO

# Define your input response matrix and measured histogram as numpy arrays
response = ...
measured = ...

# Create the QUnfoldQUBO object and initialize the QUBO model
unfolder = QUnfoldQUBO(response, measured, lam=0.1)
unfolder.initialize_qubo_model()

# Run one of the available solvers to get the unfolding result
sol, err, cov = unfolder.solve_simulated_annealing(num_reads=100)

⚠️ The response matrix must be normalized (see here).

If you are working in High-Energy Physics, your response matrix might be a RooUnfoldResponse object and your measured histogram is probably stored as a ROOT.TH1 object. The QUnfold.utils module provides some simple functions to convert these objects to standard numpy arrays:

from QUnfold.utils import TH1_to_numpy, TH2_to_numpy

# Convert ROOT.TH1 measured histogram to numpy array
measured = TH1_to_numpy(measured)

# Convert RooUnfoldResponse object to numpy array
response = TH2_to_numpy(response.Hresponse())

For a complete example on how to run the QUnfold solvers and plot the final results, you can take a look at the examples directory in the repository.

Unfolding studies

This section contains instructions to solve the unfolding problem by standard classical algotihms (widely used in HEP data analysis) as well as the QUnfold quantum-based method. It also provides several tools and examples to compare the results of the two different approached. Check out the studies directory in this repository to learn more.

HEP dependencies

To run the code you need to install the following HEP frameworks:

  • ROOT v6.28/10 (see documentation here)
  • RooUnfold v3.0.0 (see documentation here)

In your Ubuntu system, this can be done automatically by executing the following commands from the root directory of the repository:

./scripts/fetchROOT.sh
source HEP_deps/root/bin/thisroot.sh
./scripts/fetchRooUnfold.sh

Performance analysis

The code can be used to generate syntetic data samples according to common HEP probability density functions (normal, gamma, exponential, Breit-Wigner, double-peaked) and apply a smearing to roughly simulate the distortion effects due to limitions efficiency, acceptance, and space/time resolution of a given detector.

Then, unfolding is performed by several classical, hybrid, and quantum techniques and the results are studied to compare the performance of the different methods. In particular, the algorithms currently available are the following:

⚠️ The HYB and QA solvers require access to a real D-Wave quantum annealer (1 min/month available for free via the D-Wave Leap cloud platform).


Main developers


Gianluca Bianco

Simone Gasperini

Other contributors


Marco Lorusso

About

A module to perform the statistical unfolding / deconvolution / matrix-inversion problem using quantum annealing with D-Wave quantum computer.

License:MIT License


Languages

Language:Python 92.4%Language:C++ 4.6%Language:Shell 2.5%Language:Dockerfile 0.6%