0
$\begingroup$

I am trying to solve some QUBO tasks with Grover Adaptive Search ("GAS"). For testing purposes, I use a simple task with quadratic part $$ A = \begin{pmatrix}0 & -0.5 \\ -0.5 & 0\end{pmatrix} $$ and linear part $b = \begin{pmatrix}-1 & -1\end{pmatrix}$. The optimal solution should be $x_0 = x_1 = 1$ and the objective function value $f(x) = -3$.

I use three qubits for representing the objective function values. Since the task has two varibles, we would need six qubits in total (3 for the objective function, 2 for variables and one ancilla). Obviously when I tried to solve the task on QPU with 5 qubits, an error message was returned:

'Number of qubits (6) in Grover circuit is greater than maximum (5) in the coupling_map'

Therefore, I run the GAS on IBM Q processors Nairobi and Oslo with seven qubits.

Interestingly, when I had a look at the job sent to Oslo processor, I realized that only five qubits are used. This means that the task should be solved on a five-qubit processor. However, Qiskit does not allow to do so.

I aslo realized that there is probably no qubit equivalent to ancilla used in original Grover algorithm, as I see no qubit initialized to state $|-\rangle$ with gates $X$ and $H$.

Could anybody shed more light on this issue? Why one qubit (probably ancilla) remains unused? Is this a matter of optimization in transpilation?

Please find my Qiskit code here:

%matplotlib inline
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer, IBMQ
from qiskit_optimization import QuadraticProgram
from qiskit_optimization.algorithms import GroverOptimizer
import numpy as np #

provider = IBMQ.load_account()

#opt: f = -3, x = 11
A = np.array([
    [0, -0.5,],
    [-0.5,  0]
    ])
b = np.array([-1,-1])

#processor = Aer.backends(name = 'qasm_simulator')[0] 
#processor = provider.backends(name='ibmq_manila')[0] #5 qubits
processor = provider.backends(name='ibm_oslo')[0] #7 qubits

obj_func_qubits = 3
iterations = 2

solver = GroverOptimizer(obj_func_qubits, num_iterations = iterations, quantum_instance = processor)

task = QuadraticProgram(name = 'QUBO')
    
for i in range(0,2):
    task.binary_var(name = 'x' + str(i)) #add variables

task.minimize(linear = b, quadratic = A, constant = 0) #set objective function
    
results = solver.solve(task)
print(results.prettyprint())

And here is QASM code for job sent to Oslo processor:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[7];

creg c25[6];


