A framework for quantum algorithms
Project description
QFrame package for quantum calculations
QFrame is a Python library layered over Eclipse Qrisp, which enables you to search for solutions to equations of the form $g(x, y, z)=(x_t, y_t, z_t)$.
The library provides operations to define the function of interest $g(x, y, z)$ and then applies the partial oracle search algorithm to find the solution values $x_s, y_s, z_s$ that satisfy $g(x_s, y_s, z_s)=(x_t, y_t, z_t)$ for the given target values $x_t, y_t, z_t$.
QFrame forms part of an ongoing research project into exponentially fast quantum algorithms and is currently in a very early stage of development with limited functionality. The set of function and operations provided in the 0.0.x release are only capable of defining functions $g(\cdot)$ that are classically reversible, so that no quantum advantage is demonstrated. The next phase of research will attempt to extend QFrame's functionality to cover non-trivial functions that are difficult to invert.
Using the QFrame library
The qframe.QFrameUInt type provides an abstract representation of the qubit registers and QFrame provides a limited set of functions and operations for combining QFrameUInt instances.
The following operations and functions are provided by QFrame:
-
$\mathrel{+}=$ operation—defines in-place addition modulo $2^w$, where $w$ is the bit-width of the
QFrameUIntarguments. The following cases are supported:- Given
QFrameUIntinstances $x$ and $y$, the operation $x \mathrel{+}= y$ implements $P,\ket{x}\ket{y} = \ket{x+y}\ket{y}$. - Given a
QFrameUIntinstance $x$ and an integer constant $c$, the operation $x \mathrel{+}= c$ implements $\ket{x}\mapsto\ket{x+c}$. - Given a
QFrameUIntinstance $x$ and a temporary function $t(y)$, such that $V,\ket{y} = \ket{t(y)}$, the operation $x \mathrel{+}= t(y)$ implements $V^\dagger PV \ket{x}\ket{y} = \ket{x + t(y)}\ket{y}$.
- Given
-
qframe.maj(a, b, c)—defines the majority function $Maj(a, b, c)$, where $a$, $b$, and $c$ are $w$-bit registers. Themaj(a, b, c)function is a temporary function, in the sense that it does not permanently change the values of registers $a$, $b$, and $c$. It is intended to be used on the right-hand side of a $\mathrel{+}=$ expression. -
qframe.ch(a, b, c)—defines the choose function $Ch(a, b, c)$, where $a$, $b$, and $c$ are $w$-bit registers. Thech(a, b, c)function is a temporary function, in the sense that it does not permanently change the values of registers $a$, $b$, and $c$. It is intended to be used on the right-hand side of a $\mathrel{+}=$ expression. -
qframe.Rotrclass—can be used to define shift operator instances. For example,r = qframe.Rotr(4, [0, 1], shr_list=[3])defines a 4-bit wide shift operator of type $\mu=(0,1)(3)$. Ther.shift_inline(x)method can then be invoked to apply the shift function to register $x$. If you need to add the result of a shift operation to another register in a $\mathrel{+}=$ expression, you should invoker.shift(x), which acts as a temporary function (leaving register $x$ unchanged after the addition operation).
This utility provides all of the operations and functions you would need to implement the SHA-256 algorithm. After defining an algorithm with QFrame, the QFrameSession object provides access to the following generated methods:
-
QFrameSession.calculate(input_args)—implements the classical function $g(\cdot)$, taking the giveninput_argvalues for the registers and returning the values of the registers after calculating $g(\cdot)$. -
QFrameSession.apply_oracle_gate(target_dict)—generates the circuit of the oracle function, where the relevant target values are specified by thetarget_dictargument. -
QFrameSession.apply_recip_oracle_gate()—generates the circuit for the reciprocal oracle function, $R[f(\cdot)]$. -
QFrameSession.partial_oracle_iteration(target_dict)—generates complete code for the partial oracle algorithm (except for the initialization of the qubit registers).
Examples
A set of working examples will shortly be published in a GitHub repository.
In the meantime, you can get an idea of how to use the library functions by looking at the test files in tests/core.
Running unit tests
Use hatchling to run unit tests (based on pytest):
hatch test
To see the output from print statements while running the tests, enter:
hatch test --capture=no
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qframe-0.0.3.tar.gz.
File metadata
- Download URL: qframe-0.0.3.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2755e05ae4e6c65f629e5717f184132dda686a80ae0ffee0afb19ab6bf4bf15
|
|
| MD5 |
71cbb272e0522835fad9e7d61dbe5748
|
|
| BLAKE2b-256 |
269087881e6dfd14d2ccb1da3caf8a4df1cf0859d4a2833d09174e1c565b78c5
|
Provenance
The following attestation bundles were made for qframe-0.0.3.tar.gz:
Publisher:
python-publish.yml on bradan-quantum/qframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qframe-0.0.3.tar.gz -
Subject digest:
a2755e05ae4e6c65f629e5717f184132dda686a80ae0ffee0afb19ab6bf4bf15 - Sigstore transparency entry: 1185376341
- Sigstore integration time:
-
Permalink:
bradan-quantum/qframe@800f4279dda1f70dacdcf06dea25faa560442110 -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/bradan-quantum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@800f4279dda1f70dacdcf06dea25faa560442110 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qframe-0.0.3-py3-none-any.whl.
File metadata
- Download URL: qframe-0.0.3-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb7f53ad96855302b330910902dd1d2b2af36663c745ae7d00cb3960519f1d0c
|
|
| MD5 |
6749f0e7a251aab494a22a1010a7395a
|
|
| BLAKE2b-256 |
b89640e8f78f049dbf587429e2058bbca352cf0129b91c7f1f994b0f13410d10
|
Provenance
The following attestation bundles were made for qframe-0.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on bradan-quantum/qframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qframe-0.0.3-py3-none-any.whl -
Subject digest:
eb7f53ad96855302b330910902dd1d2b2af36663c745ae7d00cb3960519f1d0c - Sigstore transparency entry: 1185376369
- Sigstore integration time:
-
Permalink:
bradan-quantum/qframe@800f4279dda1f70dacdcf06dea25faa560442110 -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/bradan-quantum
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@800f4279dda1f70dacdcf06dea25faa560442110 -
Trigger Event:
release
-
Statement type: