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

Greater-than-unity amplitudes for small circuits #298

Open
thisac opened this issue Aug 21, 2020 · 0 comments
Open

Greater-than-unity amplitudes for small circuits #298

thisac opened this issue Aug 21, 2020 · 0 comments

Comments

@thisac
Copy link

thisac commented Aug 21, 2020

When constructing a small qFlex circuit and running it with the default number of cuts (which is 2), the resulting state has a greater-than-unity amplitude. This seems to be due to smaller circuits being fully separable with 2 cuts and thus, as in this case, fully disconnecting parts of the qubit-grid. A simple work-around is to manually create an ordering with no cuts.

A minimal example:

import qflexcirq
import cirq

import numpy as np

q0 = cirq.GridQubit(0, 0)
q1 = cirq.GridQubit(0, 1)
q2 = cirq.GridQubit(0, 2)
q3 = cirq.GridQubit(0, 3)

def basic_circuit():
    yield cirq.H(q0)
    yield cirq.CNOT(q0, q1)
    yield cirq.CNOT(q1, q2)
    yield cirq.CNOT(q2, q3)

circuit = cirq.Circuit()
circuit.append(basic_circuit())

#############################
## Run the QFlex simulator ##
#############################
grid = qflexcirq.QFlexGrid().create_rectangular(1, 4)
qflex_device = qflexcirq.QFlexVirtualDevice(qflex_grid=grid)
circuit = qflexcirq.QFlexCircuit(cirq_circuit=circuit, device=qflex_device)
simulator = qflexcirq.QFlexSimulator()

bitstrings = [f"{i:b}".zfill(4) for i in range(2 ** 4)]

state = simulator.compute_amplitudes(
    program=circuit,
    bitstrings=bitstrings
)

print(np.around(state, 3))

This returns/prints the unnormalized state:

[2.378+0.j 0.   +0.j 0.   +0.j 0.   +0.j 2.378+0.j 0.   +0.j 0.   +0.j 0.   +0.j 2.378+0.j 0.   +0.j 0.   +0.j 0.   +0.j 2.378+0.j 0.   +0.j 0.   +0.j 0.   +0.j]
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