Skip to content

✨ Lower nested modifiers in controlled composites #2588

Description

@burgholzer

πŸ€– AI text below πŸ€–

Problem Statement

Target compilation and synthesis still reject controlled composites whose bodies are nested inside inverse or power modifiers. PR #2565 distributes a control over multiple direct body operations, but a sole composite qco.inv or qco.pow remains a large controlled operation. This affects both Qiskit and OpenQASM input.

Reproducer at e3295d31 (Python 3.14, LLVM/MLIR 23.1.0):

from mqt.core.mlir import (
    CompilerTarget, PayloadEncoding, PayloadFormat, PayloadSpecification,
    QCProgram, TargetEnvironment,
)

source = """OPENQASM 3.0;
include "stdgates.inc";
gate composite a, b, c { rx(0.37) a; cx a, c; ry(0.61) b; }
qubit[4] q;
ctrl @ inv @ composite q[0], q[1], q[2], q[3];
"""
cap = CompilerTarget.OperationCapability
target = CompilerTarget(
    4,
    connectivity=CompilerTarget.Connectivity.all_to_all(),
    native_operations=CompilerTarget.NativeOperations([
        cap("u", 1, 3), cap("cx", 2, 0), cap("gphase", 0, 1),
    ]),
)
environment = TargetEnvironment(
    target,
    PayloadSpecification(PayloadFormat("qir", "2.1.0", "base", PayloadEncoding.BINARY)),
)
QCProgram.from_openqasm_str(source).to_qco().synthesize_for_target(environment)

Both synthesize_for_target and compile_for_target fail with target does not support operation 'qco.ctrl' with arity 4 and 0 parameter(s). Removing inv @ succeeds. A Qiskit AnnotatedOperation containing inverse and control modifiers reproduces the same failure; a numeric power of a composite also remains unsupported.

Proposed Solution

Reuse the existing modifier-unrolling machinery where the algebra permits it, starting with inverse bodies. Define the supported subset for composite powers explicitly; powers cannot in general be distributed over noncommuting gates. Keep this normalization independent of the frontend and backend, preserve controlled global phase and wire order, and avoid early symbolic rotation expansion or general arbitrary-unitary synthesis.

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 MLIRenhancementImprovement of existing feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions