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

create_arbitrary_state gives different results when too many qubits are specified #167

Open
apozas opened this issue Jun 18, 2018 · 0 comments

Comments

@apozas
Copy link

apozas commented Jun 18, 2018

When using the function grove.alpha.arbitrary_state.arbitrary_state(vector, qubits), inserting qubits that will not be used in the qubits option modifies the output program and the results. Only when len(qubits) =ceil(log2(len(vector))) (i.e., only when the number of qubits specified equals the minimum number of qubits for encoding the state) the result is correct. Here is a MWE:

import pyquil.api as api
import pyquil.quil as pq
from pyquil.gates import I
from grove.alpha.arbitrary_state.arbitrary_state import create_arbitrary_state

good = pq.Program()
bad = pq.Program()
qvm = api.QVMConnection()
# To show that the problem is independent of the position of the qubits
for i in range(6):
    good.inst(I(i))
    bad.inst(I(i))
good.inst(create_arbitrary_state([0,0,0,0,1], [2,3,4]))
print('Good: ', qvm.wavefunction(good))
bad.inst(create_arbitrary_state([0,0,0,0,1], [2,3,4,5]))
print('Bad: ', qvm.wavefunction(bad))

The result being

Good: (1+0j)|010000>
Bad: (0.7071067812+0j)|010000> + (0.3535533906+0j)|100000> + (0.3535533906+0j)|100100> + (0.3535533906+0j)|101000> + (0.3535533906+0j)|101100>

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

No branches or pull requests

1 participant