quantumlib / Qualtran

Qᴜᴀʟᴛʀᴀɴ is a Python library for expressing and analyzing Fault Tolerant Quantum algorithms.
https://qualtran.readthedocs.io/en/latest/
Apache License 2.0
132 stars 35 forks source link

Support for higher precision in QROMs #1056

Open kjm538 opened 1 month ago

kjm538 commented 1 month ago

This line in QROMBase limits the precision for the data used in SelectSwapQROM. https://github.com/quantumlib/Qualtran/blob/0d8793e8a7f415d6ec1e003756422d72ac81a3a1/qualtran/bloqs/data_loading/qrom_base.py#L238

For some applications, the target bitsize for the data I need to load is quite high. I am able to represent them as integers since Python integers have unlimited precision, but the use of a numpy array above results in the error RuntimeWarning: invalid value encountered in cast and prevents resource analysis.

To reproduce the error:

powers = [61,62,63,64]
for p in powers:
    data = [2**p,2**p-2**32,2**p-2**50]
    qroam_gate = SelectSwapQROM([data],target_bitsizes=(max(data).bit_length(),),selection_bitsizes=(len(data),))
    print(t_complexity(qroam_gate))