FUQIT
FUQIT is an educational Python package for simulating small quantum circuits.
It is written for students who have a working knowledge of non-relativistic quantum mechanics up to a Masters' level (bra-ket notation, states, unitary evolution, measurement, tensor products, transformations etc.) but are new to quantum computing. FUQIT aims to prepare students for the transition into industry. One can build circuits in code or by clicking gates onto a board in a graphical interface, and see the resulting state, measurement probabilities and simulated measurement counts.
FUQIT is a teaching tool, not a high-performance simulator: it stores every gate as a full matrix, which keeps the linear algebra transparent and is fast enough for the small circuits (a handful of qubits) that are useful for learning.
Features
- States of any number of qubits: from amplitudes, labels such as
"01"or"+-", Bell states and GHZ states, with reduced density matrices, entanglement checks and fidelity. - Gates: X, Y, Z, H, S, T, rotations Rx/Ry/Rz, CNOT, CZ, SWAP and Toffoli, on any qubit(s), plus your own gates from any unitary matrix.
- Circuits: chain gates together, run them, get the overall unitary, invert them, and simulate measurements with a chosen number of shots.
- Graphical interface: choose initial states, build circuits by clicking, step through them in time, compare exact probabilities with simulated measurements, and save, reopen and export circuits.
Installation
FUQIT needs Python 3.10 or newer.
From PyPI
pip install fuqit
From the source code (for development)
-
Clone the repository and move into it:
git clone https://github.com/QC2-python-SE/FUQIT.git cd FUQIT
-
Install the package (this also installs its dependencies: numpy, matplotlib and pillow):
pip install -e .
The
-e("editable") flag means Python uses the code in this folder directly, so any changes you make take effect without reinstalling.To also install the tools for running the tests, use:
pip install -e ".[test]"
-
Check it worked:
python -c "import fuqit; print(fuqit.__version__)"
This should print the version number, e.g.
0.1.0.
The graphical interface uses Tkinter, which comes with Python on Windows and macOS.
On some Linux distributions it is a separate package (e.g. sudo apt install python3-tk).
Quick start
In code
Build a Bell state with a Hadamard and a CNOT:
from fuqit import Circuit
bell = Circuit(2).h(0).cnot(0, 1)
state = bell.run() # starts from |00> by default
print(state) # 0.707|00⟩ + 0.707|11⟩
print(state.probabilities()) # 0.5 for '00' and '11', 0 for '01' and '10'
print(state.is_entangled()) # True
counts = bell.measure(shots=1000) # simulate 1000 measurements
print(counts) # e.g. {'00': 503, '01': 0, '10': 0, '11': 497}
States can also be created directly:
from fuqit import QubitState
QubitState.from_label("+0") # |+>|0>
QubitState.bell("psi-") # (|01> - |10>)/sqrt(2)
QubitState([1, 0, 0, 1]) # amplitudes, normalised automatically
Graphical interface
Launch it with:
python -m fuqit.gui
Click a qubit's label (e.g. |0⟩) to choose its initial state, pick a gate from the
sidebar and click a slot on the board to place it; click a placed gate to remove it.
For a CNOT, click the control qubit first and then the target qubit in the same
column. For rotation gates, type the angle as a multiple of π in the θ box (e.g. 1/2
for π/2). The time axis and slider under the board step through the circuit, the
Measurement box simulates a chosen number of shots, and circuits can be saved,
reopened and exported as images. See the documentation's GUI guide for details.
Conventions
- Qubit ordering: qubit 0 is the leftmost symbol in a ket. So
|10⟩means qubit 0 is in|1⟩and qubit 1 is in|0⟩, and a gate U acting on qubit 0 of a two-qubit register is U ⊗ I. This matches most textbooks (e.g. Nielsen & Chuang), but differs from some software such as Qiskit. - Rotation gates: R_σ(θ) = exp(−iθσ/2) for σ = X, Y, Z, with θ in radians.
- States are immutable: applying a gate returns a new state and never changes the original.
Documentation
The full documentation (installation, a quantum-computing primer for physicists, a GUI guide, tutorials as Jupyter notebooks, and the API reference) is built with MkDocs. To view it locally:
pip install -e ".[docs]"
mkdocs serve
then open the address it prints (usually http://127.0.0.1:8000).
Running the tests
After installing with the test extras (see above), run from the repository folder:
pytest
The tests also run automatically on GitHub for every pull request.
Project structure
src/fuqit/
states.py QubitState: quantum states of n qubits
gates.py Gate class and the standard gates
circuit.py Circuit: sequences of gates, running and measuring
gui/ the graphical circuit builder
tests/ the test suite
Authors
Tabby Lickman, Ben Hancock and Diyaco Shwany.
Metadata
Release files for fuqit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fuqit-0.1.0.tar.gz | 49.3 kB | Without provenance | Details for fuqit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fuqit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fuqit-0.1.0-py3-none-any.whl |
Total release size: 84.6 kB
Release files / fuqit-0.1.0.tar.gz
| Download URL | fuqit-0.1.0.tar.gz |
|---|---|
| Size | 49.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
359b386ed91e02ecf72c26db45cfb21c45297996ef76a98b82dd2be1dde25ecd
|
|
BLAKE2b-256 checksum How to use checksums |
3ec8d6ae8df2ce4ca3e1149bef79a0259d3f6f806543013b2773bab2ede19ceb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fuqit-0.1.0-py3-none-any.whl
| Download URL | fuqit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2249be552a9d42c9253f37f8496574bb0183c2922c232ed565155d4b43e29fc8
|
|
BLAKE2b-256 checksum How to use checksums |
9dc7b728b5ad11158fc8d8445e3fb7bbbf8275b8d9ffee9feab3ad3d26f4f4cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for fuqit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.