Skip to main content

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 QFrameUInt arguments. The following cases are supported:

    • Given QFrameUInt instances $x$ and $y$, the operation $x \mathrel{+}= y$ implements $P\ket{x}\ket{y} = \ket{x+y}\ket{y}$.
    • Given a QFrameUInt instance $x$ and an integer constant $c$, the operation $x \mathrel{+}= c$ implements $\ket{x}\mapsto\ket{x+c}$.
    • Given a QFrameUInt instance $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}$.
  • qframe.maj(a, b, c)—defines the majority function $Maj(a, b, c)$, where $a$, $b$, and $c$ are $w$-bit registers. The maj(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. The ch(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.Rotr class—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)$. The r.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 invoke r.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 given input_arg values 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 the target_dict argument.

  • 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 are available from the following GitHub repository:

https://github.com/bradan-quantum/qframe-examples

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


Download files

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

Source Distribution

qframe-0.0.7.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

qframe-0.0.7-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file qframe-0.0.7.tar.gz.

File metadata

  • Download URL: qframe-0.0.7.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qframe-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e30a2d523e12f6af03b2f5dcc2715ce092e49205c784b6362333500bc4f88057
MD5 0ddcbf072e360c07254306e806215e58
BLAKE2b-256 2818c705db356ce393558d06340d339298436e1ad915b8e076a3dc915df39dd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for qframe-0.0.7.tar.gz:

Publisher: python-publish.yml on bradan-quantum/qframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qframe-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: qframe-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qframe-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 28dc8b6f016a5a5f06a4f3405a1343af4a23cae6dc88470e88095c0143d5afc8
MD5 409d741d872f46f0e1643c7d753ed8e0
BLAKE2b-256 00f0de736963c129dd18c149f1ddf4c8ce3df25d85b69f88f12687e95b889855

See more details on using hashes here.

Provenance

The following attestation bundles were made for qframe-0.0.7-py3-none-any.whl:

Publisher: python-publish.yml on bradan-quantum/qframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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