Python package for visualizing the loss landscape of parameterized quantum algorithms.

Related tags

Deep Learningorqviz
Overview

Image

orqviz

A Python package for easily visualizing the loss landscape of Variational Quantum Algorithms by Zapata Computing Inc.

orqviz provides a collection of tools which quantum researchers and enthusiasts alike can use for their simulations. It works with any framework for running quantum circuits, for example qiskit, cirq, pennylane, and Orquestra. The package contains functions to generate data, as well as a range of flexible plotting and helper functions. orqviz is light-weight and has very few dependencies.

Getting started

In doc/examples/ we provide a range of Jupyter notebook examples for orqviz. We have four Jupyter notebooks with tutorials for how to get started with any quantum circuit simulation framework you might use. You will find examples with qiskit, cirq, pennylane and Zapata's Orquestra library. The tutorials are not exhaustive, but they do provide a full story that you can follow along.

In this notebook we have the Sombrero example that we showcase in our paper. We also have an advanced example notebook which provides a thorough demonstration of the flexibility of the orqviz package.

We recently published a paper on arXiv where we review the tools available with orqviz:
ORQVIZ: Visualizing High-Dimensional Landscapes in Variational Quantum Algorithms

Installation

You can install our package using the following command:

pip install orqviz

Alternatively you can build the package from source. This is especially helpful if you would like to contribute to orqviz

git clone https://github.com/zapatacomputing/orqviz.git
cd orqviz
pip install -e ./

Examples

import orqviz
import numpy as np

np.random.seed(42)

def loss_function(pars):
    return np.sum(np.cos(pars))**2 + np.sum(np.sin(30*pars))**2

n_params = 42
params = np.random.uniform(-np.pi, np.pi, size=n_params)
dir1 = orqviz.geometric.get_random_normal_vector(n_params)
dir2 = orqviz.geometric.get_random_orthonormal_vector(dir1)

scan2D_result = orqviz.scans.perform_2D_scan(params, loss_function,
                                direction_x=dir1, direction_y=dir2,
                                n_steps_x=100)
orqviz.scans.plot_2D_scan_result(scan2D_result)

This code results in the following plot:

Image

Authors

The leading developer of this package is Manuel Rudolph at Zapata Computing.
For questions related to the visualization techniques, contact Manuel via [email protected] .

The leading software developer of this package is Michał Stęchły at Zapata Computing.
For questions related to technicalities of the package, contact Michał via [email protected] .

Thank you to Sukin Sim and Luis Serrano from Zapata Computing for their contributions to the tutorials.

You can also contact us or ask general questions using GitHub Discussions.

For more specific code issues, bug fixes, etc. please open a GitHub issue in the orqviz repository.

If you are doing research using orqviz, please cite our paper:

ORQVIZ: Visualizing High-Dimensional Landscapes in Variational Quantum Algorithms

How to contribute

Please see our Contribution Guidelines.

