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.
BMVC 2021 Oral: code for BI-GCN: Boundary-Aware Input-Dependent Graph Convolution for Biomedical Image Segmentation

BMVC 2021 BI-GConv: Boundary-Aware Input-Dependent Graph Convolution for Biomedical Image Segmentation Necassary Dependencies: PyTorch 1.2.0 Python 3.

Yanda Meng 15 Nov 08, 2022
Source code of D-HAN: Dynamic News Recommendation with Hierarchical Attention Network

D-HAN The source code of D-HAN This is the source code of D-HAN: Dynamic News Recommendation with Hierarchical Attention Network. However, only the co

30 Sep 22, 2022
Video Frame Interpolation with Transformer (CVPR2022)

VFIformer Official PyTorch implementation of our CVPR2022 paper Video Frame Interpolation with Transformer Dependencies python = 3.8 pytorch = 1.8.0

DV Lab 63 Dec 16, 2022
Research code of ICCV 2021 paper "Mesh Graphormer"

MeshGraphormer ✨ ✨ This is our research code of Mesh Graphormer. Mesh Graphormer is a new transformer-based method for human pose and mesh reconsructi

Microsoft 251 Jan 08, 2023
Indonesian Car License Plate Character Recognition using Tensorflow, Keras and OpenCV.

Monopol Indonesian Car License Plate (Indonesia Mobil Nomor Polisi) Character Recognition using Tensorflow, Keras and OpenCV. Background This applicat

Jayaku Briliantio 3 Apr 07, 2022
Code for the paper "Implicit Representations of Meaning in Neural Language Models"

Implicit Representations of Meaning in Neural Language Models Preliminaries Create and set up a conda environment as follows: conda create -n state-pr

Belinda Li 39 Nov 03, 2022
Tools for investing in Python

InvestOps Original repository on GitHub Original author is Magnus Erik Hvass Pedersen Introduction This is a Python package with simple and effective

24 Nov 26, 2022
Mail classification with tensorflow and MS Exchange Server (ham or spam).

Mail classification with tensorflow and MS Exchange Server (ham or spam).

Metin Karatas 1 Sep 11, 2021
CATE: Computation-aware Neural Architecture Encoding with Transformers

CATE: Computation-aware Neural Architecture Encoding with Transformers Code for paper: CATE: Computation-aware Neural Architecture Encoding with Trans

16 Dec 27, 2022
A smaller subset of 10 easily classified classes from Imagenet, and a little more French

Imagenette 🎶 Imagenette, gentille imagenette, Imagenette, je te plumerai. 🎶 (Imagenette theme song thanks to Samuel Finlayson) NB: Versions of Image

fast.ai 718 Jan 01, 2023
Massively parallel Monte Carlo diffusion MR simulator written in Python.

Disimpy Disimpy is a Python package for generating simulated diffusion-weighted MR signals that can be useful in the development and validation of dat

Leevi 16 Nov 11, 2022
This project deploys a yolo fastest model in the form of tflite on raspberry 3b+. The model is from another repository of mine called -Trash-Classification-Car

Deploy-yolo-fastest-tflite-on-raspberry 觉得有用的话可以顺手点个star嗷 这个项目将垃圾分类小车中的tflite模型移植到了树莓派3b+上面。 该项目主要是为了记录在树莓派部署yolo fastest tflite的流程 (之后有时间会尝试用C++部署来提升

7 Aug 16, 2022
Official public repository of paper "Intention Adaptive Graph Neural Network for Category-Aware Session-Based Recommendation"

Intention Adaptive Graph Neural Network (IAGNN) This is the official repository of paper Intention Adaptive Graph Neural Network for Category-Aware Se

9 Nov 22, 2022
Autotype on websites that have copy-paste disabled like Moodle, HackerEarth contest etc.

Autotype A quick and small python script that helps you autotype on websites that have copy paste disabled like Moodle, HackerEarth contests etc as it

Tushar 32 Nov 03, 2022
Unadversarial Examples: Designing Objects for Robust Vision

Unadversarial Examples: Designing Objects for Robust Vision This repository contains the code necessary to replicate the major results of our paper: U

Microsoft 93 Nov 28, 2022
A torch.Tensor-like DataFrame library supporting multiple execution runtimes and Arrow as a common memory format

TorchArrow (Warning: Unstable Prototype) This is a prototype library currently under heavy development. It does not currently have stable releases, an

Facebook Research 536 Jan 06, 2023
NDE: Climate Modeling with Neural Diffusion Equation, ICDM'21

Climate Modeling with Neural Diffusion Equation Introduction This is the repository of our accepted ICDM 2021 paper "Climate Modeling with Neural Diff

Jeehyun Hwang 5 Dec 18, 2022
Neural Dynamic Policies for End-to-End Sensorimotor Learning

This is a PyTorch based implementation for our NeurIPS 2020 paper on Neural Dynamic Policies for end-to-end sensorimotor learning.

Shikhar Bahl 47 Dec 11, 2022
This repository contains PyTorch code for Robust Vision Transformers.

This repository contains PyTorch code for Robust Vision Transformers.

117 Dec 07, 2022
code for the ICLR'22 paper: On Robust Prefix-Tuning for Text Classification

On Robust Prefix-Tuning for Text Classification Prefix-tuning has drawed much attention as it is a parameter-efficient and modular alternative to adap

Zonghan Yang 12 Nov 30, 2022