Prepare Uniform Superposition#

from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register
from qualtran import QBit, QInt, QUInt, QAny
from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma
from typing import *
import numpy as np
import sympy
import cirq

PrepareUniformSuperposition#

Prepares a uniform superposition over first \(n\) basis states using \(O(log(n))\) T-gates.

Performs a single round of amplitude amplification and prepares a uniform superposition over the first \(n\) basis states \(|0>, |1>, ..., |n - 1>\). The expected T-complexity should be \(10 * log(L) + 2 * K\) T-gates and \(2\) single qubit rotation gates, where \(n = L * 2^K\).

However, the current T-complexity is \(12 * log(L)\) T-gates and \(2 + 2 * (K + log(L))\) rotations because of two open issues:

  • https://github.com/quantumlib/Qualtran/issues/233 and

  • https://github.com/quantumlib/Qualtran/issues/235

Parameters#

  • n: The gate prepares a uniform superposition over first \(n\) basis states.

  • cvs: Control values for each control qubit. If specified, a controlled version of the gate is constructed.

References#

from qualtran.bloqs.state_preparation import PrepareUniformSuperposition

Example Instances#

prep_uniform = PrepareUniformSuperposition(n=5)
c_prep_uniform = PrepareUniformSuperposition(n=5, cvs=[1])

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([prep_uniform, c_prep_uniform],
           ['`prep_uniform`', '`c_prep_uniform`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
prep_uniform_g, prep_uniform_sigma = prep_uniform.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(prep_uniform_g)
show_counts_sigma(prep_uniform_sigma)
../../_images/688dfc620d8ee18920e8ddcab03fa8488c49f2f39a177a6c0fb99e1037b1fd5a.svg

Counts totals:

  • Allocate: 1

  • Free: 1

  • H: 9

  • LessThanConstant: 2

  • MultiAnd(n=3): 1

  • MultiAnd(n=3)†: 1

  • Rz(1.369438406004566): 2