Comments
  • Use transpile to build circuit only once

    Use transpile to build circuit only once

    Despite being wrapped up in a lambda function, the get_circuit function is actually still called for every function evaluation during plot generation or optimization, and hence the circuit is rebuilt each time. This rather defeats the concept of late binding of the parameter values. The PR uses a slightly different approach using the transpile function. The code is arguably more transparent than using the lambda function wrapper. Evaluation is faster now, but for this simple case rarely more than 10%. One downside, the circuit cannot be plotted anymore in a simple way.

    opened by RonMeiburg 11
  • ci: add step with Pythonic cruft cleanup

    ci: add step with Pythonic cruft cleanup

    Apparently, issues that we had with mypy stem from Github Actions caching some (?) directories (thanks @alexjuda for pointing this out!). This PR adds a cleaning step (taken from z-quantum-actions) that deletes potentially conflicting directories.

    opened by dexter2206 1
  • Clean notebooks

    Clean notebooks

    These are the once-run versions of the cirq and qiskit notebooks derived from the 'simplified qiskit get_circuit() return' commit from the main branch. I hope this works for you. If not, then I apologize, When it comes to git I still suffer from sas every now and then.

    opened by RonMeiburg 1
  • Loss function clarity

    Loss function clarity

    Goals of this draft PR:

    • Allow parameters to be any np.ndarray rather than strictly a 1D np.ndarray
    • Improve docstrings for what we define as a loss function
    • Improve README to specify what we define as a loss function, and how to wrap their loss function with functools.partial
    • Alternatively, allow loss_function_kwargs in the scanning functions that we pass to the loss_function with more than one argument.
    opened by MSRudolph 1
  • Utilize tqdm progress bar when verbose=True during scans.

    Utilize tqdm progress bar when verbose=True during scans.

    Is your feature request related to a problem? Please describe. We should replace the print calls when verbose=True in scans with tqdm from the tqdm library. Alternatively, we make it the default and find a way to mute the library's prints.

    Describe the solution you'd like

    verbose = True  # or False
    for it in tqdm(range(n_iters), disable = not verbose):
       ...  # run scans
    

    Additional context Our verbosity options are currently very rudimentary and tqdm is one of the most used Python libraries.

    opened by MSRudolph 2
  • This repo should contain Issues for how people can contribute

    This repo should contain Issues for how people can contribute

    Is your feature request related to a problem? Please describe. Currently, when people enter the orqviz GitHub repository with the intent to contribute, there are no open Issues and not many PRs. They will not know what might be low-hanging fruit to contribute.

    Describe the solution you'd like We (orqviz developers) should open Issues which are connected to how people can concretely contribute. For example, we could provide links to existing tutorials which we believe can be readily enhanced with our visualization techniques. In such cases, potential contributors could work on such enhancements and reach out to the authors of the original tutorials. Similarly, we can elaborate on future visualization techniques which we could experiment with. This may be done by external contributors.

    opened by MSRudolph 0
Releases(v0.3.0)
  • v0.3.0(Aug 19, 2022)

    What's Changed

    • ci: add step with Pythonic cruft cleanup by @dexter2206 in https://github.com/zapatacomputing/orqviz/pull/43
    • Update main by @mstechly in https://github.com/zapatacomputing/orqviz/pull/44
    • Fourier transform by @laurgao in https://github.com/zapatacomputing/orqviz/pull/45

    Full Changelog: https://github.com/zapatacomputing/orqviz/compare/v0.2.0...v0.3.0

    Source code(tar.gz)
    Source code(zip)
    orqviz-0.3.0-py3-none-any.whl(38.09 KB)
  • v0.2.0(Feb 8, 2022)

    New features:

    • orqviz now doesn't require parameters to be 1D vectors, they can be ND arrays instead
    • We introduced LossFunctionWrapper as a utility tool that helps with changing arbitrary python functions into orqviz-compatible loss functions.

    Minor changes:

    • Improvements in notebook examples
    • Improvements in readme and contribution guidelines
    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Nov 9, 2021)

    What's Changed

    • Fixed classifiers in the setup.cfg
    • Minor fixes in in README
    • Relax dependency versions

    Full Changelog: https://github.com/zapatacomputing/orqviz/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
Owner
Zapata Computing, Inc.
Zapata Computing, Inc.
A package for music online and offline rhythmic information analysis including music Beat, downbeat, tempo and meter tracking.

BeatNet A package for music online and offline rhythmic information analysis including music Beat, downbeat, tempo and meter tracking. This repository

Mojtaba Heydari 157 Dec 27, 2022
This is an official implementation for "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" on Object Detection and Instance Segmentation.

Swin Transformer for Object Detection This repo contains the supported code and configuration files to reproduce object detection results of Swin Tran

Swin Transformer 1.4k Dec 30, 2022
Fully Convlutional Neural Networks for state-of-the-art time series classification

Deep Learning for Time Series Classification As the simplest type of time series data, univariate time series provides a reasonably good starting poin

Stephen 572 Dec 23, 2022
A concise but complete implementation of CLIP with various experimental improvements from recent papers

x-clip (wip) A concise but complete implementation of CLIP with various experimental improvements from recent papers Install $ pip install x-clip Usag

Phil Wang 515 Dec 26, 2022
Hierarchical Uniform Manifold Approximation and Projection

HUMAP Hierarchical Manifold Approximation and Projection (HUMAP) is a technique based on UMAP for hierarchical non-linear dimensionality reduction. HU

