4

Suppose, you have two parts of a circuit in Qiskit, qc1 and qc2 on any number of qubits such that the entire circuit is given by

qc = qc1.compose(qc2)

For sake of concreteness, here is an example on 2 qubits:

qc1 = QuantumCircuit(2)
qc2 = QuantumCircuit(2)

qc1.h([0,1]) qc2.x(0)

I want to apply a single-qubit channel on the first qubit, say a depolarizing one, in between qc1 and qc2 and then simulate the whole circuit using qiskit. That is, after qc1 and before qc2. After having looked at the Qiskit Aer noise module, my idea would be to introduce a noisy version of an identity gate between the two circuits qc1 and qc2. How to do this?

Marsl
  • 909
  • 6
  • 11
  • Good question! At least according to the documentation, a noise model applies to an execution and not to a specific piece of a circuit. https://qiskit.org/documentation/apidoc/aer_noise.html – Frank Yellin Dec 01 '22 at 19:26
  • Are you open to a classical Monte Carlo like simulation where you execute the circuit again and again? Then you could introduce a u3 gate in between (on a specific qubit) and sample the gate parameters from a distribution of your choice. – Sam Dec 06 '22 at 01:55
  • Thanks for the comment. What you describe is precisely the workaround that I am using at the moment. I just find it extremely annoying that I have to manually implement the effect of the noise myself when there is a noise module. I am looking for an answer that is native to qiskit. – Marsl Dec 06 '22 at 08:50
  • You could do something like https://qiskit.org/documentation/tutorials/simulators/4_custom_gate_noise.html with a u3 gate. – R K Rupesh Dec 07 '22 at 14:33
  • @RKRupesh could you come up with some example code? – Marsl Dec 08 '22 at 10:55
  • Some sample codes are here which might help: https://quantumcomputing.stackexchange.com/questions/8553/how-to-selectively-apply-noise-in-qiskit-simulations/8571#8571 – Sam Dec 15 '22 at 16:00
  • Hi @Sam, thanks for the link. I tried the method there. This method works if one wants to apply noise to a custom non-identity gate. However, when I want to use a custom identity gate, it seems that the transpiler always gets rid of the gate before simulating the circuit which results in no noise applied... – Marsl Dec 19 '22 at 11:29
  • Ah I see. I am guessing you have tried with the optimization_flag set to 0 in the transpile step to prevent transpiler optimization. – Sam Dec 19 '22 at 19:57

0 Answers0