Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many Variations of QROAM #368

Open
fdmalone opened this issue Sep 25, 2023 · 5 comments
Open

Many Variations of QROAM #368

fdmalone opened this issue Sep 25, 2023 · 5 comments

Comments

@fdmalone
Copy link
Collaborator

fdmalone commented Sep 25, 2023

I was a little confused about the expected QROM costs when implementing something for THC.

There are at least four possible expected (Toffoli) costs:

  1. No dirty ancilla [1] : d / k + M * (k-1) (this is used for THC prepare)
  2. Dirty Ancilla [1]: 2 d / k + 4 * M * (k - 1)
  3. No dirty ancilla [2] : d / k + 2 * M * k
  4. Dirty ancilla [2] : 2 d / k + 8 M * k

d = data size, k = block size, M = number of bits of output.

[1] https://quantum-journal.org/papers/q-2019-12-02-208/pdf/ (page 9)
[2] https://arxiv.org/pdf/1812.00954.pdf Table II, rows 3 and 4, 4th column

@fdmalone
Copy link
Collaborator Author

Relevant Screenshot from [1]
Screenshot 2023-09-25 at 3 58 11 PM

@fdmalone
Copy link
Collaborator Author

fdmalone commented Sep 25, 2023

Some code

from qualtran.cirq_interop import CirqGateAsBloq
from cirq_ft.algos.select_swap_qrom import SelectSwapQROM
num_bits = 15
data_size = 230
num_blocks = 2
sel_swap = SelectSwapQROM(
        (10,)*data_size,
        target_bitsizes=(15,),
        block_size=2**num_blocks,
    )
qroam = CirqGateAsBloq(
    sel_swap
)
print(qroam.t_complexity())
cost_1 = int(np.ceil(data_size/2**num_blocks))
cost_2 = num_bits * (2**num_blocks - 1)
print(f"THC cost (no dirty ancilla) = {4*(cost_1 + cost_2)}")
print(f"THC cost (dirty ancilla) = {4*(2* cost_1 + 4*cost_2)}")
cost_1 = int(np.ceil(data_size/2**num_blocks))
cost_2 = num_bits * (2**num_blocks)
print(f"Select Swap QROM (no dirty ancilla) = {4*(cost_1 + 2 * cost_2)}")
cost_2 = num_bits * (2**num_blocks)
print(f"Select Swap QROM (dirty ancilla) = {4*(2 * cost_1 + 8 * cost_2)}")
58 4 (15,)
T-count:   744
Rotations: 0
Cliffords: 4150

T-count:   744
Rotations: 0
Cliffords: 4366

THC cost (no dirty ancilla) = 412
THC cost (dirty ancilla) = 1184
Select Swap QROM (no dirty ancilla) = 712
Select Swap QROM (dirty ancilla) = 2384

@fdmalone
Copy link
Collaborator Author

I'm a little concerned that our Tcounts are quite different than what I might expect (option 4) but I imagine there's some leeway with the parameters. cc @tanujkhattar

@fdmalone
Copy link
Collaborator Author

We also need to account for cheaper inversion which has cost:

Screenshot 2023-09-25 at 4 15 33 PM

@fdmalone
Copy link
Collaborator Author

Also QROAM on two registers
Screenshot 2023-11-30 at 10 39 43 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants