PennyLane plugin for ProjectQ
Project description
PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.
ProjectQ 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 ProjectQ as devices for PennyLane.
Features
Provides three devices to be used with PennyLane: projectq.simulator, projectq.ibm, and projectq.classical. These provide access to the respective ProjectQ backends.
Supports a wide range of PennyLane operations and observables across the devices.
Combine ProjectQ 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 ProjectQ. Installation of this plugin, as well as all dependencies, can be done using pip:
$ python -m pip install pennylane_pq
To test that the PennyLane ProjectQ plugin is working correctly you can run
$ make test
in the source folder. Tests restricted to a specific device can be run by executing make test-simulator
, make test-ibm
, or make test-classical
.
Getting started
You can instantiate a 'projectq.simulator'
device for PennyLane with:
import pennylane as qml
dev = qml.device('projectq.simulator', 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(qml.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)
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 'projectq.ibm'
device by giving your IBM Quantum Experience username and password:
import pennylane as qml
dev = qml.device('projectq.ibm', wires=2, user="XXX", password="XXX")
In order to avoid accidentally publishing your credential, you should better specify them via the PennyLane configuration file by adding a section such as
[projectq.global]
[projectq.ibm]
user = "XXX"
password = "XXX"
Please refer to the documentation of the PennyLane ProjectQ 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.
Support
Source Code: https://github.com/XanaduAI/pennylane-pq
Issue Tracker: https://github.com/XanaduAI/pennylane-pq/issues
If you are having issues, please let us know by posting the issue on our Github issue tracker.
License
The PennyLane ProjectQ plugin is free and open source, released under the Apache License, Version 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for PennyLane_PQ-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4a612a644f400912d63349339d82c827ecc6bdffbcb8e1da0604f3a9ca5888d |
|
MD5 | 9507f73c37915f12f807f1ab45a705e3 |
|
BLAKE2b-256 | 7fb889cff35734c99532961405e8f4426f5de261ff650526ccedce6cfa6c3868 |