According to the OPENQASM 2.0 documentation, it's possible to define custom unitary gates using the format:

gate name(params) qargs

where the optional parameter list params is a comma-separated list of variable parameter names, and the argument list qargs is a comma-separated list of qubit arguments.

In my specific case, I'm trying to implement a single-qubit controlled unitary which will act on two qubits. So is there a way to define a custom controlled unitary gate in OPENQASM 2.0? It should work on the new IBM Quantum Experience Beta.

  • $\begingroup$ How if given your unitary? As a matrix? A sequence of quantum gates? A quantum gate previously defined with the syntax you gave above? $\endgroup$ – Adrien Suau Jun 3 '19 at 16:59
  • $\begingroup$ @Nelimee As a sequence of quantum gates acting on two qubits. I can write the two-qubit unitary in the syntax above I suppose, but I'm not sure how to implement the control by a third qubit. $\endgroup$ – Sanchayan Dutta Jun 3 '19 at 17:02

Unfortunately, I'm pretty sure that the functionality you desire does not exist. You'll need to do it by constructing the unitary yourself, for example via this method provided in the answer to another question.

For reference, the full specification for OpenQASM 2.0 can be found here.


Your Answer

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

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