Skip to content

Supports QASM conversion with multiple control gates (controlled_by function) #1753

Description

@JialeZhouxin

Is your feature request related to a problem? Please describe.
Currently, when using circuit.to_qasm() to export a Qibo circuit to QASM format, the conversion fails if the circuit contains multi-controlled gates (e.g., gates generated via the controlled_by method). This prevents correct export and subsequent loading of the circuit in other frameworks such as Qiskit.

Describe the solution you'd like
In Qibo's to_qasm, when a multi-controlled gate is detected, automatically invoke a generic decomposition routine:
Input: a list of control qubits and the target gate type.
Output: a sequence of elementary QASM gates (e.g., CX, single-qubit rotations, and ancilla-assisted operations).

Describe alternatives you've considered
In specific modes, directly map to the target framework's native multi-controlled gate:
Qiskit → MCXGate
tket → MultiControlledUnitary

Advantages: Leverages the framework’s optimized implementation, reducing performance overhead from decomposition.
Disadvantages: Sacrifices cross-framework portability—circuits can only run within the specific target framework.

Additional context
Below is an example of to_qasm() for a circuit containing a multi-controlled gate.
Image

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions