0
$\begingroup$

I implemented the general diffuser (for arbitrary qubits) in Grover's algorithm in terms of an Multi-controlled Toffoli (MCT) gate (it flips target when all controlled gates are 1). However, this gate is not accepted by the IBM quantum computers (not among the basis gates).

Sorry for my naïve question, but how can I replace a mct gate with something that works on IBM quantum computers?

Edit 1: Thank you for the answer. I added

backend = provider.get_backend('ibmq_lima')
custom_basis = backend.configuration().basis_gates
grover = transpile(grover,basis_gates=custom_basis)

Now, I can send it to the simulators. But not an actual quantum computer such as ibmq_lima. In https://arxiv.org/pdf/2106.09976.pdf section IV, they talk about approximating mct gates (still reading and learning). I'm just a hobbyist.

Edit 2: The solution given by Ohad works, i.e. using transpile(grover, backend = backend) in the code. Many thanks. And indeed, I sent the job (Grover's algorithm to find the solution $|00000\rangle$) to ibmq_lima (5 qubits) and it gave me: enter image description here

While a simulator gives the expected results: enter image description here

$\endgroup$
3
  • $\begingroup$ Hi and welcome to Quantum Computing SE. Could you please add more details, e.g. definition of MCT gate? $\endgroup$ Commented Sep 27, 2022 at 6:07
  • $\begingroup$ Use transpile(grover, backend = backend) and you will be able to run it on a specific backend. BTW, If you run Grover's algorithm on ibmq_lima you'll probably get mostly noise and not valuable results.. $\endgroup$
    – Ohad
    Commented Sep 29, 2022 at 15:20
  • $\begingroup$ consider writing a follow up question instead of extending this question. $\endgroup$
    – luciano
    Commented Sep 30, 2022 at 16:57

2 Answers 2

0
$\begingroup$

Use qiskit's transpiler. It transpiles a given circuit to an equivalent (in functionality) circuit a given backend can run. I don't know any quantum computer that natively can run multi-qubit gates - Only single qubit and 2-qubit gates.

$\endgroup$
0
$\begingroup$

The transpilation process takes the backend to adapt the circuit to that target. The following code will work even if backend is a simulator:

grover = transpile(grover, backend)
job = backend.run(grover)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.