I would like to know if there is a way to:

  1. Implement Quantum 'Functions' e.g the QFT of QFT* containing several single-qubit operations?
  2. Implement such operations on an arbitrary number of qubits and in the same vein implement work-qubits.

Not looking as responsive as pyquil, however, I noticed in the Qiskit documentation that implementing a 'CircuitFactory' with the 'ABC' package seems to be the way to go. I would just appreciate insights from experienced hands. Thank you kindly.

  • $\begingroup$ What I see an inherent problem: ideally, a quantum field is an infinite dimensional quantum system. Thus, we would need $\infty$ qubits to describe it. But there is likely some approximation. $\endgroup$
    – peterh
    Commented Oct 31, 2020 at 18:44
  • $\begingroup$ @peterh-ReinstateMonica My guess is that QFT in this question stands for quantum Fourier transform and not quantum field theory. An unfortunate overlap of acronyms. $\endgroup$
    – Rammus
    Commented Nov 2, 2020 at 20:00
  • $\begingroup$ @Rammus Oops, thanks! :-) $\endgroup$
    – peterh
    Commented Nov 2, 2020 at 21:46

1 Answer 1


If I understand your question correctly, you are looking for a way to create custom gates.

For that, first create a circuit that it will be converted to a gate:

from qiskit import *
my_circuit = QuantumCircuit(3, name='mygate')
my_gate = my_circuit.to_gate()

Then, you can use your gate in a bigger circuit:

circuit = QuantumCircuit(5)
circuit.append(my_gate, [0,2,3])
q_0: ┤0         ├
     │          │
q_1: ┤          ├
     │  my_gate │
q_2: ┤1         ├
     │          │
q_3: ┤2         ├
q_4: ────────────

You can see your custom gate "content" with circuit.decompose().


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.