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 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


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.1.tar.gz (18.0 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.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qframe-0.0.1.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

Hashes for qframe-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3de5ddb89f120660ada76528fa3b51b5665194d6216f235cd71fad7a78b74d41
MD5 9a0c7579e9ef3986939b0f05407775ee
BLAKE2b-256 3ed870ad962a69b1902ef5e3479b86ac5477fb266c0c0ec87cb85d1acdfb4a88

See more details on using hashes here.

Provenance

The following attestation bundles were made for qframe-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: qframe-0.0.1-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

Hashes for qframe-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dad39ea9605a9e648081fc537c82e6b89594824fc993c36aa137cef5de8fbc38
MD5 1e35e5e9b1cd423c6a6ae11422043159
BLAKE2b-256 1c634d1b446046986d97962fd3586814d610b8d78a5dda40f8de9e7302c3b496

See more details on using hashes here.

Provenance

The following attestation bundles were made for qframe-0.0.1-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