-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
A student pointed me to unexpected measurement outcomes of the Phi^+ state when both qubits are measured in the computational basis. I removed some code from the tutorial to create a minimal example (see below, note that I fixed the random seed for reproducibility). When running this setup many times by adjusting num_times=1 to num_times=1000 in run_simulation.py, it prints:
- run 109: "Alice measures local qubits: 0, 1"
- run 177: "Alice measures local qubits: 1, 0"
which are outcomes I don't expect when measuring Phi^+. Did I do something wrong?
The only thing I can imagine that happens is that Qubit(connection) is not initialised in |0> by default. Is that the case?
Minimal application.py:
from netqasm.sdk.classical_communication.socket import Socket
from netqasm.sdk.connection import BaseNetQASMConnection
from netqasm.sdk.epr_socket import EPRSocket
from netqasm.sdk.qubit import Qubit
from squidasm.util.util import get_qubit_state
import netsquid as ns
from squidasm.sim.stack.program import Program, ProgramContext, ProgramMeta
ns.set_random_state(seed=0)
class AliceProgram(Program):
PEER_NAME = "Bob"
@property
def meta(self) -> ProgramMeta:
return ProgramMeta(
name="tutorial_program",
csockets=[self.PEER_NAME],
epr_sockets=[self.PEER_NAME],
max_qubits=1,
)
def run(self, context: ProgramContext):
# get connection to quantum network processing unit
connection = context.connection
# Qubits on a local node can be obtained, but require the connection to be initialized
local_qubit0 = Qubit(connection)
local_qubit1 = Qubit(connection)
# Apply a Hadamard gate
local_qubit0.H()
# Apply CNOT gate where q0 is the control qubit, q1 is the target qubit
local_qubit0.cnot(local_qubit1)
r0 = local_qubit0.measure()
r1 = local_qubit1.measure()
yield from connection.flush()
print(f"Alice measures local qubits: {r0}, {r1}")
return {}
class BobProgram(Program):
PEER_NAME = "Alice"
@property
def meta(self) -> ProgramMeta:
return ProgramMeta(
name="tutorial_program",
csockets=[self.PEER_NAME],
epr_sockets=[self.PEER_NAME],
max_qubits=1,
)
def run(self, context: ProgramContext):
return {}Metadata
Metadata
Assignees
Labels
No labels