Skip to content

ushukkla/QOSF-Screening-Task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

QOSF-Screening-Task

Solution to Task-3, for QOSF mentor-ship program. The quantum gates are the building blocks for any given quantum circuit. The idea to use a restricted set of gates to construct a particular circuit. The code snipets are written in QISkit and can be simulated on the IBMQ Experience.

The restricted gates include RX, RZ and CZ. The rotation operators are generated by exponentiation of the Pauli matrices according to:

exp(iAx) = cos(x)I + i sin(x)A

where A is one of the 3 Pauli matrices.

  • Hadamard Gate - H Gate - After compilation the H gate looks like:
qc = QuantumCircuit(2) 
qc.rx(pi/2)
qc.rz(pi/2)

The RX and RZ gates are rotation operators which are reduce the former H gate into rotations on the X and Z axes.

  • X gate - The X gate acts on a single quibt and flips its state. It is the quantum equivalent of a NOT gate in classical terms. This gate is essentially a single-qubit rotation through pi radians around the x-axis. This is also known as Pauli-X gate. After compilation, the x gate looks like:
qc = QuantumCircuit(1)
qc.rx(pi)
  • Y gate - The Y gate again acts on the a single qubit. This gate performs a single-qubit rotation through pi radians around the y-axis. This gate is derived from the Pauli matrices. After compilation the y gate looks like:
qc = QuantumCircuit(1)
qc.ry(pi)
  • Z gate - The Z gate, similar to the X and the Y gates, performs a single-qubit rotation through pi radians around the Z axis. This gate is also called the Pauli Z gate, as it is derived from the Pauli matrices.
qc = QuantumCircuit(1)
qc.rz(pi)
  • CX gate - The CX gate, also called the CNOT or the Controlled-NOT gate is a two-qubit operation, where the first qubit is generally called the control qubit and the second qubit is called the target qubit. Demonstrated in the basis states, the CNOT gate:
    1. performs an X gate operation on the target qubit, when the control qubit is in state |1>
    2. makes no change to the target qubit, when the control qubit is in state |0>

The CNOT gate does not make any change to the control qubit, whatsoever. To apply a CNOT gate to a pair of qubits, we first need to get them entangled using the hadamard gate and then implementing the X gate.

qc = QuantumCircuit(2) 
qc.h(0) #add H gate on qubit 0 
qc.cx(0,1) #add cx gate on control qubit 0 and target qubit 1

After compiling, the CNOT gate takes the form:

qc = QuantumCircuit(2) 
qc.rx(pi/2,0)
qc.rz(pi/2,0)
qc.rx(pi,c,t)

where the t refers to the target qubit and c refers to the control qubit and 0 is the first qu

  • CZ gate - The CZ gate or the CPhase gate, in the computational basis, flips the phase of the target qubit if the control qubit is in state |1>.
#controlled-Z gate
qc = QuantumCircuit(2)
c = 0 
t = 1 
qc.cz(c,t)

We know that HXH = Z and HZH = X. Hence, we convert CZ in terms of CNOT gate.

qc = QuantumCircuit(2)
qc.h(t)
qc.cx(c,t)
qc.h(t)

After compilation i.e. using a restricted set of gates, we get,

qc = QuantumCircuit(2)
qc.rx(pi/2,t)
qc.rz(pi/2,t)
qc.rx(pi/2,c)
qc.rz(pi/2,c)
qc.rx(pi,c,t)
qc.rx(pi/2,t)
qc.rz(pi/2,t)

By simply preceding and following the CNOT gate with the correct rotations, we can convert a single CNOT into a controlled version of any rotation around the Bloch sphere by an angle pi.

ANALYSING THE OVERHEAD

The overhead, here,is described as the involvement of the gates with each other in the resulting circuit than the original one. The compiled circuit is actually dependent on its components. The gates in the circuit are rotations on teh Bloch sphere. The concept of Bloch sphere makes it easier to understand the workings of a qubit but at the same time make the circuit much more complicated. There's a repetition of rotations and the same rotations are being repeated for the same qubit to perform a particular operation. This increases the complexity of the circuit and hence the overhead.

The overhead can be improved by reducing the number of rotations that are taking place on the same qubits. The same rotations can be tied in 'bundles' and executed together in the circuit. The circuit can be modified to accomodate these bundles instead of the gates.

The concept of using Spiders instead of gates is also a way to reduce the overhead of the circuit. The ZX-diagram in the ZX calculus, consists of a set of generators called spiders. These represent specific tensors. The spiders connect to form a tensor network wihch is akin to the Penrose graphical notations. The ZX-diagrams can be seen as a generalization of the quantum circuit notation. The idea behind the ZX calculus is that only connectivity matters. There's a whole different set of rules that define this concept and can be used to reduce the overhead of this circuit.