7
$\begingroup$

The Multiple-Control Toffoli (mct) gate takes as input: 1. a register containing the control qubits, 2. the target qubits and 3. a register containing ancilla qubits.

I don't know how many ancilla qubits I need to pass in for a number of $n$ controll qubits. I've seen examples and used mct gates with 4 control qubits and 2 ancillas so I know the number of ancillas is not $n-1$ like suggested in this answer

Is there a strict dependency meaning for 10 control qubits you need 5 ancillas or does the implementation adapt to the number or ancillas that are passed in?

$\endgroup$

2 Answers 2

4
$\begingroup$

I found out the number of ancillas is minimum $n-2$.

I found this line in the Qiskit source code of mct:

if len(ancillary_qubits) < len(control_qubits) - 2:
    raise AquaError('Insufficient number of ancillary qubits.')
$\endgroup$
2
  • $\begingroup$ Im new to QC so this may be a trivial question; Why use more than one ancilla? Im using the mct gate for my 6 qubit grover's algorithm circuit and the gate works just fine with just 1 ancilla... unless I am doing something wrong. Thanks in advance. $\endgroup$
    – James Bian
    Jun 22, 2021 at 13:40
  • $\begingroup$ In Qiskit, it seems fine even if I don't specify any ancilla qubit. For example, Minh Pham's answer (see below) doesn't cause an error. $\endgroup$
    – LearnerAL
    Jan 4, 2022 at 23:34
1
$\begingroup$

You don't need to use any ancillas at all. Just add in the controls as a list and a target and you should be good.

Take this as an example of 9 control bits

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ It forces you to put in atleast 1 ancilla when the control gate gets bigger than 5. $\endgroup$
    – James Bian
    Jun 22, 2021 at 13:39

Your Answer

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

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