rz(1.5707963267948966) q[1];
sx q[1];
rz(1.5707963267948966) q[1];
rz(1.5707963267948966) q[2];
sx q[2];
rz(1.5707963267948966) q[2];
cx q[1], q[2];
cx q[2], q[1];
cx q[1], q[2];
rz(1.5707963267948966) q[3];
sx q[3];
rz(1.5707963267948966) q[3];
rz(1.5707963267948966) q[5];
sx q[5];
rz(1.5707963267948966) q[5];
rz(1.5707963267948966) q[6];
sx q[6];
rz(1.5707963267948966) q[6];
cx q[6], q[5];
cx q[5], q[6];
cx q[6], q[5];
rz(-0.39269908169872414) q[5];
cx q[5], q[3];
rz(0.39269908169872414) q[3];
cx q[5], q[3];
rz(-0.39269908169872414) q[3];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
rz(-0.7853981633974483) q[3];
cx q[3], q[1];
rz(0.7853981633974483) q[1];
cx q[3], q[1];
rz(-0.7853981633974483) q[1];
cx q[1], q[3];
cx q[3], q[1];
cx q[1], q[3];
rz(-1.5707963267948966) q[1];
cx q[1], q[2];
rz(1.5707963267948966) q[2];
cx q[1], q[2];
rz(-1.5707963267948966) q[2];
cx q[1], q[2];
cx q[2], q[1];
cx q[1], q[2];
rz(-0.39269908169872414) q[6];
cx q[6], q[5];
rz(0.39269908169872414) q[5];
cx q[6], q[5];
rz(-0.39269908169872414) q[5];
cx q[6], q[5];
cx q[5], q[6];
cx q[6], q[5];
rz(-0.7853981633974483) q[5];
cx q[5], q[3];
rz(0.7853981633974483) q[3];
cx q[5], q[3];
rz(-0.7853981633974483) q[3];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
rz(-1.5707963267948966) q[3];
cx q[3], q[1];
rz(1.5707963267948966) q[1];
cx q[3], q[1];
rz(-1.5707963267948966) q[1];
cx q[1], q[2];
cx q[2], q[1];
cx q[1], q[2];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
rz(-0.19634954084936207) q[5];
cx q[5], q[6];
rz(0.19634954084936207) q[6];
cx q[5], q[6];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
cx q[3], q[1];
cx q[1], q[3];
cx q[3], q[1];
cx q[1], q[3];
rz(0.19634954084936207) q[3];
rz(-0.19634954084936207) q[6];
cx q[6], q[5];
cx q[5], q[6];
cx q[6], q[5];
cx q[3], q[5];
rz(-0.19634954084936207) q[5];
cx q[3], q[5];
cx q[3], q[1];
cx q[1], q[3];
rz(-0.19634954084936207) q[1];
rz(0.19634954084936207) q[5];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
cx q[1], q[3];
rz(0.19634954084936207) q[3];
cx q[1], q[3];
rz(-0.19634954084936207) q[3];
cx q[1], q[3];
cx q[3], q[1];
cx q[1], q[3];
cx q[1], q[2];
cx q[2], q[1];
cx q[1], q[2];
rz(-0.39269908169872414) q[2];
rz(-0.39269908169872414) q[5];
cx q[5], q[6];
rz(0.39269908169872414) q[6];
cx q[5], q[6];
cx q[5], q[3];
rz(0.39269908169872414) q[3];
rz(-0.39269908169872414) q[6];
cx q[6], q[5];
cx q[5], q[6];
cx q[6], q[5];
cx q[3], q[5];
rz(-0.39269908169872414) q[5];
cx q[3], q[5];
rz(0.39269908169872414) q[5];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
cx q[5], q[6];
cx q[6], q[5];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
rz(-0.7853981633974483) q[3];
cx q[3], q[1];
rz(0.7853981633974483) q[1];
cx q[3], q[1];
rz(-0.7853981633974483) q[1];
rz(-0.39269908169872414) q[6];
cx q[6], q[5];
rz(0.39269908169872414) q[5];
cx q[6], q[5];
rz(-0.39269908169872414) q[5];
cx q[3], q[5];
cx q[5], q[3];
cx q[3], q[5];
cx q[1], q[3];
cx q[3], q[1];
cx q[1], q[3];
rz(-0.7853981633974483) q[1];
cx q[5], q[6];
cx q[6], q[5];
cx q[5], q[6];
cx q[6], q[5];
rz(0.7853981633974483) q[5];
cx q[5], q[3];
rz(-0.7853981633974483) q[3];
cx q[5], q[3];
rz(0.7853981633974483) q[3];
cx q[6], q[5];
rz(-0.7853981633974483) q[5];
cx q[5], q[3];
rz(0.7853981633974483) q[3];
cx q[5], q[3];
rz(0.7853981633974483) q[3];
sx q[3];
rz(1.5707963267948966) q[3];
cx q[1], q[3];
rz(0.7853981633974483) q[3];
cx q[1], q[3];
rz(-0.7853981633974483) q[3];
cx q[1], q[3];
cx q[3], q[1];
cx q[1], q[3];
cx q[2], q[1];
rz(0.39269908169872414) q[1];
cx q[2], q[1];
rz(-0.39269908169872414) q[1];
cx q[1], q[2];
cx q[2], q[1];
cx q[1], q[2];
rz(-0.7853981633974483) q[1];
rz(1.5707963267948966) q[3];
sx q[3];
rz(1.5707963267948966) q[3];
cx q[1], q[3];
rz(0.7853981633974483) q[3];
cx q[1], q[3];
rz(1.5707963267948966) q[1];
sx q[1];
rz(1.5707963267948966) q[1];
rz(-0.7853981633974483) q[3];
barrier q[0], q[2], q[3], q[1], q[5], q[6], q[4];
measure q[5] -> c25[0];
measure q[6] -> c25[1];
measure q[1] -> c25[2];
measure q[3] -> c25[3];
measure q[2] -> c25[4];
measure q[0] -> c25[5];

As you can see, qubit q[0] is measured but there is no gate applied on it.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.