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

Related tags

Deep Learning orqviz
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.
Learn about quantum computing and algorithm on quantum computing

quantum_computing this repo contains everything i learn about quantum computing and algorithm on quantum computing what is aquantum computing quantum

arfy slowy 8 Dec 25, 2022
[Open Source]. The improved version of AnimeGAN. Landscape photos/videos to anime

[Open Source]. The improved version of AnimeGAN. Landscape photos/videos to anime

CC 4.4k Dec 27, 2022
Filtering variational quantum algorithms for combinatorial optimization

Current gate-based quantum computers have the potential to provide a computational advantage if algorithms use quantum hardware efficiently.

null 1 Feb 9, 2022
Orthogonal Over-Parameterized Training

The inductive bias of a neural network is largely determined by the architecture and the training algorithm. To achieve good generalization, how to effectively train a neural network is of great importance. We propose a novel orthogonal over-parameterized training (OPT) framework that can provably minimize the hyperspherical energy which characterizes the diversity of neurons on a hypersphere. See our previous work -- MHE for an in-depth introduction.

Weiyang Liu 11 Apr 18, 2022
Parameterized Explainer for Graph Neural Network

PGExplainer This is a Tensorflow implementation of the paper: Parameterized Explainer for Graph Neural Network https://arxiv.org/abs/2011.04573 NeurIP

Dongsheng Luo 89 Dec 12, 2022
Code for our CVPR 2021 Paper "Rethinking Style Transfer: From Pixels to Parameterized Brushstrokes".

Rethinking Style Transfer: From Pixels to Parameterized Brushstrokes (CVPR 2021) Project page | Paper | Colab | Colab for Drawing App Rethinking Style

CompVis Heidelberg 153 Jan 4, 2023
Implementation of parameterized soft-exponential activation function.

Soft-Exponential-Activation-Function: Implementation of parameterized soft-exponential activation function. In this implementation, the parameters are

Shuvrajeet Das 1 Feb 23, 2022
Nb workflows - A workflow platform which allows you to run parameterized notebooks programmatically

NB Workflows Description If SQL is a lingua franca for querying data, Jupyter sh

Xavier Petit 6 Aug 18, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
An implementation for the loss function proposed in Decoupled Contrastive Loss paper.

Decoupled-Contrastive-Learning This repository is an implementation for the loss function proposed in Decoupled Contrastive Loss paper. Requirements P

Ramin Nakhli 71 Dec 4, 2022
Implement of "Training deep neural networks via direct loss minimization" in PyTorch for 0-1 loss

This is the implementation of "Training deep neural networks via direct loss minimization" published at ICML 2016 in PyTorch. The implementation targe

Cuong Nguyen 1 Jan 18, 2022
Pytorch Implementations of large number classical backbone CNNs, data enhancement, torch loss, attention, visualization and some common algorithms.

Torch-template-for-deep-learning Pytorch implementations of some **classical backbone CNNs, data enhancement, torch loss, attention, visualization and

Li Shengyan 270 Dec 31, 2022
Scripts of Machine Learning Algorithms from Scratch. Implementations of machine learning models and algorithms using nothing but NumPy with a focus on accessibility. Aims to cover everything from basic to advance.

Algo-ScriptML Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The goal of this project is not t

Algo Phantoms 81 Nov 26, 2022
Simple tools for logging and visualizing, loading and training

TNT TNT is a library providing powerful dataloading, logging and visualization utilities for Python. It is closely integrated with PyTorch and is desi

null 1.5k Jan 2, 2023
Your interactive network visualizing dashboard

Your interactive network visualizing dashboard Documentation: Here What is Jaal Jaal is a python based interactive network visualizing tool built usin

Mohit 177 Jan 4, 2023
A module for solving and visualizing Schrödinger equation.

qmsolve This is an attempt at making a solid, easy to use solver, capable of solving and visualize the Schrödinger equation for multiple particles, an

null 506 Dec 28, 2022
Code for CVPR2021 "Visualizing Adapted Knowledge in Domain Transfer". Visualization for domain adaptation. #explainable-ai

Visualizing Adapted Knowledge in Domain Transfer @inproceedings{hou2021visualizing, title={Visualizing Adapted Knowledge in Domain Transfer}, auth

Yunzhong Hou 80 Dec 25, 2022
Improving Contrastive Learning by Visualizing Feature Transformation, ICCV 2021 Oral

Improving Contrastive Learning by Visualizing Feature Transformation This project hosts the codes, models and visualization tools for the paper: Impro

Bingchen Zhao 83 Dec 15, 2022
QHack—the quantum machine learning hackathon

Official repo for QHack—the quantum machine learning hackathon

Xanadu 72 Dec 21, 2022