Skip to content

[BUG] Unsupported Controlled QASM operations #252

@MTakahashi-KWH

Description

@MTakahashi-KWH

Environment

  • PyQASM version: 0.3.2
  • Python version: 3.12.8
  • Operating system: Windows

What happened?

This may be a feature request, but it looks like a partially stubbed implementation based on #32, #121, and #125.

When attempting to define and run a custom gate with multiple controls:

gate Z_on_two3 aa, ab, ac {
    x ac;
    ctrl(2) @ z aa, ab, ac;
    x ac;
}
ctrl@ gate Z_on_two3 qb[0], qb[1], qb[2];

I encounter the following error:

ValidationError: Unsupported controlled QASM operation: z with 3 controls

Source

The error originates from map_qasm_ctrl_op_to_callable, which currently contains the following comment:

# TODO: decompose controls if not built in

Expected Behavior(?)

Support for decomposing multi-controlled operations (e.g., z with 3+ controls), or clarification on whether this is intentionally unsupported.

Suggestions (Optional)

IDK if this is a semantic decomposition or needs full function decomposition to base gate ie through Solavay Kiteav or Cartan. Id assume it can be left to a semantic decomp as openqasm parsing itself accepts gate modifiers directly. LMK future development intent in this category

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions