🤖 AI text below 🤖
Problem Statement
OpenQASM 3 supports subroutines such as def f(qubit[4] q), but MQT Core currently models only custom gate definitions. Import lowers gate formals to scalar QC qubits, and export accepts only leading f64 parameters followed by scalar-qubit arguments.
Using gate or flattening a register loses the source-level function boundary and cannot represent indexed register logic faithfully.
Proposed Solution
Import and export one coherent, useful subset of OpenQASM 3 subroutines after the shared QC/QCO register-call contract is available.
Supported subset
- Global, defined, non-recursive, void
def subroutines.
- One or more scalar
qubit or fixed positive qubit[N] parameters.
- Existing supported statements in the body, including calls to previously defined supported gates and subroutines.
- No local qubit declarations.
- Register actuals are whole register identifiers. Scalar actuals use existing scalar references.
- All quantum actuals at a call must be provably pairwise disjoint.
Import each supported subroutine as a private QC func.func with borrowed scalar/memref arguments and ordinary func.call. Export reachable ordinary functions with at least one fixed register argument as def. Continue to export scalar mqt.unitary functions as gate.
Keep the parser, semantic model, QC emitter, and exporter in one pull request. A syntax-only intermediate state is not independently useful.
Likely implementation areas:
- OpenQASM lexer tokens and syntax nodes
OpenQASMParser.h and semantic analysis
OpenQASMToQCEmitter.cpp
TranslateQCToOpenQASM3.cpp
- Frontend documentation and focused parser, semantics, emitter, and round-trip tests
Acceptance criteria
- Import and export support a subroutine with mixed scalar-qubit and multiple fixed-register parameters.
- Nested supported subroutine calls work when definitions precede use.
- QC→OpenQASM 3→QC preserves register count, order, and static sizes.
- Duplicate and overlapping quantum actuals are rejected before emission.
- Dynamic registers, slices, concatenations, unresolved calls, recursion, and non-void subroutines receive targeted diagnostics.
- Existing custom-gate import and export behavior remains unchanged.
- Tests include negative parser/semantic cases and an end-to-end round trip.
Dependencies and related work
Non-goals
Classical by-value parameters; classical register parameters; bit[N] references; classical return values; extern; early return; recursion; local qubit declarations; dynamic or sliced quantum arrays; modifiers on subroutine calls.
🤖 AI text below 🤖
Problem Statement
OpenQASM 3 supports subroutines such as
def f(qubit[4] q), but MQT Core currently models only customgatedefinitions. Import lowers gate formals to scalar QC qubits, and export accepts only leadingf64parameters followed by scalar-qubit arguments.Using
gateor flattening a register loses the source-level function boundary and cannot represent indexed register logic faithfully.Proposed Solution
Import and export one coherent, useful subset of OpenQASM 3 subroutines after the shared QC/QCO register-call contract is available.
Supported subset
defsubroutines.qubitor fixed positivequbit[N]parameters.Import each supported subroutine as a private QC
func.funcwith borrowed scalar/memref arguments and ordinaryfunc.call. Export reachable ordinary functions with at least one fixed register argument asdef. Continue to export scalarmqt.unitaryfunctions asgate.Keep the parser, semantic model, QC emitter, and exporter in one pull request. A syntax-only intermediate state is not independently useful.
Likely implementation areas:
OpenQASMParser.hand semantic analysisOpenQASMToQCEmitter.cppTranslateQCToOpenQASM3.cppAcceptance criteria
Dependencies and related work
arrayin the OpenQASM frontend #2109.Non-goals
Classical by-value parameters; classical register parameters;
bit[N]references; classical return values;extern; earlyreturn; recursion; local qubit declarations; dynamic or sliced quantum arrays; modifiers on subroutine calls.