1
$\begingroup$

When I try to transpile circuit with Qiskit, I can use 'ry' as a basis gate. But I want to set one of the basis gate as $R_y(\pi/2)$. How can I do that?

Edited:

my_z2 = QuantumCircuit(1,name='z2') my_z2.rz(np.pi,0) z2_def = QuantumCircuit(1) z2_def.append(my_z2.to_gate(),[0]) StandardEquivalenceLibrary.add_equivalence(RZGate(np.pi), z2_def) qc = QuantumCircuit(1) qc.rz(np.pi,0) qc_trans = transpile(qc, basis_gates=['id','z2'],translation_method='translator') qc_trans.draw('mpl') 

This is my code and it throws CircuitError: CircuitError: 'Cannot bind parameters (rz[0]) not present in the circuit.'

How can I fix this?

$\endgroup$
5
  • 1
    $\begingroup$ You can define $R_y(\pi/2)$ as a custom gate, then follow the method described here: quantumcomputing.stackexchange.com/a/17861/9474 $\endgroup$ Commented Dec 22, 2021 at 8:37
  • $\begingroup$ Thanks. But I cannot find the code corresponds to StandardEquivalenceLibrary.add_equivalence(CXGate(), mycx_def). StandardEquivalenceLibrary seems not exist. $\endgroup$ Commented Dec 22, 2021 at 8:49
  • $\begingroup$ from qiskit.circuit.library.standard_gates.equivalence_library import StandardEquivalenceLibrary $\endgroup$ Commented Dec 22, 2021 at 9:14
  • $\begingroup$ I follow the steps but it raise a circuit error. $\endgroup$ Commented Dec 22, 2021 at 10:25
  • $\begingroup$ @Inm do you need to just transpile to a circuit with that basis, or then actually compile it to be executed on a machine? $\endgroup$ Commented Jan 4, 2022 at 4:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.