0
$\begingroup$

I need to use a random Clifford operator and add it to another circuit. However, the Clifford operator does not seem to be there after application of compose. An example code which illustrates the problem is:

import qiskit as qk
from qiskit.quantum_info import random_clifford
from qiskit.quantum_info import Clifford

qc = qk.QuantumCircuit(3)
U = random_clifford(3,seed=123)
U = Clifford.to_circuit(U)
qc.compose(U,qubits=[0,1,2])
qc.draw("mpl")

If I draw U alone, it gives a nice example of a random Clifford gate. Thus, I guess the error lies in the application of compose, but how can I solve this? It does not throw an error, it just does not happen anything.

$\endgroup$

1 Answer 1

0
$\begingroup$

By default, compose() method returns the composed circuit and keep the original circuit unchanged. For in-place composition, you need to set inplace parameter to True:

qc.compose(U,qubits=[0,1,2], inplace=True)
$\endgroup$
1
  • $\begingroup$ perfect, thank you! $\endgroup$
    – Juri V
    Mar 7, 2023 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.