Skip to main content

High performance quantum sims on qudits

Project description

icon

qudit

High performance simulations for qudit systems. To make qudit machine learning, qudit error correction, and qudit circuit simulation easier. Qudit is made fully around numpy and pytorch to make it easy to mix and match tools without worrying about type errors.

PyPI version

pip install qudit

Quickstart

In most cases it should not matter if you mix and match numpy with qudit since most abstractions are built on top of numpy arrays. The following is two examples to do the same thing, one using the Circuit class and the other manually using the matrices.

Using the Circuit class:

from qudit import Circuit
import numpy as np

C = Circuit(2, dim=2)  # 2 qBits with d=2
G = C.gates[2]

C.gate(G.H, dits=[0])
C.gate(G.CX, dits=[0, 1])

ket0 = np.zeros(2**2)
ket0[0] = 1.0  # |00>

print(C(ket0))  # [1. 0. 0. 1.]/rt2

Contributing

Qudit has a small shell scripts used to generate documentation and run tests. If you want to contribute, please fork the repo and make a pull request with your changes. The running script is do.

./do helper script

The repository includes a small ./do helper for common workflows (build, tests, docs, etc.).

./do help

Commands

  • ./do build
    • Builds sdist + wheel and runs twine check dist/*.
  • ./do deploy
    • Uploads dist/* to PyPI via twine upload using an API token.
    • Token is read from FILE (defaults to .vscode/token.env).
  • ./do test
    • Runs the Python test scripts in ./tests.
  • ./do prof
    • Profiles ./tests/bench_fast.py with cProfile and opens snakeviz.
  • ./do head
    • Runs python ./view/headers.py (used by the docs pipeline).
  • ./do docs dev
    • Runs the docs dev server (npm run dev).
  • ./do docs build
    • Builds the docs (npm run build).

Common workflows

# run test scripts
./do test

# build packages locally
./do build

# build docs
./do docs build

# docs dev server
./do docs dev

PyPI token setup (for deploy)

Create a file containing only your PyPI API token (no export, no quotes):

  • default location: .vscode/token.env
  • or specify a different file via FILE=path/to/token.env

Example:

FILE=.vscode/token.env ./do deploy

Acknowledgements

Many many thanks to Sai Sakunthala and R-Phoenix for testing and fixing bugs!

This library is built on top of pytorch, and takes ideas from Qiskit, Cirq, and QuDiet.

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

qudit-0.3.1.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qudit-0.3.1-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file qudit-0.3.1.tar.gz.

File metadata

  • Download URL: qudit-0.3.1.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for qudit-0.3.1.tar.gz
Algorithm Hash digest
SHA256 cce4fce8ed2f409eca510c49fbefb38ebf92d7bd27fd65298f5969152eaa8048
MD5 d829620e282b7b64e986f1a079925000
BLAKE2b-256 1ee6ce78782ac5e1cf3d94202092a9460cffbf112a329bea6ccbd893543815bc

See more details on using hashes here.

File details

Details for the file qudit-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: qudit-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for qudit-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4775ca8613c6d5c75a6f46aac106c38603097d7d786f3e3b6d131d0c30bc9a57
MD5 a747f7360b8ad9b2ae0f4c7fbb53a2b7
BLAKE2b-256 255ebe2e75c0ede82bae0dd963a53b9ee5d6eb9e6aed2230db720399045ff2eb

See more details on using hashes here.

Supported by

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