0

Step 1 Qisqit : Here is the code of Qiskit. I have initialized the four qubits.

qr1 = QuantumRegister(4)
mea = ClassicalRegister(2) 
circuit = QuantumCircuit(qr1,mea) 
initial=[[1,0],[0,1]]

circuit.initialize(initial[1], 0)
circuit.initialize(initial[1], 1)

#  Uc 
circuit.x(qr1[1])
circuit.ccx(qr1[0],qr1[1],qr1[2])
circuit.x(qr1[0])
circuit.x(qr1[1])
circuit.ccx(qr1[0],qr1[1],qr1[3])
circuit.x(qr1[0])

Its Circut:

enter image description here

Step 2 IBM Qunatum Composer: Here is no such tool to initialize the qubis. Please guide me how to initilize here?

enter image description here

1 Answers1

1

The OpenQASM language is the standard for exchange circuits among several quantum computing tools. You can use to move your Qiskit circuit to the IBM Quantum Composer.

print(circuit.qasm())
OPENQASM 2.0;
include "qelib1.inc";
gate multiplex1_reverse_dg q0 { ry(pi) q0; }
...

You can take the output and paste it in the OpenQASM 2.0 box in IBM Quantum Composer.

Note: At the moment, there is an issue in Qiskit that QASM-exports a circuit with initialize instructions as "gates". For your specific case, you need to do decompose first:

print(circuit.decompose().qasm())

Detailed explanation of initialize: Qiskit initialize is a reset followed by a state preparation. Take the following example:

circuit = QuantumCircuit(1) 
circuit.initialize([0,1], 0)
print(circuit.decompose().qasm())
OPENQASM 2.0;
include "qelib1.inc";
gate multiplex1_reverse_dg q0 { ry(pi) q0; }   #3
gate disentangler_dg q0 { multiplex1_reverse_dg q0; }
gate state_preparation(param0,param1) q0 { disentangler_dg q0; }
qreg q[1];
reset q[0];                  #1
state_preparation(0,1) q[0]; #2

In #1, the reset, followed by state_preparation in #2. After some nested calling, the standard ry is called in #3. In this case, circuit.initialize([0,1], 0) is equivalent to reset q0[0]; ry(pi) q0[0].

luciano
  • 399
  • 4
  • 13
  • But why there is no initializing symbol in IBM Composer – Engr. Khuram Shahzad Nov 05 '22 at 19:00
  • Because different tools support different instruction sets. Both Qiskit and IBM Quantum composer support a superset of the OpenQASM 2.0 instruction set. Both can rewrite their operations in terms of OpenQASM 2.0 and use that to talk to each other. Interoperability among tools is hard. – luciano Nov 05 '22 at 21:45
  • But I am a little bit confused, about how these two are the same, mean initialize in Qiskit or in QASM. Can you little bit explain it. ? – Engr. Khuram Shahzad Nov 07 '22 at 06:57
  • Qiskit `initialize` is a `reset` followed by a state preparation (see https://qiskit.org/documentation/stubs/qiskit.extensions.Initialize.html). It's instruction that is composed by these two operations, like a routine calling other subroutines in regular procedural programming. I added an explanation of a OpenQASM2 to illustrate that. You could implement your own `initialize` for this case in IBM Quantum Experience with `reset q0[0]; x q0[0]`. – luciano Nov 07 '22 at 09:52