Quantum Computing Asked on March 28, 2021
If one has two qubits in arbitrary stats and wishes to apply a controlled version of some global phase gate $P(varphi) = begin{pmatrix} e^{ivarphi} & 0 0 & e^{ivarphi} end{pmatrix}$ one should obtain:
$$
left| psi_0 rightrangle left| psi_1 rightrangle = left(c_{00} left| 0 rightrangle + c_{01} left| 1 rightrangle right)left(c_{10} left| 0 rightrangle + c_{11} left| 1 rightrangle right) xrightarrow{text{CP}
}$$
$$
xrightarrow{text{CP}}
c_{00} left| 0 rightrangle left(c_{10} left| 0 rightrangle + c_{11} left| 1 rightrangle right) + c_{01} left| 1 rightrangle left(c_{10} e^{ivarphi} left| 0 rightrangle + c_{11} e^{ivarphi} left| 1 rightrangle right),
$$
This example shows that in contrast to global phase gate $P$ which doesn’t produce any measurable changes in a qubit state, the controlled version of it ($CP$) makes measurable changes in the state of a system of qubits. So it is ok if $P$ is ignored, but it is not ok if $CP$ is ignored (what is happening in the presented code).
Here is a code where I use qiskit.aqua.operators.common.evolution_instruction
method, where because of (how I understand) ignoring the global phase gate, the $CP$ gate wasn’t obtained (the print(qc.qasm())
command shows no gate is added to the circuit):
import numpy as np
from qiskit import *
from qiskit.aqua.operators import WeightedPauliOperator
from qiskit.aqua.operators.common import evolution_instruction
phase = np.pi
pauli_dict = {'paulis': [{"coeff": {"imag": 0.0, "real": phase}, "label": "I"}]}
identity = WeightedPauliOperator.from_dict(pauli_dict)
pauli_list = identity.reorder_paulis()
instruction = evolution_instruction(pauli_list, evo_time=1, num_time_slices=1, controlled=True)
q = QuantumRegister(2)
qc_temp = QuantumCircuit(q)
qc_temp.append(instruction, q)
qc = qc_temp.decompose()
print(qc.qasm())
Possible consequences: when I tried to implement IPEA algorithm for $H = begin{pmatrix} E_1 & 0 0 & E_2 end{pmatrix}$ Hamiltonian I was estimating $E_2 – E_1$ instead of estimating $E_2$ eigenvalue. This problem was reported here. Problems may arise also for other quantum algos that use PEA as a subroutine (like HHL algo).
Is this a problem/bug? Are there alternatives to qiskit evolution_instruction method
that don’t ignore phase gates (or Pauli I operator)?
It seems that this is not a problem/bug. In case the global phase gate $P$ is applied in non-controlled form, final matrix for two qubits ($P$ is acting on second qubit) is begin{equation} I otimes P = begin{pmatrix} P & O O & P end{pmatrix} =mathrm{e}^{iphi}I end{equation} So, $P$ acts as global phase gate and the phase $mathrm{e}^{iphi}$ can be ignored.
However, matrix of controlled $P$ is as follows begin{equation} CP = begin{pmatrix} I & O O & P end{pmatrix} end{equation} Hence, $CP$ is no longer global phase gate but it prepares entangled state.
Answered by Martin Vesely on March 28, 2021
What does the print(qc.qasm())
yield for you?
Here is what I get:
OPENQASM 2.0;
include "qelib1.inc";
qreg q2[2];
Controlled-Evolution^1 q2[0],q2[1];
Answered by Jack Woehr on March 28, 2021
I just copied and pasted your code above, and that is the output I get from the print() statement. What version of qiskit do you have?
from qiskit import qiskit_version
print(qiskit_version)
Answered by Jack Woehr on March 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP