Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

Add support for multi-indexed data loading for both QROM and SelectSwapQROM

Open tanujkhattar opened this issue 3 years ago • 5 comments

Unary iteration now supports writing nested for-loops by iterating over multiple qubit registers, each of different lengths. This support should be extended to QROM so that we can load, for example, data[i][j] in the target register when selection registers store i and j.

  • For QROM, this should be trivial to extend.
  • For SelectSwapQROM, we need to choose a parameter $k_{i}$ for each nested for-loop and then load $N_{i} / k_{i}$ elements using QROM and do swaps correctly for each loaded batch. See Appendix G of https://arxiv.org/pdf/2011.03494.pdf for more details.

tanujkhattar avatar Nov 14 '22 06:11 tanujkhattar

We also need multi-indexed selectedmajoranafermion and applygatetolthqubit for #107

mpharrigan avatar Jan 04 '23 23:01 mpharrigan

Is this done?

mpharrigan avatar May 08 '24 17:05 mpharrigan

QROM yes (I think). For SelectSwapQROM where I've seen this in the literature they typically form a contiguous index from the multi index and do 1D array access if I'm reading this correctly. Although now that I write this I would assume QROM would also incur a contiguous index formation cost...

fdmalone avatar May 08 '24 18:05 fdmalone

For SelectSwapQROM where I've seen this in the literature they typically form a contiguous index from the multi index and do 1D array access if I'm reading this correctly

@fdmalone The additional cost for computing a contiguous register is required only for the cases where one of the selection indices depends upon the other. For example

for i in range(N):
    for j in range(i):
        # Load data[i][j] ==> This requires computing a contiguous register
for i in range(N):
    for j in range(M):
        # Load data[i][j] ==> This DOES NOT require computing a contiguous register

QROM supports the second case, SelectSwapQROM does not. Appendix G of the linked THC paper explains how to do this for SelectSwapQROM

tanujkhattar avatar May 08 '24 18:05 tanujkhattar

thanks, I always found that appendix confusing.

fdmalone avatar May 08 '24 18:05 fdmalone