Code Monkey home page Code Monkey logo

pyquil's Introduction

PyQuil: Quantum programming in Python

pipeline status build status docs status pypi downloads pypi version conda-forge version slack workspace

PyQuil is a Python library for quantum programming using Quil, the quantum instruction language developed at Rigetti Computing. PyQuil serves three main functions:

PyQuil has a ton of other features, which you can learn more about in the docs. However, you can also keep reading below to get started with running your first quantum program!

Installation

Please Note: PyQuil, along with quilc, the QVM, and other libraries, make up what is called the Forest SDK. To make full use of pyQuil's functionality, you will need to additionally have installed quilc and the QVM. This can be done by following their respective READMEs, or by downloading them as binaries from here.

PyQuil can be installed using conda, pip, or directly from source.

To install pyQuil as a conda package from the conda-forge channel (recommended), do the following:

conda install -c conda-forge pyquil

To instead install pyQuil as a PyPI package, do the following:

pip install pyquil

Finally, if you would prefer to install pyQuil directly from source, do the following from within the repository after cloning it:

pip install -e .

If you choose to use pip, we highly recommend installing pyQuil within a virtual environment.

Getting Started

In just a few lines, we can use pyQuil with the Forest SDK to simulate a Bell state!

from pyquil import get_qc, Program
from pyquil.gates import CNOT, H, MEASURE
 
qvm = get_qc('2q-qvm')
 
p = Program()
p += H(0)
p += CNOT(0, 1)
ro = p.declare('ro', 'BIT', 2)
p += MEASURE(0, ro[0])
p += MEASURE(1, ro[1])
p.wrap_in_numshots_loop(10)
 
qvm.run(p).tolist()

The output of the above program should look something like the following, the statistics of which are consistent with a two-qubit entangled state.

[[0, 0],
 [1, 1],
 [1, 1],
 [1, 1],
 [1, 1],
 [0, 0],
 [0, 0],
 [1, 1],
 [0, 0],
 [0, 0]]

Running on the QPU

Using the Forest SDK, you can simulate the operation of a real quantum processor. If you would like to run on the real QPUs in our lab in Berkeley, you can sign up for an account on Quantum Cloud Services!

Joining the Forest Community

Join the public Forest Slack channel at http://slack.rigetti.com.

The following projects have been contributed by community members:

Contributing to pyQuil

To make changes to PyQuil itself see DEVELOPMENT.md for instructions on development and testing.

Citing pyQuil and Forest

If you use pyQuil, Grove, or other parts of the Rigetti Forest stack in your research, please cite it as follows:

BibTeX:

@misc{1608.03355,
  title={A Practical Quantum Instruction Set Architecture},
  author={Smith, Robert S and Curtis, Michael J and Zeng, William J},
  journal={arXiv preprint arXiv:1608.03355},
  year={2016}
}

Text:

R. Smith, M. J. Curtis and W. J. Zeng, "A Practical Quantum Instruction Set Architecture," (2016), 
  arXiv:1608.03355 [quant-ph], https://arxiv.org/abs/1608.03355

License

PyQuil is licensed under the Apache License 2.0.

pyquil's People

Contributors

ampolloreno avatar appleby avatar astaley avatar caryan avatar cbosborn avatar echelon9 avatar ecpeterson avatar ejdanderson avatar gecrooks avatar harleypatton avatar jclapis avatar joshcombes avatar jotterbach avatar karalekas avatar kylegulshen avatar lcapelluto avatar mossheim avatar mpharrigan avatar msohaibalam avatar mstechly avatar ncrubin avatar notmgsk avatar ntezak avatar rht avatar riccardomanenti avatar ryankarle avatar stevenheidel avatar stylewarning avatar vontell avatar willzeng avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.