Giter Club home page Giter Club logo

pennylane-qiskit's Introduction

PennyLane qiskit Plugin

Travis Codecov coverage Codacy grade Read the Docs PyPI PyPI - Python Version

PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

qiskit is an open-source compilation framework capable of targeting various types of hardware and a high-performance quantum computer simulator with emulation capabilities, and various compiler plug-ins.

This PennyLane plugin allows to use both the software and hardware backends of qiskit as devices for PennyLane.

Features

  • Provides two providers to be used with PennyLane: qiskit.basicaer and qiskit.ibm. These provide access to the respective qiskit backends.
  • Supports a wide range of PennyLane operations and expectation values across the providers.
  • Combine qiskit high performance simulator and hardware backend support with PennyLane's automatic differentiation and optimization.

Installation

This plugin requires Python version 3.5 and above, as well as PennyLane and qiskit. Installation of this plugin, as well as all dependencies, can be done using pip:

$ python -m pip install pennylane_qiskit

To test that the PennyLane qiskit plugin is working correctly you can run

$ make test

in the source folder. Tests restricted to a specific provider can be run by executing make test-aer or make test-ibm.

Note

Tests on the ibm provider can only be run if a ibmqx_token for the IBM Q experience is configured in the PennyLane configuration file. If this is the case, running make test also executes tests on the ibm provider. By default tests on the ibm provider run with ibmq_qasm_simulator backend and those done by the basicaer provider are run with the qasm_simulator backend. At the time of writing this means that the test are "free". Please verify that this is also the case for your account.

Getting started

You can instantiate a 'qiskit.basicaer' device for PennyLane with:

import pennylane as qml
dev = qml.device('qiskit.basicaer', wires=2)

This device can then be used just like other devices for the definition and evaluation of QNodes within PennyLane. A simple quantum function that returns the expectation value of a measurement and depends on three classical input parameters would look like:

@qml.qnode(dev)
def circuit(x, y, z):
    qml.RZ(z, wires=[0])
    qml.RY(y, wires=[0])
    qml.RX(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.expval.PauliZ(wires=1)

You can then execute the circuit like any other function to get the quantum mechanical expectation value.

circuit(0.2, 0.1, 0.3)

You can also change the default device's backend with

dev = qml.device('qiskit.basicaer', wires=2, backend='unitary_simulator')

To get a current overview what backends are available you can query this by

dev.capabilities()['backend']

Running your code on an IBM Quantum Experience simulator or even a real hardware chip is just as easy. Instead of the device above, you would instantiate a 'qiskit.ibm' device by giving your IBM Quantum Experience token:

import pennylane as qml
dev = qml.device('qiskit.ibm', wires=2, ibmqx_token="XXX")

In order to avoid any publishing of your token it is also possible to define an environment variable IBMQX_TOKEN, which will be taken if non is provided. Per default the backend ibm uses the simulator backend ibmq_qasm_simulator, but you can change that to be any of the real backends as given by

dev.capabilities()['backend']

Please refer to the documentation of the PennyLane qiskit Plugin as well as well as to the documentation of PennyLane for further reference.

How to cite

If you are doing research using PennyLane, please cite our whitepaper:

Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, and Nathan Killoran. PennyLane. arXiv, 2018. arXiv:1811.04968

Contributing

We welcome contributions - simply fork the repository of this plugin, and then make a pull request containing your contribution. All contributers to this plugin will be listed as authors on the releases.

We also encourage bug reports, suggestions for new features and enhancements, and even links to cool projects or applications built on PennyLane.

Authors

Carsten Blank

Support

If you are having issues, please let us know by posting the issue on our Github issue tracker.

License

The PennyLane qiskit plugin is free and open source, released under the Apache License, Version 2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.