qunfold

Quantum Annealing for distribution unfolding in experimental High-Energy Physics

https://github.com/quantum4hep/qunfold

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.1%) to scientific vocabulary

Keywords

dwave high-energy-physics quantum-annealing quantum-computing qubo-problem unfolding
Last synced: 6 months ago · JSON representation ·

Repository

Quantum Annealing for distribution unfolding in experimental High-Energy Physics

Basic Info
  • Host: GitHub
  • Owner: Quantum4HEP
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 11.1 MB
Statistics
  • Stars: 23
  • Watchers: 5
  • Forks: 3
  • Open Issues: 4
  • Releases: 12
Topics
dwave high-energy-physics quantum-annealing quantum-computing qubo-problem unfolding
Created over 2 years ago · Last pushed 11 months ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.md

logo

DOI docs
version license python

Table of contents

Introduction

This package provides a quantum-based approach to the statistical unfolding problem in High-Energy Physics (HEP). The technique is based on the reformulation of this task as a Quadratic Unconstrained Binary Optimization (QUBO) problem to be solved by Quantum Annealing (QA) on D-Wave quantum devices.

The code is written in Python and relies on numpy arrays as basic data structures. However, the package also includes simple tools to convert ROOT data to numpy, allowing HEP scientists to run the algorithms for their specific use-cases with a minimal effort. The software is designed leveraging the powerful D-Wave Ocean SDK, which provides several tools to define the QUBO model and run widely-used heuristics for classical computers (e.g. Simulated Annealing) as well as hybrid/quantum solvers running on real QA D-Wave Systems.

The idea for this project was inspired by the work done by K. Cormier, R. Di Sipio, and P. Wittek in 2019 (see here for the links to an oral presentation and the published paper).

:warning: For a comprehensive introduction to the classical problem, see Chapter 11 of the book Statistical Data Analysis by G. Cowan.

Documentation

(work in progress...)

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: shell pip install QUnfold

If you also want to enable the classical Gurobi solver both for the integer optimization problem and the QUBO problem, you need to install QUnfold including this additional requirement: shell pip install QUnfold[gurobi]

Dev-mode

To create a dedicated conda environment and install QUnfold in developer-mode you can do: shell conda create --name qunfold-dev python==3.10.14 conda activate qunfold-dev git clone https://github.com/Quantum4HEP/QUnfold.git cd QUnfold pip install --upgrade -r requirements-dev.txt pip install -e .[gurobi]

Docker container

Two different Docker images are ready to be downloaded from DockerHub to start playing with a containerized version of QUnfold: - qunfold: minimal working version for testing basic functionalities - qunfold-dev: full version based on the conda distribution for Python, including the installation of ROOT framework and RooUnfold library for expert users in High-Energy Physics

Both the containerized solutions offer the possibility to use QUnfold running a JupyterLab web-based environment on your favourite browser. First, run the Docker container with the porting option as follows: docker docker run -itp 8888:8888 qunfold Secondly, once the container has started, launch jupyter-lab with the following command: shell jupyter-lab --ip=0.0.0.0

Usage example

Here is a minimal example showing how to use QUnfold. The code snippet shows how to create an instance of the unfolder class, initialize the QUBO model, and run the simulated annealing algorithm to solve the problem. ```python from qunfold import QUnfolder

Define your input response matrix and measured histogram as numpy arrays

response = ... measured = ... binning = ...

Create the QUnfolder object and initialize the QUBO model

unfolder = QUnfolder(response, measured, binning, lam=0.1) unfolder.initializequbomodel()

Run one of the available solvers to get the unfolding result

sol, cov = unfolder.solvesimulatedannealing(num_reads=100) ```

The figures show a specific example of a given response matrix as well as the correponding histograms for the case of a gamma distribution with Gaussian smearing.

