2

I'm performing an entanglement swap using 4 qubits in Qiskit. I make my own noisy gates and insert noise in the circuit. I want to create two noisy input Bell pairs of various two different fidelities and, after performing the swap, find the fidelity of the swapped circuit. I'm using a depolarizing error for the CNOT gates and CZ gates. The problem arises when I make the measurement and calculate the fidelity using the Hellinger Fidelity function in Qiskit. For the lower value of two input fidelities, the outcome fidelity is higher than the two input fidelities. How is that possible? Can someone help me with this?

Here is the code below:

def entanglement_swap(f1, f2, dep_errorx, dep_errorz):
    """Simulate entanglement swapping with depolarizing errors and given initial fidelities.
Args:
    f1 (float): Fidelity of the first Bell pair.
    f2 (float): Fidelity of the second Bell pair.
    dep_error (float): Depolarizing error rate for CNOT gates.

Returns:
    float: Estimated fidelity after entanglement swapping.
"""
# Calculate depolarizing error rates to achieve given fidelities f1 and f2
p1 =  (4/3) *(1 - (f1))
p2 =  (4/3) *(1 - (f2))



#prepare the noisy gates 
cx_gate = CXGate()  # regular cnot gate
h_gate = HGate() # regular H gate
cz_gate = CZGate()

cx1_gate = CXGate(label="cx1")  # first labelled CX gate 
cx2_gate = CXGate(label="cx2")  # second labelled CX gate
cx3_gate = CXGate(label="cx3")  # third labelled CX gate 
cx4_gate = CXGate(label="cx4")  # fourth labelled CX gate 

cz1_gate = CZGate(label="cz1")

# create the depolarizing errors for each CX gate
cx1_error = depolarizing_error(p1, 2)   # For the first Bell pair
cx2_error = depolarizing_error(p2, 2)   # For the second Bell pair
cx3_error = depolarizing_error(dep_errorx, 2)
cx4_error = depolarizing_error(dep_errorx, 2)

cz_error = depolarizing_error(dep_errorz, 2)

#readout error only if we perform any sort of measurement
#ro_err_rate = 0.1
#ro_err = ReadoutError( [[1 - ro_err_rate, ro_err_rate], [ro_err_rate, 1 - ro_err_rate]] )


#jot down the noise model
noise_model_gate = NoiseModel()
noise_model_gate.add_all_qubit_quantum_error(cx1_error, cx1_gate.label)
noise_model_gate.add_all_qubit_quantum_error(cx2_error, cx2_gate.label)
noise_model_gate.add_all_qubit_quantum_error(cx3_error, cx3_gate.label)
noise_model_gate.add_all_qubit_quantum_error(cx4_error, cx4_gate.label)

noise_model_gate.add_all_qubit_quantum_error(cz_error, cz1_gate.label)

noise_model_gate.add_readout_error(ro_err, [0])

noise_model_gate.add_basis_gates(['cx','cz1', 'cx1','cx2','cx3','cx4'])       #adds noise to basis gates

# make the quantum circuit with noise gates
bell_noise = QuantumCircuit(4, 2)

#make the first bell pair
bell_noise.h(0)
bell_noise.append(cx1_gate, [0,1])  # first noisy cx gate

#make the second bell pair
bell_noise.h(2)
bell_noise.append(cx2_gate, [2,3])  # second noisy cx gate


bell_noise.append(cx3_gate, [1,2])  # swap noisy cx gate
#bell_noise.cx(1,2)
bell_noise.h(1)

bell_noise.barrier()
bell_noise.append(cz1_gate, [0,1])
#bell_noise.cz(0,1)
#bell_noise.cx(2,3)
bell_noise.append(cx4_gate, [2,3])
bell_noise.barrier()
bell_noise.measure([0,3],[0,1])


# Simulate the circuit with the noise model
basis_gates = noise_model_gate.basis_gates
sim_noise = AerSimulator(noise_model=noise_model_gate, basis_gates = basis_gates)   
rep = 2000
qc_aer = transpile(bell_noise, backend= sim_noise)
result = sim_noise.run(qc_aer, shots=rep).result()
counts = result.get_counts()



# Estimate fidelity (assuming ideal Bell state |Φ+⟩ = (|00⟩ + |11⟩)/√2)

#fidelity = correct_outcomes / rep

return counts

f1 = 0.4 f2 = 0.4

dep_errorx = 0 dep_errorz = 0 noise_counts = entanglement_swap(f1, f2, dep_errorx, dep_errorz) # , dep_errorx, dep_errorz)

#use Hellinger fidelity for ideal and noise count dict fidelity = hellinger_fidelity(counts_ideal, noise_counts) print("Fidelity of entanglement swap F_AC=", fidelity)

>>>>> Fidelity of entanglement swap F_AC= 0.5224602685141051

Note that counts_ideal are the counts distribution from the ideal simulation of a Bell pair.

Martin Vesely
  • 15,398
  • 4
  • 32
  • 75
Travis
  • 21
  • 1

0 Answers0