-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Description
Example code:
from qualtran.bloqs.state_preparation import PrepareUniformSuperposition
from qualtran.resource_counting import get_cost_value, QubitCount
from qualtran.drawing import show_bloqs
bloq = PrepareUniformSuperposition(n=3,cvs=(1,))
cbloq = bloq.decompose_bloq()
cbloq_flat = cbloq.flatten()
print(get_cost_value(bloq, QubitCount()))
print(get_cost_value(cbloq, QubitCount()))
print(get_cost_value(cbloq_flat, QubitCount()))
show_bloqs([bloq, cbloq, cbloq_flat])
Output:
7
6
3
The correct answer for all 3 cases should be 7. The fully flattened bloq seems to completely ignore the allocations / deallocations happening in the decomposition and reports the answer to be 3 (which is equal to the number of qubits in the signature). This trend also continues for larger values of n
. For example:
bloq = PrepareUniformSuperposition(n=10000,cvs=(1,))
cbloq = bloq.decompose_bloq()
cbloq_flat = cbloq.flatten()
print(get_cost_value(bloq, QubitCount()))
print(get_cost_value(cbloq, QubitCount()))
print(get_cost_value(cbloq_flat, QubitCount()))
print(bloq.signature.n_qubits())
Output:
27
22
15
15
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working