If you are working in High-Energy Physics, your response matrix might be a RooUnfoldResponse object and your measured histogram is probably stored in a ROOT.TH1. The qunfold.root2numpy module provides some simple functions to convert these objects to standard numpy arrays: ```python from qunfold.root2numpy import TH1tonumpy, TH2tonumpy

Convert ROOT.TH1 measured histogram to numpy array

measured = TH1tonumpy(measured)

Convert RooUnfoldResponse object to numpy array

response = TH2tonumpy(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 classical methods (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 approaches.

HEP dependencies

To run the classical unfolding algorithms you need to install the ROOT framework developed by CERN (see documentation here) and the specialized RooUnfold library (see documentation here). On Linux or Mac OS this can be done automatically by running the following script in the root directory of the repository AFTER having activated the python environment you want to use (this can take a long time): shell ./install_roounfold.sh This step can be ignored if you are using the qunfold-dev Docker container since the corresponding Docker image already includes the required HEP software.

Performance analysis

The code available in the studies directory 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 limited 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: - RooUnfold framework: - Matrix Inversion unfolding (MI) - Bin-by-Bin unfolding (B2B) - Iterative Bayesian Unfolding (IBU) - Tikhonov regularized unfolding (SVD) - QUnfold library: - D-Wave Simulated Annealing (SA) for QUBO unfolding - D-Wave Hybrid solver (HYB) for QUBO unfolding - D-Wave Quantum Annealing (QA) for QUBO unfolding - Gurobi solver for integer optimization formulation of the unfolding problem - Gurobi solver for QUBO unfolding problem

:warning: 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) while the Gurobi solvers (Python API) require a software license (freely available for 18 months).


Main developers


Gianluca Bianco

Simone Gasperini

Other contributors


Marco Lorusso

Owner

  • Name: Quantum4HEP
  • Login: Quantum4HEP
  • Kind: organization
  • Email: simone.gasperini4@unibo.it
  • Location: Italy

Quantum computing algorithms for applications in High-Energy Physics

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: "Bianco"
    given-names: "Gianluca"
  - family-names: "Gasperini"
    given-names: "Simone"
title: "QUnfold"
version: 0.3.5
doi: https://zenodo.org/badge/latestdoi/652649177
date-released: 2024-09-20
url: "https://github.com/Quantum4HEP/QUnfold"

GitHub Events

Total
  • Issues event: 3
  • Watch event: 3
  • Delete event: 1
  • Issue comment event: 10
  • Push event: 33
  • Pull request review event: 4
  • Pull request review comment event: 4
  • Pull request event: 9
  • Fork event: 2
  • Create event: 4
Last Year
  • Issues event: 3
  • Watch event: 3
  • Delete event: 1
  • Issue comment event: 10
  • Push event: 33
  • Pull request review event: 4
  • Pull request review comment event: 4
  • Pull request event: 9
  • Fork event: 2
  • Create event: 4

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 2
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 1 month
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • SimoneGasperini (2)
Pull Request Authors
  • tommasodiotalevi (3)
  • SimoneGasperini (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 21 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 9
  • Total maintainers: 2
pypi.org: qunfold

A quantum-based approach to the distribution unfolding problem

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 21 Last month
Rankings
Dependent packages count: 9.8%
Stargazers count: 17.1%
Forks count: 19.2%
Average: 28.5%
Dependent repos count: 67.9%
Maintainers (2)
Last synced: 6 months ago

Dependencies

.github/workflows/DocGenerator.yml actions
  • EndBug/add-and-commit v7 composite
  • actions/checkout v3 composite
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/upload-artifact v2 composite
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v2 composite
requirements.txt pypi
  • cairosvg *
  • dwave-ocean-sdk *
  • hypothesis *
  • matplotlib *
  • pygal *
  • pyqubo *
  • pytest *
  • pytest-benchmark *
  • pytest-sugar *
  • scipy *
  • seaborn *
src/setup.py pypi
  • dwave-ocean-sdk *
  • matplotlib *
  • pyqubo *
  • scipy *