Skip to main content

No project description provided

Project description

Guppy

Guppy is a quantum programming language that is fully embedded into Python. It allows you to write high-level hybrid quantum programs with classical control flow and mid-circuit measurements using Pythonic syntax:

from guppylang import guppy, Qubit, quantum

guppy.load(quantum)

# Teleports the state in `src` to `tgt`.
@guppy
def teleport(src: Qubit, tgt: Qubit) -> Qubit:
   # Create ancilla and entangle it with src and tgt
   tmp = Qubit()
   tmp, tgt = cx(h(tmp), tgt)
   src, tmp = cx(src, tmp)
   
   # Apply classical corrections
   if measure(h(src)):
      tgt = z(tgt)
   if measure(tmp):
      tgt = x(tgt)
   return tgt

More examples and tutorials are available here.

Install

Guppy can be installed via pip. Requires Python >= 3.10.

pip install guppylang

Usage

See the Getting Started guide and the other examples.

Development

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Python >= 3.10
  • Poetry
  • Rust >= 1.75.0 (only needed for tests)

Installing

Run the following to setup your virtual environment and install dependencies:

poetry install --with validation

Note that the --with validation flag is optional and only needed to run integration tests.

You can then activate the virtual environment and work within it with:

poetry shell

Consider using direnv to automate this when entering and leaving a directory.

To run a single command in the shell, just prefix it with poetry run.

Pre-commit

Install the pre-commit hook by running:

poetry run pre-commit install

Testing

Run tests using

poetry run pytest -v

You have to install extra dependencies to test automatic circuit conversion from pytket:

poetry install --with pytket
poetry run pytest -v  # Now rerun tests

Integration test cases can be exported to a directory using

poetry run pytest --export-test-cases=guppy-exports

which will create a directory ./guppy-exports populated with hugr modules serialised in JSON.

License

This project is licensed under Apache License, Version 2.0 (LICENCE or http://www.apache.org/licenses/LICENSE-2.0).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guppylang-0.1.0.tar.gz (72.6 kB view details)

Uploaded Source

Built Distribution

guppylang-0.1.0-py3-none-any.whl (87.4 kB view details)

Uploaded Python 3

File details

Details for the file guppylang-0.1.0.tar.gz.

File metadata

  • Download URL: guppylang-0.1.0.tar.gz
  • Upload date:
  • Size: 72.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for guppylang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f131c4f28f90b08ef04b9940f8ccdede503b85bde2a000d4d92e1794f198b02
MD5 eb789cf7deed0ff884a016a090fde36f
BLAKE2b-256 813b46346840a922dc7556f91bcbbbfa33793269e9cd3d28084939a8995cd7fe

See more details on using hashes here.

File details

Details for the file guppylang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: guppylang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 87.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for guppylang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 719cc24bc2873069afa0c61ca3cbd08f9c6c14a7259f48b6b0600ce155ef63e7
MD5 246518bbab8502dbccb2c73b8fc966bf
BLAKE2b-256 6354119a7abdeaaa46abec15032774a2b646fd080661c6030342a5657d41137e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page