Skip to main content
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 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 pytorch with qudit since most abstractions are built on top of pytorch tensors. 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 torch as pt

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 = pt.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.

Commands

  • ./do help
    • Helper for common workflows (build, tests, docs, etc.)
  • ./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.

Caveats

qudit does not, and will not support openQASM in the near future since hardware is not a goal. There are plans for some amount of interoperability with other qudit simulators, however that will be a long term goal and not a near term one. We will first make qudit stable.

Release files for qudit 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qudit 0.4.1
File Size Uploaded
qudit-0.4.1.tar.gz 47.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qudit 0.4.1
File Interpreter ABI Platform
qudit-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 101.6 kB

Release files / qudit-0.4.1.tar.gz

Download URL qudit-0.4.1.tar.gz
Size 47.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cb737d6d62a82a887b781d280671ce2b5a4fb2fb1d24dce8f4647ba717532a30
BLAKE2b-256 checksum
How to use checksums
6a1549fb05118b5dde8dd9e2c5a83cffedaa8b30db1bbc4a5cc95283f47bb26e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / qudit-0.4.1-py3-none-any.whl

Download URL qudit-0.4.1-py3-none-any.whl
Size 54.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d5dc3720b798e40772c40db59f09a6a717b14e88d9924b2e506cb0fff02878e
BLAKE2b-256 checksum
How to use checksums
9c7abd46c0420ad21537d861ed857d733d638c67106b7e7d9aef0848c93cb1a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page