Wilson Estécio Marcílio Júnior 160 Jan 06, 2023
Official Python implementation of the 'Sparse deconvolution'-v0.3.0

Sparse deconvolution Python v0.3.0 Official Python implementation of the 'Sparse deconvolution', and the CPU (NumPy) and GPU (CuPy) calculation backen

Weisong Zhao 23 Dec 28, 2022
Code for AA-RMVSNet: Adaptive Aggregation Recurrent Multi-view Stereo Network (ICCV 2021).

AA-RMVSNet Code for AA-RMVSNet: Adaptive Aggregation Recurrent Multi-view Stereo Network (ICCV 2021) in PyTorch. paper link: arXiv | CVF Change Log Ju

Qingtian Zhu 97 Dec 30, 2022
Convert onnx models to pytorch.

onnx2torch onnx2torch is an ONNX to PyTorch converter. Our converter: Is easy to use – Convert the ONNX model with the function call convert; Is easy

ENOT 264 Dec 30, 2022
SwinTrack: A Simple and Strong Baseline for Transformer Tracking

SwinTrack This is the official repo for SwinTrack. A Simple and Strong Baseline Prerequisites Environment conda (recommended) conda create -y -n SwinT

LitingLin 196 Jan 04, 2023
Multi-Glimpse Network With Python

Multi-Glimpse Network Multi-Glimpse Network: A Robust and Efficient Classification Architecture based on Recurrent Downsampled Attention arXiv Require

9 May 10, 2022
A Python library for Deep Probabilistic Modeling

Abstract DeeProb-kit is a Python library that implements deep probabilistic models such as various kinds of Sum-Product Networks, Normalizing Flows an

DeeProb-org 46 Dec 26, 2022
Implementation of ConvMixer for "Patches Are All You Need? 🤷"

Patches Are All You Need? 🤷 This repository contains an implementation of ConvMixer for the ICLR 2022 submission "Patches Are All You Need?" by Asher

CMU Locus Lab 934 Jan 08, 2023
AdvStyle - Official PyTorch Implementation

AdvStyle - Official PyTorch Implementation Paper | Supp Discovering Interpretable Latent Space Directions of GANs Beyond Binary Attributes. Huiting Ya

Beryl 37 Oct 21, 2022
YOLOV4运行在嵌入式设备上

在嵌入式设备上实现YOLO V4 tiny 在嵌入式设备上实现YOLO V4 tiny 目录结构 目录结构 |-- YOLO V4 tiny |-- .gitignore |-- LICENSE |-- README.md |-- test.txt |-- t

Liu-Wei 6 Sep 09, 2021
[Arxiv preprint] Causality-inspired Single-source Domain Generalization for Medical Image Segmentation (code&data-processing pipeline)

Causality-inspired Single-source Domain Generalization for Medical Image Segmentation Arxiv preprint Repository under construction. Might still be bug

Cheng 31 Dec 27, 2022
The official implementation for "FQ-ViT: Fully Quantized Vision Transformer without Retraining".

FQ-ViT [arXiv] This repo contains the official implementation of "FQ-ViT: Fully Quantized Vision Transformer without Retraining". Table of Contents In

132 Jan 08, 2023
This code is part of the reproducibility package for the SANER 2022 paper "Generating Clarifying Questions for Query Refinement in Source Code Search".

Clarifying Questions for Query Refinement in Source Code Search This code is part of the reproducibility package for the SANER 2022 paper "Generating

Zachary Eberhart 0 Dec 04, 2021
Rule Based Classification Project For Python

Rule-Based-Classification-Project (ENG) Business Problem: A game company wants to create new level-based customer definitions (personas) by using some

Deniz Can OĞUZ 4 Oct 29, 2022
Pixel-level Crack Detection From Images Of Levee Systems : A Comparative Study

PIXEL-LEVEL CRACK DETECTION FROM IMAGES OF LEVEE SYSTEMS : A COMPARATIVE STUDY G

Manisha Panta 2 Jul 23, 2022
Chainer Implementation of Semantic Segmentation using Adversarial Networks

Semantic Segmentation using Adversarial Networks Requirements Chainer (1.23.0) Differences Use of FCN-VGG16 instead of Dilated8 as Segmentor. Caution

Taiki Oyama 99 Jun 28, 2022