Skip to content

✨ Recognize unitary OpenQASM gates with structured control flow #2413

Description

@burgholzer

πŸ€– AI text below πŸ€–

Problem Statement

OpenQASM import currently marks every custom gate that requires structured control flow as non-unitary. This includes gates with statically bounded for loops whose bodies contain only unitary operations. Callers of such gates also remain non-unitary, which prevents later unitary-only handling even when the source gate is safe.

This follows up on the final review of #2338.

Proposed Solution

Add conservative unitary recognition for structured custom-gate bodies. Support at least statically bounded for loops whose bodies contain only unitary operations or calls to unitary gates. Propagate the result through callers.

Leave functions unmarked when they contain non-unitary operations, recursion, unresolved calls, or unsupported control flow. Add import and round-trip tests for accepted loops and rejected non-unitary bodies.

Activity

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

Metadata

Metadata

Assignees

Labels

MLIRAnything related to MLIROpenQASMAnything related to OpenQASMenhancementImprovement of existing feature

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions