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

Two QuantumError objects with the same superoperator affect a CX gate differently #1425

Closed
Firepanda415 opened this issue Jan 13, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Firepanda415
Copy link

Informations

  • Qiskit version: 0.34.1
  • Qiskit Aer version: 0.10.1
  • Python version: 3.8.10
  • Operating system: Ubuntu 20.04.3 LTS (Windows Subsystem for Linux 2)

What is the current behavior?

The two 2-qubit errors with the same superoperator affects the same CNOT gate in different ways.

Steps to reproduce the problem

import numpy as np
from qiskit import QuantumCircuit
from qiskit.providers.aer import AerSimulator
import qiskit.providers.aer.noise as noise
from qiskit.providers.aer.noise import QuantumError
from qiskit.providers.aer.noise import thermal_relaxation_error
from qiskit.quantum_info import SuperOp

# Make a circuit
circ = QuantumCircuit(2)
circ.cx(0,1)
circ.save_superop(pershot=False)

# Create a 2-qubit thermal relaxation error
gate_len_1 = 200
gate_len_2 = 200
T1_1 = 100
T1_2 = 100
T2_1 = 100
T2_2 = 100
error_1 = thermal_relaxation_error(T1_1, T2_1, gate_len_1, excited_state_population=0)
error_2 = thermal_relaxation_error(T1_2, T2_2, gate_len_2, excited_state_population=0)
error = error_1.expand(error_2)

# Noise model 1, add error directly
noise_model_1 = noise.NoiseModel()
noise_model_1.add_quantum_error(error, ['cx'], [0,1]) # apply the error to CX(0,1)
# Make a corresponding noisy simulator
simulator_1 = AerSimulator(method='superop', noise_model=noise_model_1)

# Perform a noise simulation, record the super operator of noisy CX gate
result_1 = simulator_1.run(circ.copy()).result()
superop_CX_1= result_1.data()['superop'].data

# Noise model 2, make the same error, but from the superoperator
noise_model_2 = noise.NoiseModel()
error_ver_2 = QuantumError(error.to_quantumchannel()) 
noise_model_2.add_quantum_error(error_ver_2, ['cx'], [0,1])
# Make a corresponding noisy simulator
simulator_2 = AerSimulator(method='superop', noise_model=noise_model_2)

# Perform a noise simulation, record the super operator of noisy CX gate
result_2 = simulator_2.run(circ.copy()).result()
superop_CX_2= result_2.data()['superop'].data

# To check if both error and error_ver_2 has the same superoperator
print(np.linalg.norm(error.to_quantumchannel().data - error_ver_2.to_quantumchannel().data)) # it prints 1.452288788600663e-15.

# To check if both noise model gives the same noisy CNOT gate
print(np.linalg.norm(superop_CX_1 - superop_CX_2)) # it prints 2.4265909917740323

What is the expected behavior?

I suppose print(np.linalg.norm(superop_CX_1 - superop_CX_2)) gives a very small number (in the scale of 1e-12 to 1e-16). Because both noise models apply the same noise superoperator to the same CNOT gate. In fact, in the noise model 2, if I write error_ver_2 = QuantumError(error), both noisy CNOT gates are exactly the same.

Thanks for your time! If it is just because I did not understand how QuantumError works, then I apologize for the trouble, and please enlighten me.

Muqing

@Firepanda415 Firepanda415 added the bug Something isn't working label Jan 13, 2022
@jakelishman
Copy link
Member

I think this is a manifestation of the same bug as #1415. Could you try upgrading to Aer 0.10.2 and check whether it works correctly there? (For what it's worth, I get the same results up to 1ULP with Aer 0.10.2+, but can reproduce your error with Aer 0.10.1.)

@Firepanda415
Copy link
Author

Thank you. It is indeed the same issue. I have no problem with Aer 0.10.2.

I think this is a manifestation of the same bug as #1415. Could you try upgrading to Aer 0.10.2 and check whether it works correctly there? (For what it's worth, I get the same results up to 1ULP with Aer 0.10.2+, but can reproduce your error with Aer 0.10.1.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants