diff --git a/CHANGELOG.md b/CHANGELOG.md index 941d811227..4565e501f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel - ✨ Add conversions between `jeff` and QCO ([#1479], [#1548], [#1565], [#1637], [#1676], [#1706], [#1776]) ([**@denialhaag**], [**@burgholzer**]) - ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547], [#1568], [#1581], [#1583], [#1588], [#1600], [#1664], [#1709], [#1716], [#1748]) ([**@MatthiasReumann**], [**@burgholzer**]) - ✨ Add initial infrastructure for new QC and QCO MLIR dialects - ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1542], [#1548], [#1550], [#1554], [#1567], [#1569], [#1570], [#1572], [#1573], [#1580], [#1602], [#1620], [#1623], [#1624], [#1626], [#1627], [#1635], [#1638], [#1673], [#1675], [#1700], [#1710], [#1717], [#1728], [#1730], [#1749], [#1751], [#1762], [#1765], [#1774], [#1781]) + ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1542], [#1548], [#1550], [#1554], [#1567], [#1569], [#1570], [#1572], [#1573], [#1580], [#1602], [#1620], [#1623], [#1624], [#1626], [#1627], [#1635], [#1638], [#1673], [#1675], [#1700], [#1710], [#1717], [#1728], [#1730], [#1749], [#1751], [#1755], [#1762], [#1765], [#1774], [#1781]) ([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**], [**@simon1hofmann**]) ### Changed @@ -407,6 +407,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool [#1774]: https://github.com/munich-quantum-toolkit/core/pull/1774 [#1765]: https://github.com/munich-quantum-toolkit/core/pull/1765 [#1762]: https://github.com/munich-quantum-toolkit/core/pull/1762 +[#1755]: https://github.com/munich-quantum-toolkit/core/pull/1755 [#1751]: https://github.com/munich-quantum-toolkit/core/pull/1751 [#1749]: https://github.com/munich-quantum-toolkit/core/pull/1749 [#1748]: https://github.com/munich-quantum-toolkit/core/pull/1748 diff --git a/include/mqt-core/ir/QuantumComputation.hpp b/include/mqt-core/ir/QuantumComputation.hpp index 68f2e295b1..92e426f982 100644 --- a/include/mqt-core/ir/QuantumComputation.hpp +++ b/include/mqt-core/ir/QuantumComputation.hpp @@ -322,11 +322,12 @@ class QuantumComputation { /** * @brief Add measurements to all qubits * @param addBits Whether to add new classical bits to the circuit + * @param addBarrier Whether to add a barrier before the measurements * @details This function adds measurements to all qubits in the circuit and * appends a new classical register (named "meas") to the circuit if addBits * is true. Otherwise, qubit q is measured into classical bit q. */ - void measureAll(bool addBits = true); + void measureAll(bool addBits = true, bool addBarrier = true); void bridge(const Targets& targets); diff --git a/mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h b/mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h index ed94af35bc..e5bf471821 100644 --- a/mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h +++ b/mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h @@ -70,7 +70,8 @@ class QCProgramBuilder final : public ImplicitLocOpBuilder { //===--------------------------------------------------------------------===// /** - * @brief Initialize the builder and prepare for program construction + * @brief Initialize the builder and prepare for program construction, with + * a default return type of i64. * * @details * Creates a main function with an entry_point attribute. Must be called @@ -78,6 +79,23 @@ class QCProgramBuilder final : public ImplicitLocOpBuilder { */ void initialize(); + /** + * @brief Initialize the builder and prepare for program construction + * with specified return types. + * @param returnTypes The return types for the main function + * + * @details + * Creates a main function with an entry_point attribute. Must be called + * before adding operations. + */ + void initialize(TypeRange returnTypes); + + /** + * @brief Modify the return types of the main function after initialization. + * @param returnTypes The new return types for the main function + */ + void retype(TypeRange returnTypes); + //===--------------------------------------------------------------------===// // Constants //===--------------------------------------------------------------------===// @@ -1092,17 +1110,38 @@ class QCProgramBuilder final : public ImplicitLocOpBuilder { OwningOpRef finalize(); /** - * @brief Convenience method for building quantum programs + * @brief Finalize the program with a given exit code and return the + * constructed module + * @param returnValues Values representing the exit code to return + * + * @details + * Automatically deallocates all remaining valid qubits and tensors of qubits, + * adds a return statement with a given exit code, + * and transfers ownership of the module to the caller. The builder should not + * be used after calling this method. + * + * The return values must have the types indicated by the function signature + * of the main function, which returns an `i64` by default and can be + * modified by passing different arguments to the `initialize()` method. + * + * @return OwningOpRef containing the constructed quantum program module + */ + OwningOpRef finalize(ValueRange returnValues); + + /** + * @brief Convenience method for building quantum programs. * @param context The MLIR context to use for building the program * @param buildFunc A function that takes a reference to a QCProgramBuilder * and uses it to build the desired quantum program. The builder will be * properly initialized before calling this function, and the resulting module - * will be finalized and returned after this function completes. + * will be finalized using the returned ValueRange after this function + * completes. * @return The module containing the quantum program built by buildFunc. */ static OwningOpRef build(MLIRContext* context, - const function_ref& buildFunc); + const function_ref, SmallVector>( + QCProgramBuilder&)>& buildFunc); private: enum class AllocationMode : uint8_t { Unset, Static, Dynamic }; diff --git a/mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h b/mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h index 12d7ef73d1..99b28b3077 100644 --- a/mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h +++ b/mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h @@ -78,7 +78,8 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder { //===--------------------------------------------------------------------===// /** - * @brief Initialize the builder and prepare for program construction + * @brief Initialize the builder and prepare for program construction, with + * a default return type of i64. * * @details * Creates a main function with an entry_point attribute. Must be called @@ -86,6 +87,23 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder { */ void initialize(); + /** + * @brief Initialize the builder and prepare for program construction + * with specified return types. + * @param returnTypes The return types for the main function + * + * @details + * Creates a main function with an entry_point attribute. Must be called + * before adding operations. + */ + void initialize(TypeRange returnTypes); + + /** + * @brief Modify the return types of the main function after initialization. + * @param returnTypes The new return types for the main function + */ + void retype(TypeRange returnTypes); + //===--------------------------------------------------------------------===// // Constants //===--------------------------------------------------------------------===// @@ -387,7 +405,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder { * * @param qubit Input qubit (must be valid/unconsumed) * @param bit The classical bit to record the result - * @return Output qubit value + * @return Pair of (output_qubit, measurement_result) * * @par Example: * ```c++ @@ -397,7 +415,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder { * %q0_out, %r0 = qco.measure("c", 3, 0) %q0 : !qco.qubit * ``` */ - Value measure(Value qubit, const Bit& bit); + std::pair measure(Value qubit, const Bit& bit); /** * @brief Reset a qubit to |0⟩ state @@ -1391,17 +1409,39 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder { OwningOpRef finalize(); /** - * @brief Convenience method for building quantum programs + * @brief Finalize the program with a given exit code and return the + * constructed module + * @param returnValues Values representing the exit code to return + * + * @details + * Automatically deallocates all remaining valid qubits and tensors of qubits, + * adds a return statement with a given exit code, + * and transfers ownership of the module to the caller. The builder should not + * be used after calling this method. + * + * The return values must have the types indicated by the function signature + * of the main function, which returns an `i64` by default and can be + * modified by passing different arguments to the `initialize()` method. + * + * @return OwningOpRef containing the constructed quantum program module + */ + OwningOpRef finalize(ValueRange returnValues); + + /** + * @brief Convenience method for building quantum programs. * @param context The MLIR context to use for building the program + * @param returnTypes The types of the values to be returned by the program. * @param buildFunc A function that takes a reference to a QCOProgramBuilder * and uses it to build the desired quantum program. The builder will be * properly initialized before calling this function, and the resulting module - * will be finalized and returned after this function completes. + * will be finalized using the returned ValueRange after this function + * completes. * @return The module containing the quantum program built by buildFunc. */ static OwningOpRef build(MLIRContext* context, - const function_ref& buildFunc); + const function_ref, SmallVector>( + QCOProgramBuilder&)>& buildFunc); private: enum class AllocationMode : uint8_t { Unset, Static, Dynamic }; diff --git a/mlir/include/mlir/Dialect/QCO/IR/QCODialect.td b/mlir/include/mlir/Dialect/QCO/IR/QCODialect.td index 62d1f5bba4..e7d98a0367 100644 --- a/mlir/include/mlir/Dialect/QCO/IR/QCODialect.td +++ b/mlir/include/mlir/Dialect/QCO/IR/QCODialect.td @@ -38,6 +38,8 @@ def QCODialect : Dialect { let cppNamespace = "::mlir::qco"; let useDefaultTypePrinterParser = 1; + + let hasCanonicalizer = 1; } #endif // MLIR_DIALECT_QCO_IR_QCODIALECT_TD diff --git a/mlir/include/mlir/Dialect/QCO/IR/QCOOps.td b/mlir/include/mlir/Dialect/QCO/IR/QCOOps.td index 17bab8174b..edbf5c8f67 100644 --- a/mlir/include/mlir/Dialect/QCO/IR/QCOOps.td +++ b/mlir/include/mlir/Dialect/QCO/IR/QCOOps.td @@ -96,7 +96,7 @@ def StaticOp : QCOOp<"static", [Pure]> { // Measurement and Reset Operations //===----------------------------------------------------------------------===// -def MeasureOp : QCOOp<"measure"> { +def MeasureOp : QCOOp<"measure", [Pure]> { let summary = "Measure a qubit in the computational basis"; let description = [{ Measures a qubit in the computational (Z) basis, collapsing the state @@ -119,8 +119,7 @@ def MeasureOp : QCOOp<"measure"> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, OptionalAttr:$register_name, OptionalAttr>:$register_size, OptionalAttr>:$register_index); @@ -136,9 +135,10 @@ def MeasureOp : QCOOp<"measure"> { }]>]; let hasVerifier = 1; + let hasCanonicalizer = 1; } -def ResetOp : QCOOp<"reset", [Idempotent, SameOperandsAndResultType]> { +def ResetOp : QCOOp<"reset", [Idempotent, SameOperandsAndResultType, Pure]> { let summary = "Reset a qubit to |0⟩ state"; let description = [{ Resets a qubit to the |0⟩ state, regardless of its current state, @@ -150,8 +150,7 @@ def ResetOp : QCOOp<"reset", [Idempotent, SameOperandsAndResultType]> { ``` }]; - let arguments = - (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -208,7 +207,8 @@ def GPhaseOp let hasCanonicalizer = 1; } -def IdOp : QCOOp<"id", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def IdOp + : QCOOp<"id", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply an Id gate to a qubit"; let description = [{ Applies an Id gate to a qubit and returns the transformed qubit. @@ -219,7 +219,7 @@ def IdOp : QCOOp<"id", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -232,7 +232,8 @@ def IdOp : QCOOp<"id", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def XOp : QCOOp<"x", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def XOp + : QCOOp<"x", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply an X gate to a qubit"; let description = [{ Applies an X gate to a qubit and returns the transformed qubit. @@ -243,7 +244,7 @@ def XOp : QCOOp<"x", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -256,7 +257,8 @@ def XOp : QCOOp<"x", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def YOp : QCOOp<"y", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def YOp + : QCOOp<"y", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply a Y gate to a qubit"; let description = [{ Applies a Y gate to a qubit and returns the transformed qubit. @@ -267,7 +269,7 @@ def YOp : QCOOp<"y", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -280,7 +282,8 @@ def YOp : QCOOp<"y", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def ZOp : QCOOp<"z", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def ZOp + : QCOOp<"z", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply a Z gate to a qubit"; let description = [{ Applies a Z gate to a qubit and returns the transformed qubit. @@ -291,7 +294,7 @@ def ZOp : QCOOp<"z", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -304,7 +307,8 @@ def ZOp : QCOOp<"z", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def HOp : QCOOp<"h", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def HOp + : QCOOp<"h", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply a H gate to a qubit"; let description = [{ Applies a H gate to a qubit and returns the transformed qubit. @@ -315,7 +319,7 @@ def HOp : QCOOp<"h", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -328,7 +332,8 @@ def HOp : QCOOp<"h", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def SOp : QCOOp<"s", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def SOp + : QCOOp<"s", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply an S gate to a qubit"; let description = [{ Applies an S gate to a qubit and returns the transformed qubit. @@ -339,7 +344,7 @@ def SOp : QCOOp<"s", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -352,8 +357,8 @@ def SOp : QCOOp<"s", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def SdgOp - : QCOOp<"sdg", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def SdgOp : QCOOp<"sdg", + traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply an Sdg gate to a qubit"; let description = [{ Applies an Sdg gate to a qubit and returns the transformed qubit. @@ -364,7 +369,7 @@ def SdgOp ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -377,7 +382,8 @@ def SdgOp let hasCanonicalizer = 1; } -def TOp : QCOOp<"t", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def TOp + : QCOOp<"t", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply a T gate to a qubit"; let description = [{ Applies a T gate to a qubit and returns the transformed qubit. @@ -388,7 +394,7 @@ def TOp : QCOOp<"t", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -401,8 +407,8 @@ def TOp : QCOOp<"t", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def TdgOp - : QCOOp<"tdg", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def TdgOp : QCOOp<"tdg", + traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply a Tdg gate to a qubit"; let description = [{ Applies a Tdg gate to a qubit and returns the transformed qubit. @@ -413,7 +419,7 @@ def TdgOp ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -426,7 +432,8 @@ def TdgOp let hasCanonicalizer = 1; } -def SXOp : QCOOp<"sx", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def SXOp + : QCOOp<"sx", traits = [UnitaryOpInterface, OneTargetZeroParameter, Pure]> { let summary = "Apply an SX gate to a qubit"; let description = [{ Applies an SX gate to a qubit and returns the transformed qubit. @@ -437,7 +444,7 @@ def SXOp : QCOOp<"sx", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -450,8 +457,8 @@ def SXOp : QCOOp<"sx", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { let hasCanonicalizer = 1; } -def SXdgOp - : QCOOp<"sxdg", traits = [UnitaryOpInterface, OneTargetZeroParameter]> { +def SXdgOp : QCOOp<"sxdg", traits = [UnitaryOpInterface, OneTargetZeroParameter, + Pure]> { let summary = "Apply an SXdg gate to a qubit"; let description = [{ Applies an SXdg gate to a qubit and returns the transformed qubit. @@ -462,7 +469,7 @@ def SXdgOp ``` }]; - let arguments = (ins Arg:$qubit_in); + let arguments = (ins Arg:$qubit_in); let results = (outs QubitType:$qubit_out); let assemblyFormat = "$qubit_in attr-dict `:` type($qubit_in) `->` type($qubit_out)"; @@ -475,7 +482,8 @@ def SXdgOp let hasCanonicalizer = 1; } -def RXOp : QCOOp<"rx", traits = [UnitaryOpInterface, OneTargetOneParameter]> { +def RXOp + : QCOOp<"rx", traits = [UnitaryOpInterface, OneTargetOneParameter, Pure]> { let summary = "Apply an RX gate to a qubit"; let description = [{ Applies an RX gate to a qubit and returns the transformed qubit. @@ -486,7 +494,7 @@ def RXOp : QCOOp<"rx", traits = [UnitaryOpInterface, OneTargetOneParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta); let results = (outs QubitType:$qubit_out); let assemblyFormat = "`(` $theta `)` $qubit_in attr-dict `:` type($qubit_in) " @@ -504,7 +512,8 @@ def RXOp : QCOOp<"rx", traits = [UnitaryOpInterface, OneTargetOneParameter]> { let hasCanonicalizer = 1; } -def RYOp : QCOOp<"ry", traits = [UnitaryOpInterface, OneTargetOneParameter]> { +def RYOp + : QCOOp<"ry", traits = [UnitaryOpInterface, OneTargetOneParameter, Pure]> { let summary = "Apply an RY gate to a qubit"; let description = [{ Applies an RY gate to a qubit and returns the transformed qubit. @@ -515,7 +524,7 @@ def RYOp : QCOOp<"ry", traits = [UnitaryOpInterface, OneTargetOneParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta); let results = (outs QubitType:$qubit_out); let assemblyFormat = "`(` $theta `)` $qubit_in attr-dict `:` type($qubit_in) " @@ -533,7 +542,8 @@ def RYOp : QCOOp<"ry", traits = [UnitaryOpInterface, OneTargetOneParameter]> { let hasCanonicalizer = 1; } -def RZOp : QCOOp<"rz", traits = [UnitaryOpInterface, OneTargetOneParameter]> { +def RZOp + : QCOOp<"rz", traits = [UnitaryOpInterface, OneTargetOneParameter, Pure]> { let summary = "Apply an RZ gate to a qubit"; let description = [{ Applies an RZ gate to a qubit and returns the transformed qubit. @@ -544,7 +554,7 @@ def RZOp : QCOOp<"rz", traits = [UnitaryOpInterface, OneTargetOneParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta); let results = (outs QubitType:$qubit_out); let assemblyFormat = "`(` $theta `)` $qubit_in attr-dict `:` type($qubit_in) " @@ -562,7 +572,8 @@ def RZOp : QCOOp<"rz", traits = [UnitaryOpInterface, OneTargetOneParameter]> { let hasCanonicalizer = 1; } -def POp : QCOOp<"p", traits = [UnitaryOpInterface, OneTargetOneParameter]> { +def POp + : QCOOp<"p", traits = [UnitaryOpInterface, OneTargetOneParameter, Pure]> { let summary = "Apply a P gate to a qubit"; let description = [{ Applies a P gate to a qubit and returns the transformed qubit. @@ -573,7 +584,7 @@ def POp : QCOOp<"p", traits = [UnitaryOpInterface, OneTargetOneParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta); let results = (outs QubitType:$qubit_out); let assemblyFormat = "`(` $theta `)` $qubit_in attr-dict `:` type($qubit_in) " @@ -591,7 +602,8 @@ def POp : QCOOp<"p", traits = [UnitaryOpInterface, OneTargetOneParameter]> { let hasCanonicalizer = 1; } -def ROp : QCOOp<"r", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { +def ROp + : QCOOp<"r", traits = [UnitaryOpInterface, OneTargetTwoParameter, Pure]> { let summary = "Apply an R gate to a qubit"; let description = [{ Applies an R gate to a qubit and returns the transformed qubit. @@ -602,7 +614,7 @@ def ROp : QCOOp<"r", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta, Arg:$phi); let results = (outs QubitType:$qubit_out); @@ -621,7 +633,8 @@ def ROp : QCOOp<"r", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { let hasCanonicalizer = 1; } -def U2Op : QCOOp<"u2", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { +def U2Op + : QCOOp<"u2", traits = [UnitaryOpInterface, OneTargetTwoParameter, Pure]> { let summary = "Apply a U2 gate to a qubit"; let description = [{ Applies a U2 gate to a qubit and returns the transformed qubit. @@ -632,7 +645,7 @@ def U2Op : QCOOp<"u2", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$phi, Arg:$lambda); let results = (outs QubitType:$qubit_out); @@ -651,7 +664,8 @@ def U2Op : QCOOp<"u2", traits = [UnitaryOpInterface, OneTargetTwoParameter]> { let hasCanonicalizer = 1; } -def UOp : QCOOp<"u", traits = [UnitaryOpInterface, OneTargetThreeParameter]> { +def UOp + : QCOOp<"u", traits = [UnitaryOpInterface, OneTargetThreeParameter, Pure]> { let summary = "Apply a U gate to a qubit"; let description = [{ Applies a U gate to a qubit and returns the transformed qubit. @@ -662,7 +676,7 @@ def UOp : QCOOp<"u", traits = [UnitaryOpInterface, OneTargetThreeParameter]> { ``` }]; - let arguments = (ins Arg:$qubit_in, + let arguments = (ins Arg:$qubit_in, Arg:$theta, Arg:$phi, Arg:$lambda); @@ -683,8 +697,8 @@ def UOp : QCOOp<"u", traits = [UnitaryOpInterface, OneTargetThreeParameter]> { let hasCanonicalizer = 1; } -def SWAPOp - : QCOOp<"swap", traits = [UnitaryOpInterface, TwoTargetZeroParameter]> { +def SWAPOp : QCOOp<"swap", traits = [UnitaryOpInterface, TwoTargetZeroParameter, + Pure]> { let summary = "Apply a SWAP gate to two qubits"; let description = [{ Applies a SWAP gate to two qubits and returns the transformed qubits. @@ -695,9 +709,8 @@ def SWAPOp ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "$qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) `,` " @@ -711,8 +724,8 @@ def SWAPOp let hasCanonicalizer = 1; } -def iSWAPOp - : QCOOp<"iswap", traits = [UnitaryOpInterface, TwoTargetZeroParameter]> { +def iSWAPOp : QCOOp<"iswap", traits = [UnitaryOpInterface, + TwoTargetZeroParameter, Pure]> { let summary = "Apply a iSWAP gate to two qubits"; let description = [{ Applies a iSWAP gate to two qubits and returns the transformed qubits. @@ -723,9 +736,8 @@ def iSWAPOp ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "$qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) `,` " @@ -737,8 +749,8 @@ def iSWAPOp }]; } -def DCXOp - : QCOOp<"dcx", traits = [UnitaryOpInterface, TwoTargetZeroParameter]> { +def DCXOp : QCOOp<"dcx", + traits = [UnitaryOpInterface, TwoTargetZeroParameter, Pure]> { let summary = "Apply a DCX gate to two qubits"; let description = [{ Applies a DCX gate to two qubits and returns the transformed qubits. @@ -749,9 +761,8 @@ def DCXOp ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "$qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) `,` " @@ -765,8 +776,8 @@ def DCXOp let hasCanonicalizer = 1; } -def ECROp - : QCOOp<"ecr", traits = [UnitaryOpInterface, TwoTargetZeroParameter]> { +def ECROp : QCOOp<"ecr", + traits = [UnitaryOpInterface, TwoTargetZeroParameter, Pure]> { let summary = "Apply an ECR gate to two qubits"; let description = [{ Applies an ECR gate to two qubits and returns the transformed qubits. @@ -777,9 +788,8 @@ def ECROp ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "$qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) `,` " @@ -793,7 +803,8 @@ def ECROp let hasCanonicalizer = 1; } -def RXXOp : QCOOp<"rxx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { +def RXXOp + : QCOOp<"rxx", traits = [UnitaryOpInterface, TwoTargetOneParameter, Pure]> { let summary = "Apply an RXX gate to two qubits"; let description = [{ Applies an RXX gate to two qubits and returns the transformed qubits. @@ -804,10 +815,9 @@ def RXXOp : QCOOp<"rxx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `)` $qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) " @@ -825,7 +835,8 @@ def RXXOp : QCOOp<"rxx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { let hasCanonicalizer = 1; } -def RYYOp : QCOOp<"ryy", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { +def RYYOp + : QCOOp<"ryy", traits = [UnitaryOpInterface, TwoTargetOneParameter, Pure]> { let summary = "Apply an RYY gate to two qubits"; let description = [{ Applies an RYY gate to two qubits and returns the transformed qubits. @@ -836,10 +847,9 @@ def RYYOp : QCOOp<"ryy", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `)` $qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) " @@ -857,7 +867,8 @@ def RYYOp : QCOOp<"ryy", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { let hasCanonicalizer = 1; } -def RZXOp : QCOOp<"rzx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { +def RZXOp + : QCOOp<"rzx", traits = [UnitaryOpInterface, TwoTargetOneParameter, Pure]> { let summary = "Apply an RZX gate to two qubits"; let description = [{ Applies an RZX gate to two qubits and returns the transformed qubits. @@ -868,10 +879,9 @@ def RZXOp : QCOOp<"rzx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `)` $qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) " @@ -889,7 +899,8 @@ def RZXOp : QCOOp<"rzx", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { let hasCanonicalizer = 1; } -def RZZOp : QCOOp<"rzz", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { +def RZZOp + : QCOOp<"rzz", traits = [UnitaryOpInterface, TwoTargetOneParameter, Pure]> { let summary = "Apply an RZZ gate to two qubits"; let description = [{ Applies an RZZ gate to two qubits and returns the transformed qubits. @@ -900,10 +911,9 @@ def RZZOp : QCOOp<"rzz", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `)` $qubit0_in `,` $qubit1_in attr-dict `:` type($qubit0_in) " @@ -921,8 +931,8 @@ def RZZOp : QCOOp<"rzz", traits = [UnitaryOpInterface, TwoTargetOneParameter]> { let hasCanonicalizer = 1; } -def XXPlusYYOp : QCOOp<"xx_plus_yy", - traits = [UnitaryOpInterface, TwoTargetTwoParameter]> { +def XXPlusYYOp : QCOOp<"xx_plus_yy", traits = [UnitaryOpInterface, + TwoTargetTwoParameter, Pure]> { let summary = "Apply an XX+YY gate to two qubits"; let description = [{ Applies an XX+YY gate to two qubits and returns the transformed qubits. @@ -933,11 +943,10 @@ def XXPlusYYOp : QCOOp<"xx_plus_yy", ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta, - Arg:$beta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta, + Arg:$beta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `,` $beta `)` $qubit0_in `,` $qubit1_in " "attr-dict `:` type($qubit0_in) `,` type($qubit1_in) " @@ -956,8 +965,8 @@ def XXPlusYYOp : QCOOp<"xx_plus_yy", let hasCanonicalizer = 1; } -def XXMinusYYOp : QCOOp<"xx_minus_yy", - traits = [UnitaryOpInterface, TwoTargetTwoParameter]> { +def XXMinusYYOp : QCOOp<"xx_minus_yy", traits = [UnitaryOpInterface, + TwoTargetTwoParameter, Pure]> { let summary = "Apply an XX-YY gate to two qubits"; let description = [{ Applies an XX-YY gate to two qubits and returns the transformed qubits. @@ -968,11 +977,10 @@ def XXMinusYYOp : QCOOp<"xx_minus_yy", ``` }]; - let arguments = - (ins Arg:$qubit0_in, - Arg:$qubit1_in, - Arg:$theta, - Arg:$beta); + let arguments = (ins Arg:$qubit0_in, + Arg:$qubit1_in, + Arg:$theta, + Arg:$beta); let results = (outs QubitType:$qubit0_out, QubitType:$qubit1_out); let assemblyFormat = "`(` $theta `,` $beta `)` $qubit0_in `,` $qubit1_in " "attr-dict `:` type($qubit0_in) `,` type($qubit1_in) " @@ -991,7 +999,7 @@ def XXMinusYYOp : QCOOp<"xx_minus_yy", let hasCanonicalizer = 1; } -def BarrierOp : QCOOp<"barrier", traits = [UnitaryOpInterface]> { +def BarrierOp : QCOOp<"barrier", traits = [UnitaryOpInterface, Pure]> { let summary = "Apply a barrier gate to a set of qubits"; let description = [{ Applies a barrier gate to a set of qubits and returns the transformed qubits. @@ -1003,7 +1011,7 @@ def BarrierOp : QCOOp<"barrier", traits = [UnitaryOpInterface]> { }]; let arguments = - (ins Arg, "the target qubits", [MemRead]>:$qubits_in); + (ins Arg, "the target qubits">:$qubits_in); let results = (outs Variadic:$qubits_out); let assemblyFormat = "$qubits_in attr-dict `:` type($qubits_in) `->` type($qubits_out)"; @@ -1041,7 +1049,7 @@ def BarrierOp : QCOOp<"barrier", traits = [UnitaryOpInterface]> { // Modifiers //===----------------------------------------------------------------------===// -def YieldOp : QCOOp<"yield", traits = [Terminator, ReturnLike]> { +def YieldOp : QCOOp<"yield", traits = [Terminator, ReturnLike, Pure]> { let summary = "Yield from a modifier region"; let description = [{ Terminates a modifier region, yielding the transformed target qubit and qtensor values back to the enclosing modifier operation. @@ -1064,7 +1072,7 @@ def CtrlOp : QCOOp<"ctrl", traits = [UnitaryOpInterface, AttrSizedOperandSegments, AttrSizedResultSegments, SameOperandsAndResultType, SameOperandsAndResultShape, - SingleBlockImplicitTerminator<"YieldOp">, + SingleBlockImplicitTerminator<"YieldOp">, Pure, RecursiveMemoryEffects]> { let summary = "Add control qubits to a unitary operation"; let description = [{ @@ -1086,9 +1094,9 @@ def CtrlOp : QCOOp<"ctrl", ``` }]; - let arguments = (ins Arg, - "the control qubits", [MemRead]>:$controls_in, - Arg, "the target qubits", [MemRead]>:$targets_in); + let arguments = + (ins Arg, "the control qubits">:$controls_in, + Arg, "the target qubits">:$targets_in); let results = (outs Variadic:$controls_out, Variadic:$targets_out); let regions = (region SizedRegion<1>:$region); @@ -1143,7 +1151,7 @@ def CtrlOp : QCOOp<"ctrl", def InvOp : QCOOp<"inv", traits = [UnitaryOpInterface, SingleBlockImplicitTerminator<"YieldOp">, - RecursiveMemoryEffects]> { + Pure, RecursiveMemoryEffects]> { let summary = "Invert a unitary operation"; let description = [{ A modifier operation that inverts the unitary operation defined in its body region. @@ -1162,9 +1170,8 @@ def InvOp : QCOOp<"inv", traits = [UnitaryOpInterface, ``` }]; - let arguments = - (ins Arg, - "the qubits involved in the operation", [MemRead]>:$qubits_in); + let arguments = (ins Arg, + "the qubits involved in the operation">:$qubits_in); let results = (outs Variadic:$qubits_out); let regions = (region SizedRegion<1>:$region); let assemblyFormat = [{ @@ -1224,7 +1231,7 @@ def IfOp RegionBranchOpInterface, ["getNumRegionInvocations", "getRegionInvocationBounds", "getEntrySuccessorRegions"]>, - SingleBlock, SingleBlockImplicitTerminator<"YieldOp">, + SingleBlock, SingleBlockImplicitTerminator<"YieldOp">, Pure, RecursiveMemoryEffects]> { let summary = "If-then-else operation for linear (qubit) types"; diff --git a/mlir/include/mlir/Dialect/QCO/QCOUtils.h b/mlir/include/mlir/Dialect/QCO/QCOUtils.h index e2ec9740ba..27035ed7ce 100644 --- a/mlir/include/mlir/Dialect/QCO/QCOUtils.h +++ b/mlir/include/mlir/Dialect/QCO/QCOUtils.h @@ -12,6 +12,7 @@ #include #include +#include #include namespace mlir::qco { @@ -246,4 +247,21 @@ mergeTwoTargetOneParameterWithSwappedTargets(OpType op, return success(); } +/** + * @brief Check if given quantum operation is unused (i.e., only used by + * sinks and no memory effects). + * + * @param op The operation to check. + * @return bool True if the operation is unused, false otherwise. + */ +inline bool checkDeadGate(Operation* op) { + if (!isMemoryEffectFree(op)) { + // This ignores operations and regions that have children with memory + // effects, which should never be considered dead. + return false; + } + return llvm::all_of(op->getUsers(), + [](Operation* user) { return isa(user); }); +} + } // namespace mlir::qco diff --git a/mlir/include/mlir/Dialect/QIR/Builder/QIRProgramBuilder.h b/mlir/include/mlir/Dialect/QIR/Builder/QIRProgramBuilder.h index 30802171eb..d8f5bd3173 100644 --- a/mlir/include/mlir/Dialect/QIR/Builder/QIRProgramBuilder.h +++ b/mlir/include/mlir/Dialect/QIR/Builder/QIRProgramBuilder.h @@ -102,6 +102,23 @@ class QIRProgramBuilder final : public ImplicitLocOpBuilder { */ void initialize(); + /** + * @brief Initialize the builder and prepare for program construction + * with specified return types. + * @param returnType The return type for the main function + * + * @details + * Creates a main function with an entry_point attribute. Must be called + * before adding operations. + */ + void initialize(Type returnType); + + /** + * @brief Modify the return type of the main function after initialization. + * @param returnType The new return type for the main function + */ + void retype(Type returnType); + //===--------------------------------------------------------------------===// // Constants //===--------------------------------------------------------------------===// @@ -383,6 +400,24 @@ class QIRProgramBuilder final : public ImplicitLocOpBuilder { */ QIRProgramBuilder& reset(Value qubit); + /** + * @brief Read the value of the given measurement result. + * + * @details + * The value is read via `__quantum__rt__read_result`. + * + * @param result The value representing the measurement result + * @return An LLVM pointer to the measurement result + * + * @par Example: + * ```c++ + * auto result = builder.measure(q0, 0); + * auto value = builder.readResult(result); + * + * ``` + */ + Value readResult(Value result); + //===--------------------------------------------------------------------===// // Unitary Operations //===--------------------------------------------------------------------===// @@ -1026,6 +1061,25 @@ class QIRProgramBuilder final : public ImplicitLocOpBuilder { */ OwningOpRef finalize(); + /** + * @brief Finalize the program with a given exit code and return the + * constructed module + * @param returnValue The value representing the exit code to return + * + * @details + * Automatically deallocates all remaining valid qubits and tensors of qubits, + * adds a return statement with a given exit code, + * and transfers ownership of the module to the caller. The builder should not + * be used after calling this method. + * + * The return value must have the type indicated by the function signature + * of the main function, which returns an `i64` by default and can be + * modified by passing different arguments to the `initialize()` method. + * + * @return OwningOpRef containing the constructed quantum program module + */ + OwningOpRef finalize(Value returnValue); + /** * @brief Convenience method for building quantum programs * @param context The MLIR context to use for building the program @@ -1037,7 +1091,8 @@ class QIRProgramBuilder final : public ImplicitLocOpBuilder { */ static OwningOpRef build(MLIRContext* context, - const function_ref& buildFunc, + const function_ref< + std::pair(QIRProgramBuilder&)>& buildFunc, Profile profile = Profile::Adaptive); private: diff --git a/mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp b/mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp index 03d7acb815..d3e4576d89 100644 --- a/mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp +++ b/mlir/lib/Dialect/QC/Builder/QCProgramBuilder.cpp @@ -12,6 +12,7 @@ #include "mlir/Dialect/QC/IR/QCDialect.h" #include "mlir/Dialect/QC/IR/QCOps.h" +#include "mlir/Dialect/QCO/IR/QCODialect.h" #include "mlir/Dialect/Utils/Utils.h" #include @@ -47,12 +48,14 @@ QCProgramBuilder::QCProgramBuilder(MLIRContext* context) ctx->loadDialect(); } -void QCProgramBuilder::initialize() { +void QCProgramBuilder::initialize() { initialize({getI64Type()}); } + +void QCProgramBuilder::initialize(TypeRange returnTypes) { // Set insertion point to the module body setInsertionPointToStart(cast(module).getBody()); // Create main function as entry point - auto funcType = getFunctionType({}, {getI64Type()}); + auto funcType = getFunctionType({}, returnTypes); auto mainFunc = func::FuncOp::create(*this, "main", funcType); // Add entry_point attribute to identify the main function @@ -65,6 +68,16 @@ void QCProgramBuilder::initialize() { regionStack.emplace_back(entryBlock.getParent()); } +void QCProgramBuilder::retype(TypeRange returnTypes) { + auto mainFunc = qco::getEntryPoint(mlir::cast(module)); + if (!mainFunc) { + llvm::reportFatalUsageError("Main function not found for retyping"); + } + auto funcType = + getFunctionType(mainFunc.getFunctionType().getInputs(), returnTypes); + mainFunc.setType(funcType); +} + Value QCProgramBuilder::boolConstant(const bool value) { checkFinalized(); return arith::ConstantOp::create(*this, getBoolAttr(value)).getResult(); @@ -630,6 +643,13 @@ void QCProgramBuilder::ensureAllocationMode( OwningOpRef QCProgramBuilder::finalize() { checkFinalized(); + auto exitCode = intConstant(0); + return finalize({exitCode}); +} + +OwningOpRef QCProgramBuilder::finalize(ValueRange returnValues) { + checkFinalized(); + // Ensure that main function exists and insertion point is valid auto* insertionBlock = getInsertionBlock(); func::FuncOp mainFunc = nullptr; @@ -660,11 +680,8 @@ OwningOpRef QCProgramBuilder::finalize() { } allocatedMemrefs.clear(); - // Create constant 0 for successful exit code - auto exitCode = intConstant(0); - - // Add return statement with exit code 0 to the main function - func::ReturnOp::create(*this, exitCode); + // Add return statement with the given return values to the main function + func::ReturnOp::create(*this, returnValues); // Invalidate context to prevent use-after-finalize ctx = nullptr; @@ -675,11 +692,13 @@ OwningOpRef QCProgramBuilder::finalize() { OwningOpRef QCProgramBuilder::build( MLIRContext* context, - const function_ref& buildFunc) { + const function_ref, SmallVector>( + QCProgramBuilder&)>& buildFunc) { QCProgramBuilder builder(context); builder.initialize(); - buildFunc(builder); - return builder.finalize(); + auto [result, resultTypes] = buildFunc(builder); + builder.retype(resultTypes); + return builder.finalize(result); } } // namespace mlir::qc diff --git a/mlir/lib/Dialect/QC/Translation/TranslateQuantumComputationToQC.cpp b/mlir/lib/Dialect/QC/Translation/TranslateQuantumComputationToQC.cpp index 7a2cf23651..1087d15fd6 100644 --- a/mlir/lib/Dialect/QC/Translation/TranslateQuantumComputationToQC.cpp +++ b/mlir/lib/Dialect/QC/Translation/TranslateQuantumComputationToQC.cpp @@ -849,7 +849,15 @@ OwningOpRef translateQuantumComputationToQC( MLIRContext* context, const ::qc::QuantumComputation& quantumComputation) { // Create and initialize the builder (creates module and main function) QCProgramBuilder builder(context); - builder.initialize(); + SmallVector resultTypes(quantumComputation.getNcbits()); + for (auto i = 0; i < quantumComputation.getNcbits(); ++i) { + resultTypes[i] = builder.getI1Type(); + } + if (quantumComputation.getNcbits() == 0) { + // Without classical bits, we instead return an exit code 0. + resultTypes.push_back(builder.getI64Type()); + } + builder.initialize(resultTypes); // Allocate quantum registers using the builder const auto qregs = allocateQregs(builder, quantumComputation); @@ -876,7 +884,9 @@ OwningOpRef translateQuantumComputationToQC( // Finalize and return the module (adds return statement and transfers // ownership) - return builder.finalize(); + return quantumComputation.getNcbits() == 0 + ? builder.finalize({builder.intConstant(0)}) + : builder.finalize(state.results); } } // namespace mlir diff --git a/mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp b/mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp index da20f3bfa4..6db2692f21 100644 --- a/mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp +++ b/mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp @@ -52,12 +52,14 @@ QCOProgramBuilder::QCOProgramBuilder(MLIRContext* context) ctx->loadDialect(); } -void QCOProgramBuilder::initialize() { +void QCOProgramBuilder::initialize() { initialize({getI64Type()}); } + +void QCOProgramBuilder::initialize(TypeRange returnTypes) { // Set insertion point to the module body setInsertionPointToStart(mlir::cast(module).getBody()); // Create main function as entry point - auto funcType = getFunctionType({}, {getI64Type()}); + auto funcType = getFunctionType({}, returnTypes); auto mainFunc = func::FuncOp::create(*this, "main", funcType); // Add entry_point attribute to identify the main function @@ -69,6 +71,16 @@ void QCOProgramBuilder::initialize() { setInsertionPointToStart(&entryBlock); } +void QCOProgramBuilder::retype(TypeRange returnTypes) { + auto mainFunc = getEntryPoint(mlir::cast(module)); + if (!mainFunc) { + llvm::reportFatalUsageError("Main function not found for retyping"); + } + auto funcType = + getFunctionType(mainFunc.getFunctionType().getInputs(), returnTypes); + mainFunc.setType(funcType); +} + Value QCOProgramBuilder::intConstant(const int64_t value) { checkFinalized(); return arith::ConstantOp::create(*this, getI64IntegerAttr(value)).getResult(); @@ -400,7 +412,8 @@ std::pair QCOProgramBuilder::measure(Value qubit) { return {qubitOut, result}; } -Value QCOProgramBuilder::measure(Value qubit, const Bit& bit) { +std::pair QCOProgramBuilder::measure(Value qubit, + const Bit& bit) { checkFinalized(); auto nameAttr = getStringAttr(bit.registerName); @@ -413,7 +426,7 @@ Value QCOProgramBuilder::measure(Value qubit, const Bit& bit) { // Update tracking updateQubitTracking(qubit, qubitOut); - return qubitOut; + return {qubitOut, measureOp.getResult()}; } Value QCOProgramBuilder::reset(Value qubit) { @@ -1103,6 +1116,13 @@ void QCOProgramBuilder::ensureAllocationMode( OwningOpRef QCOProgramBuilder::finalize() { checkFinalized(); + auto exitCode = intConstant(0); + return finalize({exitCode}); +} + +OwningOpRef QCOProgramBuilder::finalize(ValueRange returnValues) { + checkFinalized(); + // Ensure that main function exists and insertion point is valid auto* insertionBlock = getInsertionBlock(); func::FuncOp mainFunc = nullptr; @@ -1151,11 +1171,8 @@ OwningOpRef QCOProgramBuilder::finalize() { validQubits.clear(); validTensors.clear(); - // Create constant 0 for successful exit code - auto exitCode = intConstant(0); - - // Add return statement with exit code 0 to the main function - func::ReturnOp::create(*this, exitCode); + // Add return statement with the given return values to the main function + func::ReturnOp::create(*this, returnValues); // Invalidate context to prevent use-after-finalize ctx = nullptr; @@ -1165,11 +1182,13 @@ OwningOpRef QCOProgramBuilder::finalize() { OwningOpRef QCOProgramBuilder::build( MLIRContext* context, - const function_ref& buildFunc) { + const function_ref, SmallVector>( + QCOProgramBuilder&)>& buildFunc) { QCOProgramBuilder builder(context); builder.initialize(); - buildFunc(builder); - return builder.finalize(); + auto [result, resultTypes] = buildFunc(builder); + builder.retype(resultTypes); + return builder.finalize(result); } } // namespace mlir::qco diff --git a/mlir/lib/Dialect/QCO/IR/Operations/MeasureOp.cpp b/mlir/lib/Dialect/QCO/IR/Operations/MeasureOp.cpp index b76a2d0471..b2107f7836 100644 --- a/mlir/lib/Dialect/QCO/IR/Operations/MeasureOp.cpp +++ b/mlir/lib/Dialect/QCO/IR/Operations/MeasureOp.cpp @@ -9,12 +9,37 @@ */ #include "mlir/Dialect/QCO/IR/QCOOps.h" +#include "mlir/Dialect/QCO/QCOUtils.h" +#include +#include #include using namespace mlir; using namespace mlir::qco; +namespace { + +/** + * @brief Remove dead measurements. + */ +struct DeadMeasurementRemoval final : OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(MeasureOp op, + PatternRewriter& rewriter) const override { + if (!checkDeadGate(op)) { + return failure(); + } + + rewriter.replaceAllUsesWith(op.getQubitOut(), op.getQubitIn()); + rewriter.eraseOp(op); + return success(); + } +}; + +} // namespace + LogicalResult MeasureOp::verify() { const auto registerName = getRegisterName(); const auto registerSize = getRegisterSize(); @@ -37,3 +62,8 @@ LogicalResult MeasureOp::verify() { } return success(); } + +void MeasureOp::getCanonicalizationPatterns(RewritePatternSet& results, + MLIRContext* context) { + results.add(context); +} diff --git a/mlir/lib/Dialect/QCO/IR/Operations/ResetOp.cpp b/mlir/lib/Dialect/QCO/IR/Operations/ResetOp.cpp index 8832162354..0886ba39a6 100644 --- a/mlir/lib/Dialect/QCO/IR/Operations/ResetOp.cpp +++ b/mlir/lib/Dialect/QCO/IR/Operations/ResetOp.cpp @@ -9,6 +9,7 @@ */ #include "mlir/Dialect/QCO/IR/QCOOps.h" +#include "mlir/Dialect/QCO/QCOUtils.h" #include "mlir/Dialect/QTensor/IR/QTensorOps.h" #include "mlir/Dialect/QTensor/IR/QTensorUtils.h" @@ -101,6 +102,23 @@ struct RemoveResetAfterExtract final : OpRewritePattern { } }; +/** + * @brief Remove dead resets. + */ +struct DeadResetRemoval final : OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(ResetOp op, + PatternRewriter& rewriter) const override { + if (!checkDeadGate(op)) { + return failure(); + } + + rewriter.replaceOp(op, op->getOperands()); + return success(); + } +}; + } // namespace OpFoldResult ResetOp::fold(FoldAdaptor /*adaptor*/) { @@ -113,5 +131,5 @@ OpFoldResult ResetOp::fold(FoldAdaptor /*adaptor*/) { void ResetOp::getCanonicalizationPatterns(RewritePatternSet& results, MLIRContext* context) { - results.add(context); + results.add(context); } diff --git a/mlir/lib/Dialect/QCO/IR/QCOOps.cpp b/mlir/lib/Dialect/QCO/IR/QCOOps.cpp index f1cb23a849..81fb68f925 100644 --- a/mlir/lib/Dialect/QCO/IR/QCOOps.cpp +++ b/mlir/lib/Dialect/QCO/IR/QCOOps.cpp @@ -11,13 +11,17 @@ #include "mlir/Dialect/QCO/IR/QCOOps.h" #include "mlir/Dialect/QCO/IR/QCODialect.h" // IWYU pragma: associated +#include "mlir/Dialect/QCO/IR/QCOInterfaces.h" +#include "mlir/Dialect/QCO/QCOUtils.h" #include "mlir/Dialect/Utils/Utils.h" #include #include +#include #include #include #include +#include #include #include #include @@ -31,6 +35,33 @@ using namespace mlir; using namespace mlir::qco; +//===----------------------------------------------------------------------===// +// Dialect-Level Canonicalizers +//===----------------------------------------------------------------------===// + +namespace { + +/** + * @brief Remove dead gates. + */ +struct DeadGateElimination final + : public OpInterfaceRewritePattern { + + explicit DeadGateElimination(MLIRContext* context) + : OpInterfaceRewritePattern(context) {} + + LogicalResult matchAndRewrite(UnitaryOpInterface op, + PatternRewriter& rewriter) const override { + if (!checkDeadGate(op)) { + return failure(); + } + + rewriter.replaceOp(op, op.getInputQubits()); + return success(); + } +}; +} // namespace + //===----------------------------------------------------------------------===// // Custom Parsers //===----------------------------------------------------------------------===// @@ -190,6 +221,10 @@ void QCODialect::initialize() { >(); } +void QCODialect::getCanonicalizationPatterns(RewritePatternSet& results) const { + results.add(getContext()); +} + //===----------------------------------------------------------------------===// // Types //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp b/mlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp index 4ac2d98faa..00e17eb0a1 100644 --- a/mlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp +++ b/mlir/lib/Dialect/QCO/IR/SCF/IfOp.cpp @@ -9,6 +9,7 @@ */ #include "mlir/Dialect/QCO/IR/QCOOps.h" +#include "mlir/Dialect/QCO/QCOUtils.h" #include #include @@ -234,11 +235,29 @@ struct ConditionPropagation : public OpRewritePattern { return success(changed); } }; + +/** + * @brief Remove dead `IfOp` instructions. + */ +struct DeadIfRemoval final : OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + + LogicalResult matchAndRewrite(IfOp op, + PatternRewriter& rewriter) const override { + if (!checkDeadGate(op)) { + return failure(); + } + + rewriter.replaceOp(op, op.getQubits()); + return success(); + } +}; } // namespace void IfOp::getCanonicalizationPatterns(RewritePatternSet& results, MLIRContext* context) { results.add(context); + results.add(context); populateRegionBranchOpInterfaceCanonicalizationPatterns( results, IfOp::getOperationName()); } diff --git a/mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp b/mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp index 771e62b926..2943de2dc7 100644 --- a/mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp +++ b/mlir/lib/Dialect/QIR/Builder/QIRProgramBuilder.cpp @@ -48,12 +48,14 @@ QIRProgramBuilder::QIRProgramBuilder(MLIRContext* context) getContext()->loadDialect(); } -void QIRProgramBuilder::initialize() { +void QIRProgramBuilder::initialize() { initialize(getI64Type()); } + +void QIRProgramBuilder::initialize(Type returnType) { // Set insertion point to the module body setInsertionPointToStart(cast(module).getBody()); // Create main function: () -> i64 - auto funcType = LLVM::LLVMFunctionType::get(getI64Type(), {}); + auto funcType = LLVM::LLVMFunctionType::get(returnType, {}); auto mainFuncOp = LLVM::LLVMFuncOp::create(*this, "main", funcType); mainFunc = mainFuncOp.getOperation(); @@ -84,7 +86,6 @@ void QIRProgramBuilder::initialize() { // Create exit code constant in entry block setInsertionPointToStart(entryBlock); - exitCode = intConstant(0); // Add initialize call auto initSig = LLVM::LLVMFunctionType::get(voidType, ptrType); @@ -96,14 +97,19 @@ void QIRProgramBuilder::initialize() { setInsertionPointToEnd(entryBlock); LLVM::BrOp::create(*this, bodyBlock); - // Return the exit code (success) in output block - setInsertionPointToEnd(outputBlock); - LLVM::ReturnOp::create(*this, exitCode); - // Set insertion point to body block for user operations setInsertionPointToStart(bodyBlock); } +void QIRProgramBuilder::retype(Type returnType) { + auto mainFn = dyn_cast(mainFunc); + if (!mainFn) { + llvm::reportFatalUsageError("Main function not found for retyping"); + } + auto funcType = LLVM::LLVMFunctionType::get(returnType, {}); + mainFn.setType(funcType); +} + Value QIRProgramBuilder::resolveIntVariant( const std::variant& variant) { if (std::holds_alternative(variant)) { @@ -423,6 +429,17 @@ QIRProgramBuilder& QIRProgramBuilder::reset(Value qubit) { return *this; } +Value QIRProgramBuilder::readResult(mlir::Value result) { + checkFinalized(); + + const auto fnSig = LLVM::LLVMFunctionType::get(getI1Type(), {ptrType}); + auto fnDec = + getOrCreateFunctionDeclaration(*this, module, QIR_READ_RESULT, fnSig); + auto readOp = LLVM::CallOp::create(*this, fnDec, result); + + return readOp.getResult(); +} + //===----------------------------------------------------------------------===// // Unitary Operations //===----------------------------------------------------------------------===// @@ -983,9 +1000,20 @@ void QIRProgramBuilder::generateOutputRecording() { OwningOpRef QIRProgramBuilder::finalize() { checkFinalized(); + auto exitCode = intConstant(0); + return finalize(exitCode); +} + +OwningOpRef QIRProgramBuilder::finalize(Value returnValue) { + checkFinalized(); + // Save current insertion point const InsertionGuard guard(*this); + // Add return statement with the given return values to the main function + setInsertionPointToEnd(outputBlock); + LLVM::ReturnOp::create(*this, returnValue); + // Release resources in output block setInsertionPoint(outputBlock->getTerminator()); @@ -1037,12 +1065,14 @@ OwningOpRef QIRProgramBuilder::finalize() { OwningOpRef QIRProgramBuilder::build( MLIRContext* context, - const function_ref& buildFunc, Profile profile) { + const function_ref(QIRProgramBuilder&)>& buildFunc, + Profile profile) { QIRProgramBuilder builder(context); builder.profile = profile; builder.initialize(); - buildFunc(builder); - return builder.finalize(); + auto [result, resultType] = buildFunc(builder); + builder.retype(resultType); + return builder.finalize(result); } } // namespace mlir::qir diff --git a/mlir/unittests/Compiler/test_compiler_pipeline.cpp b/mlir/unittests/Compiler/test_compiler_pipeline.cpp index 191074ddac..c452465b01 100644 --- a/mlir/unittests/Compiler/test_compiler_pipeline.cpp +++ b/mlir/unittests/Compiler/test_compiler_pipeline.cpp @@ -44,8 +44,11 @@ namespace mqt::test::compiler { -using QCProgramBuilderFn = NamedBuilder; -using QIRProgramBuilderFn = NamedBuilder; +using QCProgramBuilderFn = NamedBuilder< + mlir::qc::QCProgramBuilder, + std::pair, mlir::SmallVector>>; +using QIRProgramBuilderFn = NamedBuilder>; using QuantumComputationBuilderFn = NamedBuilder<::qc::QuantumComputation>; namespace { @@ -208,10 +211,15 @@ TEST_P(CompilerPipelineTest, EndToEndPipeline) { */ TEST_F(CompilerPipelineTest, RotationGateMergingPass) { auto module = mlir::qc::QCProgramBuilder::build( - context.get(), [&](mlir::qc::QCProgramBuilder& b) { + context.get(), + [&](mlir::qc::QCProgramBuilder& b) + -> std::pair, + mlir::SmallVector> { auto q = b.allocQubit(); b.rz(1.0, q); b.rx(1.0, q); + auto m = b.measure(q); + return {{m}, {b.getI1Type()}}; }); ASSERT_TRUE(module); @@ -231,10 +239,15 @@ TEST_F(CompilerPipelineTest, RotationGateMergingPass) { */ TEST_F(CompilerPipelineTest, HadamardLiftingPass) { auto module = mlir::qc::QCProgramBuilder::build( - context.get(), [&](mlir::qc::QCProgramBuilder& b) { + context.get(), + [&](mlir::qc::QCProgramBuilder& b) + -> std::pair, + mlir::SmallVector> { auto q = b.allocQubit(); b.x(q); b.h(q); + auto m = b.measure(q); + return {{m}, {b.getI1Type()}}; }); ASSERT_TRUE(module); @@ -277,23 +290,23 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(mlir::qc::staticQubitsWithInv), MQT_NAMED_BUILDER(mlir::qc::staticQubitsWithInv), MQT_NAMED_BUILDER(mlir::qir::staticQubitsWithInv), false}, - CompilerPipelineTestCase{"AllocQubit", - MQT_NAMED_BUILDER(qc::allocQubit), nullptr, - MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, - CompilerPipelineTestCase{"AllocQubitRegister", - MQT_NAMED_BUILDER(qc::allocQubitRegister), - nullptr, MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, + CompilerPipelineTestCase{ + "AllocQubit", MQT_NAMED_BUILDER(qc::allocQubit), nullptr, + MQT_NAMED_BUILDER(mlir::qc::alloc1QubitRegister), + MQT_NAMED_BUILDER(mlir::qir::alloc1QubitRegister)}, + CompilerPipelineTestCase{ + "AllocQubitRegister", MQT_NAMED_BUILDER(qc::allocQubitRegister), + nullptr, MQT_NAMED_BUILDER(mlir::qc::allocQubitRegister), + MQT_NAMED_BUILDER(mlir::qir::allocQubitRegister)}, CompilerPipelineTestCase{ "AllocMultipleQubitRegisters", MQT_NAMED_BUILDER(qc::allocMultipleQubitRegisters), nullptr, - MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, - CompilerPipelineTestCase{"AllocLargeRegister", - MQT_NAMED_BUILDER(qc::allocLargeRegister), - nullptr, MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, + MQT_NAMED_BUILDER(mlir::qc::allocMultipleQubitRegisters), + MQT_NAMED_BUILDER(mlir::qir::allocMultipleQubitRegisters)}, + CompilerPipelineTestCase{ + "AllocLargeRegister", MQT_NAMED_BUILDER(qc::allocLargeRegister), + nullptr, MQT_NAMED_BUILDER(mlir::qc::allocLargeRegister), + MQT_NAMED_BUILDER(mlir::qir::allocQubitRegister)}, CompilerPipelineTestCase{ "SingleMeasurementToSingleBit", MQT_NAMED_BUILDER(qc::singleMeasurementToSingleBit), nullptr, @@ -341,19 +354,20 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(qc::globalPhase), nullptr, MQT_NAMED_BUILDER(mlir::qc::globalPhase), MQT_NAMED_BUILDER(mlir::qir::globalPhase)}, - CompilerPipelineTestCase{"Identity", MQT_NAMED_BUILDER(qc::identity), - nullptr, MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, + CompilerPipelineTestCase{ + "Identity", MQT_NAMED_BUILDER(qc::identity), nullptr, + MQT_NAMED_BUILDER(mlir::qc::alloc1QubitRegister), + MQT_NAMED_BUILDER(mlir::qir::alloc1QubitRegister)}, CompilerPipelineTestCase{ "SingleControlledIdentity", MQT_NAMED_BUILDER(qc::singleControlledIdentity), nullptr, - MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, + MQT_NAMED_BUILDER(mlir::qc::allocQubitRegister), + MQT_NAMED_BUILDER(mlir::qir::allocQubitRegister)}, CompilerPipelineTestCase{ "MultipleControlledIdentity", MQT_NAMED_BUILDER(qc::multipleControlledIdentity), nullptr, - MQT_NAMED_BUILDER(mlir::qc::emptyQC), - MQT_NAMED_BUILDER(mlir::qir::emptyQIR)}, + MQT_NAMED_BUILDER(mlir::qc::alloc1QubitRegister), + MQT_NAMED_BUILDER(mlir::qir::alloc1QubitRegister)}, CompilerPipelineTestCase{"X", MQT_NAMED_BUILDER(qc::x), nullptr, MQT_NAMED_BUILDER(mlir::qc::x), MQT_NAMED_BUILDER(mlir::qir::x)}, diff --git a/mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp b/mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp index 0f09b2b274..dcef2f4d34 100644 --- a/mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp +++ b/mlir/unittests/Conversion/JeffRoundTrip/test_jeff_round_trip.cpp @@ -42,8 +42,12 @@ namespace { struct JeffRoundTripTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const JeffRoundTripTestCase& info); diff --git a/mlir/unittests/Conversion/QCOToQC/test_qco_to_qc.cpp b/mlir/unittests/Conversion/QCOToQC/test_qco_to_qc.cpp index f25ce73b6f..6a2801f873 100644 --- a/mlir/unittests/Conversion/QCOToQC/test_qco_to_qc.cpp +++ b/mlir/unittests/Conversion/QCOToQC/test_qco_to_qc.cpp @@ -41,8 +41,12 @@ namespace { struct QCOToQCTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const QCOToQCTestCase& info); diff --git a/mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp b/mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp index 9e66a0b655..cae1dc0009 100644 --- a/mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp +++ b/mlir/unittests/Conversion/QCToQCO/test_qc_to_qco.cpp @@ -41,8 +41,12 @@ namespace { struct QCToQCOTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const QCToQCOTestCase& info); diff --git a/mlir/unittests/Conversion/QCToQIR/QCToQIRAdaptive/test_qc_to_qir_adaptive.cpp b/mlir/unittests/Conversion/QCToQIR/QCToQIRAdaptive/test_qc_to_qir_adaptive.cpp index 1a1f5a3639..ffc609fadf 100644 --- a/mlir/unittests/Conversion/QCToQIR/QCToQIRAdaptive/test_qc_to_qir_adaptive.cpp +++ b/mlir/unittests/Conversion/QCToQIR/QCToQIRAdaptive/test_qc_to_qir_adaptive.cpp @@ -42,7 +42,9 @@ namespace { struct QCToQIRAdaptiveTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; mqt::test::NamedBuilder referenceBuilder; friend std::ostream& operator<<(std::ostream& os, diff --git a/mlir/unittests/Conversion/QCToQIR/QCToQIRBase/test_qc_to_qir_base.cpp b/mlir/unittests/Conversion/QCToQIR/QCToQIRBase/test_qc_to_qir_base.cpp index 409d1d70de..0999355b6e 100644 --- a/mlir/unittests/Conversion/QCToQIR/QCToQIRBase/test_qc_to_qir_base.cpp +++ b/mlir/unittests/Conversion/QCToQIR/QCToQIRBase/test_qc_to_qir_base.cpp @@ -42,7 +42,9 @@ namespace { struct QCToQIRBaseTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; mqt::test::NamedBuilder referenceBuilder; friend std::ostream& operator<<(std::ostream& os, diff --git a/mlir/unittests/Dialect/QC/IR/test_qc_ir.cpp b/mlir/unittests/Dialect/QC/IR/test_qc_ir.cpp index 4d0f56912b..63257ae7cb 100644 --- a/mlir/unittests/Dialect/QC/IR/test_qc_ir.cpp +++ b/mlir/unittests/Dialect/QC/IR/test_qc_ir.cpp @@ -35,8 +35,12 @@ namespace { struct QCTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const QCTestCase& info); }; diff --git a/mlir/unittests/Dialect/QCO/IR/test_qco_ir.cpp b/mlir/unittests/Dialect/QCO/IR/test_qco_ir.cpp index 883c7d32d2..f6a39ada17 100644 --- a/mlir/unittests/Dialect/QCO/IR/test_qco_ir.cpp +++ b/mlir/unittests/Dialect/QCO/IR/test_qco_ir.cpp @@ -39,8 +39,12 @@ namespace { struct QCOTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const QCOTestCase& info); }; @@ -74,7 +78,8 @@ TEST_P(QCOTest, ProgramEquivalence) { const auto name = " (" + GetParam().name + ")"; mqt::test::DeferredPrinter printer; - auto program = QCOProgramBuilder::build(context.get(), programBuilder.fn); + auto program = + QCOProgramBuilder::buildWithReturn(context.get(), programBuilder.fn); ASSERT_TRUE(program); printer.record(program.get(), "Original QCO IR" + name); EXPECT_TRUE(verify(*program).succeeded()); @@ -83,7 +88,8 @@ TEST_P(QCOTest, ProgramEquivalence) { printer.record(program.get(), "Canonicalized QCO IR" + name); EXPECT_TRUE(verify(*program).succeeded()); - auto reference = QCOProgramBuilder::build(context.get(), referenceBuilder.fn); + auto reference = + QCOProgramBuilder::buildWithReturn(context.get(), referenceBuilder.fn); ASSERT_TRUE(reference); printer.record(reference.get(), "Reference QCO IR" + name); EXPECT_TRUE(verify(*reference).succeeded()); @@ -114,10 +120,124 @@ TEST_F(QCOTest, BuilderRejectsMixedStaticAndDynamicQubitAllocationModes) { "Cannot mix dynamic and static qubit allocation modes"); } +TEST_F(QCOTest, CheckDeadGateElimination) { + QCOProgramBuilder builder(context.get()); + builder.initialize({builder.getI1Type(), builder.getI1Type()}); + auto q0S0 = builder.allocQubit(); + auto q1S0 = builder.allocQubit(); + + auto [q0Measured, m0] = builder.measure(q0S0); + auto [q1Measured, m1] = builder.measure(q1S0); + + auto q0S1 = builder.h(q0Measured); + auto [q0S2, q1S1] = builder.cx(q0S1, q1Measured); + auto [q1S2, c1] = builder.measure(q1S1); + builder.sink(q0S2); + builder.sink(q1S2); + auto module = builder.finalize({m0, m1}); + + QCOProgramBuilder reference(context.get()); + reference.initialize({reference.getI1Type(), reference.getI1Type()}); + auto r0 = reference.allocQubit(); + auto r1 = reference.allocQubit(); + auto [r0Measured, mr0] = reference.measure(r0); + auto [r1Measured, mr1] = reference.measure(r1); + reference.sink(r0Measured); + reference.sink(r1Measured); + auto refModule = reference.finalize({mr0, mr1}); + + ASSERT_TRUE(module); + EXPECT_TRUE(verify(*module).succeeded()); + EXPECT_TRUE(runQCOCleanupPipeline(module.get()).succeeded()); + EXPECT_TRUE(verify(*module).succeeded()); + + ASSERT_TRUE(refModule); + EXPECT_TRUE(verify(*refModule).succeeded()); + EXPECT_TRUE(runQCOCleanupPipeline(refModule.get()).succeeded()); + EXPECT_TRUE(verify(*refModule).succeeded()); + + EXPECT_TRUE( + areModulesEquivalentWithPermutations(module.get(), refModule.get())); +} + +TEST_F(QCOTest, CheckIfOpDeadGateElimination) { + QCOProgramBuilder builder(context.get()); + builder.initialize(); + auto q0S0 = builder.allocQubit(); + auto q1S0 = builder.allocQubit(); + auto q0S1 = builder.h(q0S0); + auto [q0S2, c0] = builder.measure(q0S1); + + // This is an `if` with memory effects - it can't be removed. + auto q1S1 = builder.qcoIf( + c0, {q1S0}, + [&](ValueRange qubits) -> SmallVector { + auto q1Then = builder.x(qubits[0]); + builder.gphase(0.5); // This adds memory effects to the `IfOp`. + return SmallVector{q1Then}; + }, + [&](ValueRange qubits) -> SmallVector { + auto q1Else = builder.h(qubits[0]); + return SmallVector{q1Else}; + })[0]; + + // This is an `if` without memory effects - it can be removed. + auto q1S2 = builder.qcoIf( + c0, {q1S1}, + [&](ValueRange qubits) -> SmallVector { + auto q1Then = builder.x(qubits[0]); + return SmallVector{q1Then}; + }, + [&](ValueRange qubits) -> SmallVector { + auto q1Else = builder.h(qubits[0]); + return SmallVector{q1Else}; + })[0]; + builder.sink(q0S2); + builder.sink(q1S2); + auto module = builder.finalize(); + + QCOProgramBuilder reference(context.get()); + reference.initialize(); + auto r0S0 = reference.allocQubit(); + auto r1S0 = reference.allocQubit(); + auto r0S1 = reference.h(r0S0); + auto [r0S2, cr0] = reference.measure(r0S1); + + // This is an `if` with memory effects - it can't be removed. + auto r1S1 = reference.qcoIf( + cr0, {r1S0}, + [&](ValueRange qubits) -> SmallVector { + auto q1Then = reference.x(qubits[0]); + reference.gphase(0.5); // Due to memory effect, the `IfOp` stays. + return SmallVector{q1Then}; + }, + [&](ValueRange qubits) -> SmallVector { + auto q1Else = reference.h(qubits[0]); + return SmallVector{q1Else}; + })[0]; + + reference.sink(r0S2); + reference.sink(r1S1); + auto refModule = reference.finalize(); + + ASSERT_TRUE(module); + EXPECT_TRUE(verify(*module).succeeded()); + EXPECT_TRUE(runQCOCleanupPipeline(module.get()).succeeded()); + EXPECT_TRUE(verify(*module).succeeded()); + + ASSERT_TRUE(refModule); + EXPECT_TRUE(verify(*refModule).succeeded()); + EXPECT_TRUE(runQCOCleanupPipeline(refModule.get()).succeeded()); + EXPECT_TRUE(verify(*refModule).succeeded()); + + EXPECT_TRUE( + areModulesEquivalentWithPermutations(module.get(), refModule.get())); +} + TEST_F(QCOTest, DirectIfBuilder) { // Test If construction directly QCOProgramBuilder builder(context.get()); - builder.initialize(); + builder.initialize({builder.getI1Type()}); auto c0 = arith::ConstantIndexOp::create(builder, 0); auto c1 = arith::ConstantIndexOp::create(builder, 1); auto r0 = qtensor::AllocOp::create(builder, c1); @@ -130,18 +250,19 @@ TEST_F(QCOTest, DirectIfBuilder) { auto innerQubit = XOp::create(builder, qubits[0]); return SmallVector{innerQubit}; }); - auto r2 = qtensor::InsertOp::create(builder, ifOp.getResult(0), + auto finalMeasureOp = MeasureOp::create(builder, ifOp.getResult(0)); + auto r2 = qtensor::InsertOp::create(builder, finalMeasureOp.getQubitOut(), extractOp.getOutTensor(), c0); qtensor::DeallocOp::create(builder, r2); - auto directBuilder = builder.finalize(); + auto directBuilder = builder.finalize({finalMeasureOp.getResult()}); ASSERT_TRUE(directBuilder); EXPECT_TRUE(verify(*directBuilder).succeeded()); EXPECT_TRUE(runQCOCleanupPipeline(directBuilder.get()).succeeded()); EXPECT_TRUE(verify(*directBuilder).succeeded()); - auto refBuilder = - QCOProgramBuilder::build(context.get(), MQT_NAMED_BUILDER(simpleIf).fn); + auto refBuilder = QCOProgramBuilder::buildWithReturn( + context.get(), MQT_NAMED_BUILDER(simpleIf).fn); ASSERT_TRUE(refBuilder); EXPECT_TRUE(verify(*refBuilder).succeeded()); EXPECT_TRUE(runQCOCleanupPipeline(refBuilder.get()).succeeded()); @@ -155,10 +276,9 @@ TEST_F(QCOTest, IfOpParser) { // Test IfOp parser const char* mlirCode = R"( module { - func.func @main() -> i64 attributes {passthrough = ["entry_point"]} { + func.func @main() -> i1 attributes {passthrough = ["entry_point"]} { %c0 = arith.constant 0 : index %c1 = arith.constant 1 : index - %c0_i64 = arith.constant 0 : i64 %q0_0 = qco.alloc : !qco.qubit %t0 = qtensor.alloc(%c1) : tensor<1x!qco.qubit> %q0_1 = qco.h %q0_0 : !qco.qubit -> !qco.qubit @@ -172,9 +292,10 @@ TEST_F(QCOTest, IfOpParser) { } else args(%arg0 = %q0_2, %arg1 = %t0) { qco.yield %arg0, %arg1 : !qco.qubit, tensor<1x!qco.qubit> } - qco.sink %q0_4 : !qco.qubit + %q0_5, %c = qco.measure %q0_4 : !qco.qubit + qco.sink %q0_5 : !qco.qubit qtensor.dealloc %t3 : tensor<1x!qco.qubit> - return %c0_i64 : i64 + return %c : i1 } })"; @@ -185,7 +306,7 @@ TEST_F(QCOTest, IfOpParser) { EXPECT_TRUE(runQCOCleanupPipeline(parsedSourceModule.get()).succeeded()); EXPECT_TRUE(verify(*parsedSourceModule).succeeded()); - auto refBuilder = QCOProgramBuilder::build( + auto refBuilder = QCOProgramBuilder::buildWithReturn( context.get(), MQT_NAMED_BUILDER(ifOneQubitOneTensor).fn); ASSERT_TRUE(refBuilder); EXPECT_TRUE(verify(*refBuilder).succeeded()); @@ -306,7 +427,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(twoDcx)}, QCOTestCase{"TwoDCXSwappedTargets", MQT_NAMED_BUILDER(twoDcxSwappedTargets), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/EcrOp.cpp @@ -333,7 +454,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledEcr), MQT_NAMED_BUILDER(multipleControlledEcr)}, QCOTestCase{"TwoECR", MQT_NAMED_BUILDER(twoEcr), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/GphaseOp.cpp @@ -377,7 +498,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledH), MQT_NAMED_BUILDER(multipleControlledH)}, QCOTestCase{"TwoH", MQT_NAMED_BUILDER(twoH), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(allocQubit)})); /// @} /// \name QCO/Operations/StandardGates/IdOp.cpp @@ -386,24 +507,24 @@ INSTANTIATE_TEST_SUITE_P( QCOIDOpTest, QCOTest, testing::Values( QCOTestCase{"Identity", MQT_NAMED_BUILDER(identity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(allocQubit)}, QCOTestCase{"SingleControlledIdentity", MQT_NAMED_BUILDER(singleControlledIdentity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"MultipleControlledIdentity", MQT_NAMED_BUILDER(multipleControlledIdentity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc3QubitRegister)}, QCOTestCase{"NestedControlledIdentity", MQT_NAMED_BUILDER(nestedControlledIdentity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc3QubitRegister)}, QCOTestCase{"TrivialControlledIdentity", MQT_NAMED_BUILDER(trivialControlledIdentity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(allocQubit)}, QCOTestCase{"InverseIdentity", MQT_NAMED_BUILDER(inverseIdentity), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(allocQubit)}, QCOTestCase{"InverseMultipleControlledIdentity", MQT_NAMED_BUILDER(inverseMultipleControlledIdentity), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc3QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/IswapOp.cpp @@ -453,7 +574,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledP), MQT_NAMED_BUILDER(multipleControlledP)}, QCOTestCase{"TwoPOppositePhase", MQT_NAMED_BUILDER(twoPOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(allocQubit)})); /// @} /// \name QCO/Operations/StandardGates/ROp.cpp @@ -504,7 +625,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledRx), MQT_NAMED_BUILDER(multipleControlledRx)}, QCOTestCase{"TwoRXOppositePhase", MQT_NAMED_BUILDER(twoRxOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc1QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RxxOp.cpp @@ -537,10 +658,10 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(rxx)}, QCOTestCase{"TwoRXXOppositePhase", MQT_NAMED_BUILDER(twoRxxOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"TwoRXXOppositePhaseSwappedTargets", MQT_NAMED_BUILDER(twoRxxOppositePhaseSwappedTargets), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RyOp.cpp @@ -565,7 +686,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledRy), MQT_NAMED_BUILDER(multipleControlledRy)}, QCOTestCase{"TwoRYOppositePhase", MQT_NAMED_BUILDER(twoRyOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc1QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RyyOp.cpp @@ -598,10 +719,10 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(ryy)}, QCOTestCase{"TwoRYYOppositePhaseSwappedTargets", MQT_NAMED_BUILDER(twoRyyOppositePhaseSwappedTargets), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"TwoRYYOppositePhase", MQT_NAMED_BUILDER(twoRyyOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RzOp.cpp @@ -626,7 +747,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledRz), MQT_NAMED_BUILDER(multipleControlledRz)}, QCOTestCase{"TwoRZOppositePhase", MQT_NAMED_BUILDER(twoRzOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc1QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RzxOp.cpp @@ -654,7 +775,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(multipleControlledRzx)}, QCOTestCase{"TwoRZXOppositePhase", MQT_NAMED_BUILDER(twoRzxOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/RzzOp.cpp @@ -687,10 +808,10 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(rzz)}, QCOTestCase{"TwoRZZOppositePhaseSwappedTargets", MQT_NAMED_BUILDER(twoRzzOppositePhaseSwappedTargets), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"TwoRZZOppositePhase", MQT_NAMED_BUILDER(twoRzzOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/SOp.cpp @@ -714,7 +835,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledS), MQT_NAMED_BUILDER(multipleControlledSdg)}, QCOTestCase{"SThenSdg", MQT_NAMED_BUILDER(sThenSdg), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoS", MQT_NAMED_BUILDER(twoS), MQT_NAMED_BUILDER(z)})); /// @} @@ -742,7 +863,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledSdg), MQT_NAMED_BUILDER(multipleControlledS)}, QCOTestCase{"SdgThenS", MQT_NAMED_BUILDER(sdgThenS), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoSdg", MQT_NAMED_BUILDER(twoSdg), MQT_NAMED_BUILDER(z)})); /// @} @@ -771,10 +892,10 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledSwap), MQT_NAMED_BUILDER(multipleControlledSwap)}, QCOTestCase{"TwoSWAP", MQT_NAMED_BUILDER(twoSwap), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"TwoSWAPSwappedTargets", MQT_NAMED_BUILDER(twoSwapSwappedTargets), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/SxOp.cpp @@ -799,7 +920,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledSx), MQT_NAMED_BUILDER(multipleControlledSxdg)}, QCOTestCase{"SXThenSXdg", MQT_NAMED_BUILDER(sxThenSxdg), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoSX", MQT_NAMED_BUILDER(twoSx), MQT_NAMED_BUILDER(x)})); /// @} @@ -827,7 +948,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledSxdg), MQT_NAMED_BUILDER(multipleControlledSx)}, QCOTestCase{"SXdgThenSX", MQT_NAMED_BUILDER(sxdgThenSx), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoSXdg", MQT_NAMED_BUILDER(twoSxdg), MQT_NAMED_BUILDER(x)})); /// @} @@ -853,7 +974,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledT), MQT_NAMED_BUILDER(multipleControlledTdg)}, QCOTestCase{"TThenTdg", MQT_NAMED_BUILDER(tThenTdg), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoT", MQT_NAMED_BUILDER(twoT), MQT_NAMED_BUILDER(s)})); /// @} @@ -881,7 +1002,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledTdg), MQT_NAMED_BUILDER(multipleControlledT)}, QCOTestCase{"TdgThenS", MQT_NAMED_BUILDER(tdgThenT), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"TwoTdg", MQT_NAMED_BUILDER(twoTdg), MQT_NAMED_BUILDER(sdg)})); /// @} @@ -966,11 +1087,11 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledX), MQT_NAMED_BUILDER(multipleControlledX)}, QCOTestCase{"TwoX", MQT_NAMED_BUILDER(twoX), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc1QubitRegister)}, QCOTestCase{"ControlledTwoX", MQT_NAMED_BUILDER(controlledTwoX), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"InverseTwoX", MQT_NAMED_BUILDER(inverseTwoX), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/XxMinusYyOp.cpp @@ -999,7 +1120,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(multipleControlledXxMinusYY)}, QCOTestCase{"TwoXXMinusYYOppositePhase", MQT_NAMED_BUILDER(twoXxMinusYYOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/XxPlusYyOp.cpp @@ -1028,7 +1149,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(multipleControlledXxPlusYY)}, QCOTestCase{"TwoXXPlusYYOppositePhase", MQT_NAMED_BUILDER(twoXxPlusYYOppositePhase), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc2QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/YOp.cpp @@ -1052,7 +1173,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledY), MQT_NAMED_BUILDER(multipleControlledY)}, QCOTestCase{"TwoY", MQT_NAMED_BUILDER(twoY), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc1QubitRegister)})); /// @} /// \name QCO/Operations/StandardGates/ZOp.cpp @@ -1076,7 +1197,7 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(inverseMultipleControlledZ), MQT_NAMED_BUILDER(multipleControlledZ)}, QCOTestCase{"TwoZ", MQT_NAMED_BUILDER(twoZ), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(alloc1QubitRegister)})); /// @} /// \name QCO/Operations/MeasureOp.cpp @@ -1105,13 +1226,13 @@ INSTANTIATE_TEST_SUITE_P( QCOResetOpTest, QCOTest, testing::Values(QCOTestCase{"ResetQubitWithoutOp", MQT_NAMED_BUILDER(resetQubitWithoutOp), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(allocQubit)}, QCOTestCase{"ResetMultipleQubitsWithoutOp", MQT_NAMED_BUILDER(resetMultipleQubitsWithoutOp), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(alloc2QubitRegister)}, QCOTestCase{"RepeatedResetWithoutOp", MQT_NAMED_BUILDER(repeatedResetWithoutOp), - MQT_NAMED_BUILDER(emptyQCO)}, + MQT_NAMED_BUILDER(allocQubit)}, QCOTestCase{"ResetQubitAfterSingleOp", MQT_NAMED_BUILDER(resetQubitAfterSingleOp), MQT_NAMED_BUILDER(resetQubitAfterSingleOp)}, @@ -1129,16 +1250,10 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( QCOQubitManagementTest, QCOTest, testing::Values( - QCOTestCase{"AllocQubit", MQT_NAMED_BUILDER(allocQubit), - MQT_NAMED_BUILDER(emptyQCO)}, - QCOTestCase{"AllocQubitRegister", MQT_NAMED_BUILDER(allocQubitRegister), - MQT_NAMED_BUILDER(emptyQCO)}, - QCOTestCase{"AllocMultipleQubitRegisters", - MQT_NAMED_BUILDER(allocMultipleQubitRegisters), - MQT_NAMED_BUILDER(emptyQCO)}, - QCOTestCase{"AllocLargeRegister", MQT_NAMED_BUILDER(allocLargeRegister), + QCOTestCase{"AllocQubit", MQT_NAMED_BUILDER(allocQubitNoMeasure), MQT_NAMED_BUILDER(emptyQCO)}, - QCOTestCase{"StaticQubits", MQT_NAMED_BUILDER(staticQubits), + QCOTestCase{"StaticQubitsNoMeasure", + MQT_NAMED_BUILDER(staticQubitsNoMeasure), MQT_NAMED_BUILDER(emptyQCO)}, QCOTestCase{"StaticQubitsWithOps", MQT_NAMED_BUILDER(staticQubitsWithOps), @@ -1156,5 +1271,5 @@ INSTANTIATE_TEST_SUITE_P( MQT_NAMED_BUILDER(staticQubitsWithInv), MQT_NAMED_BUILDER(staticQubitsWithInv)}, QCOTestCase{"AllocSinkPair", MQT_NAMED_BUILDER(allocSinkPair), - MQT_NAMED_BUILDER(emptyQCO)})); + MQT_NAMED_BUILDER(allocQubit)})); /// @} diff --git a/mlir/unittests/Dialect/QCO/IR/test_qco_ir_matrix.cpp b/mlir/unittests/Dialect/QCO/IR/test_qco_ir_matrix.cpp index 91c31f9899..19251af49e 100644 --- a/mlir/unittests/Dialect/QCO/IR/test_qco_ir_matrix.cpp +++ b/mlir/unittests/Dialect/QCO/IR/test_qco_ir_matrix.cpp @@ -52,8 +52,12 @@ namespace { struct QCOMatrixTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; }; class QCOMatrixTest : public testing::TestWithParam { @@ -74,7 +78,8 @@ class QCOMatrixTest : public testing::TestWithParam { /// \name QCO/Modifiers/CtrlOp.cpp /// @{ TEST_F(QCOMatrixTest, CXOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), singleControlledX); + auto moduleOp = + QCOProgramBuilder::buildWithReturn(context.get(), singleControlledX); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -97,7 +102,8 @@ TEST_F(QCOMatrixTest, CXOpMatrix) { /// \name QCO/Modifiers/InvOp.cpp /// @{ TEST_F(QCOMatrixTest, InverseIswapOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), inverseIswap); + auto moduleOp = + QCOProgramBuilder::buildWithReturn(context.get(), inverseIswap); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -150,7 +156,8 @@ TEST_F(QCOMatrixTest, ECROpMatrix) { /// \name QCO/Operations/StandardGates/GphaseOp.cpp /// @{ TEST_F(QCOMatrixTest, GPhaseOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), globalPhase); + auto moduleOp = + QCOProgramBuilder::buildWithReturn(context.get(), globalPhase); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -215,7 +222,7 @@ TEST_F(QCOMatrixTest, iSWAPOpMatrix) { /// \name QCO/Operations/StandardGates/POp.cpp /// @{ TEST_F(QCOMatrixTest, POpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), p); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), p); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -235,7 +242,7 @@ TEST_F(QCOMatrixTest, POpMatrix) { /// \name QCO/Operations/StandardGates/ROp.cpp /// @{ TEST_F(QCOMatrixTest, ROpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), r); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), r); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -255,7 +262,7 @@ TEST_F(QCOMatrixTest, ROpMatrix) { /// \name QCO/Operations/StandardGates/RxOp.cpp /// @{ TEST_F(QCOMatrixTest, RXOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), rx); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), rx); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -276,7 +283,7 @@ TEST_F(QCOMatrixTest, RXOpMatrix) { /// \name QCO/Operations/StandardGates/RxxOp.cpp /// @{ TEST_F(QCOMatrixTest, RXXOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), rxx); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), rxx); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -296,7 +303,7 @@ TEST_F(QCOMatrixTest, RXXOpMatrix) { /// \name QCO/Operations/StandardGates/RyOp.cpp /// @{ TEST_F(QCOMatrixTest, RYOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), ry); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), ry); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -317,7 +324,7 @@ TEST_F(QCOMatrixTest, RYOpMatrix) { /// \name QCO/Operations/StandardGates/RyyOp.cpp /// @{ TEST_F(QCOMatrixTest, RYYOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), ryy); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), ryy); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -337,7 +344,7 @@ TEST_F(QCOMatrixTest, RYYOpMatrix) { /// \name QCO/Operations/StandardGates/RzOp.cpp /// @{ TEST_F(QCOMatrixTest, RZOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), rz); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), rz); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -358,7 +365,7 @@ TEST_F(QCOMatrixTest, RZOpMatrix) { /// \name QCO/Operations/StandardGates/RzxOp.cpp /// @{ TEST_F(QCOMatrixTest, RZXOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), rzx); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), rzx); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -378,7 +385,7 @@ TEST_F(QCOMatrixTest, RZXOpMatrix) { /// \name QCO/Operations/StandardGates/RzzOp.cpp /// @{ TEST_F(QCOMatrixTest, RZZOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), rzz); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), rzz); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -503,7 +510,7 @@ TEST_F(QCOMatrixTest, TdgOpMatrix) { /// \name QCO/Operations/StandardGates/U2Op.cpp /// @{ TEST_F(QCOMatrixTest, U2OpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), u2); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), u2); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -524,7 +531,7 @@ TEST_F(QCOMatrixTest, U2OpMatrix) { /// \name QCO/Operations/StandardGates/UOp.cpp /// @{ TEST_F(QCOMatrixTest, UOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), u); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), u); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -560,7 +567,7 @@ TEST_F(QCOMatrixTest, XOpMatrix) { /// \name QCO/Operations/StandardGates/XxMinusYyOp.cpp /// @{ TEST_F(QCOMatrixTest, XXMinusYYOpMatrix) { - auto moduleOp = QCOProgramBuilder::build(context.get(), xxMinusYY); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), xxMinusYY); ASSERT_TRUE(moduleOp); // Get the operation from the module @@ -581,7 +588,7 @@ TEST_F(QCOMatrixTest, XXMinusYYOpMatrix) { /// \name QCO/Operations/StandardGates/XxPlusYyOp.cpp /// @{ TEST_F(QCOMatrixTest, XXPlusYYOp) { - auto moduleOp = QCOProgramBuilder::build(context.get(), xxPlusYY); + auto moduleOp = QCOProgramBuilder::buildWithReturn(context.get(), xxPlusYY); ASSERT_TRUE(moduleOp); // Get the operation from the module diff --git a/mlir/unittests/Dialect/QTensor/IR/test_qtensor_ir.cpp b/mlir/unittests/Dialect/QTensor/IR/test_qtensor_ir.cpp index a76e20cc1a..335a7ad448 100644 --- a/mlir/unittests/Dialect/QTensor/IR/test_qtensor_ir.cpp +++ b/mlir/unittests/Dialect/QTensor/IR/test_qtensor_ir.cpp @@ -416,8 +416,12 @@ TEST_F(QTensorTest, ResetAfterExtractThroughSameIndexInsertIsNotEliminated) { struct QTensorIntegrationTestCase { std::string name; - mqt::test::NamedBuilder programBuilder; - mqt::test::NamedBuilder referenceBuilder; + mqt::test::NamedBuilder, SmallVector>> + programBuilder; + mqt::test::NamedBuilder, SmallVector>> + referenceBuilder; friend std::ostream& operator<<(std::ostream& os, const QTensorIntegrationTestCase& info); diff --git a/mlir/unittests/TestCaseUtils.h b/mlir/unittests/TestCaseUtils.h index 570c86c87f..b876751074 100644 --- a/mlir/unittests/TestCaseUtils.h +++ b/mlir/unittests/TestCaseUtils.h @@ -26,11 +26,11 @@ namespace mqt::test { -template struct NamedBuilder { +template struct NamedBuilder { const char* name = nullptr; - void (*fn)(BuilderT&) = nullptr; + RetT (*fn)(BuilderT&) = nullptr; - constexpr NamedBuilder(const char* nameIn, void (*fnIn)(BuilderT&)) noexcept + constexpr NamedBuilder(const char* nameIn, RetT (*fnIn)(BuilderT&)) noexcept : name(nameIn), fn(fnIn) {} // NOLINTNEXTLINE(*-explicit-constructor) @@ -41,10 +41,10 @@ template struct NamedBuilder { } }; -template -[[nodiscard]] constexpr NamedBuilder -namedBuilder(const char* name, void (*fn)(BuilderT&)) noexcept { - return NamedBuilder{name, fn}; +template +[[nodiscard]] constexpr NamedBuilder +namedBuilder(const char* name, RetT (*fn)(BuilderT&)) noexcept { + return NamedBuilder{name, fn}; } [[nodiscard]] constexpr const char* displayName(const char* name) noexcept { diff --git a/mlir/unittests/programs/qc_programs.cpp b/mlir/unittests/programs/qc_programs.cpp index 8410afd7a8..c707a7ff00 100644 --- a/mlir/unittests/programs/qc_programs.cpp +++ b/mlir/unittests/programs/qc_programs.cpp @@ -12,22 +12,43 @@ #include "mlir/Dialect/QC/Builder/QCProgramBuilder.h" +#include +#include +#include +#include + #include +#include +#include + +static std::pair, mlir::SmallVector> +measureAndReturn(mlir::qc::QCProgramBuilder& b, + mlir::SmallVector qubits) { + mlir::SmallVector bits; + mlir::SmallVector bitTypes; + auto i1Type = b.getI1Type(); + for (const auto& q : qubits) { + bits.push_back(b.measure(q)); + bitTypes.push_back(i1Type); + } + return {bits, bitTypes}; +} namespace mlir::qc { -void emptyQC([[maybe_unused]] QCProgramBuilder& builder) {} - -void allocQubit(QCProgramBuilder& b) { b.allocQubit(); } - -void allocQubitRegister(QCProgramBuilder& b) { b.allocQubitRegister(2); } +std::pair, SmallVector> +emptyQC([[maybe_unused]] QCProgramBuilder& builder) { + return measureAndReturn(builder, {}); +} -void allocMultipleQubitRegisters(QCProgramBuilder& b) { - b.allocQubitRegister(2); - b.allocQubitRegister(3); +std::pair, SmallVector> +allocQubit(QCProgramBuilder& b) { + auto q = b.allocQubit(); + return measureAndReturn(b, {q}); } -void allocMultipleQubitRegistersWithOps(QCProgramBuilder& b) { +std::pair, SmallVector> +allocMultipleQubitRegistersWithOps(QCProgramBuilder& b) { auto q0 = b.allocQubitRegister(2); auto q1 = b.allocQubitRegister(3); b.h(q0[0]); @@ -35,47 +56,84 @@ void allocMultipleQubitRegistersWithOps(QCProgramBuilder& b) { b.h(q1[0]); b.h(q1[1]); b.h(q1[2]); + return measureAndReturn(b, {q0[0], q0[1], q1[0], q1[1], q1[2]}); } -void allocLargeRegister(QCProgramBuilder& b) { b.allocQubitRegister(100); } +std::pair, SmallVector> +alloc1QubitRegister(QCProgramBuilder& b) { + auto q = b.allocQubitRegister(1); + return measureAndReturn(b, {q[0]}); +} -void staticQubits(QCProgramBuilder& b) { - b.staticQubit(0); - b.staticQubit(1); +std::pair, SmallVector> +allocQubitRegister(QCProgramBuilder& b) { + auto q = b.allocQubitRegister(2); + return measureAndReturn(b, {q[0], q[1]}); } -void staticQubitsWithOps(QCProgramBuilder& b) { +std::pair, SmallVector> +allocMultipleQubitRegisters(QCProgramBuilder& b) { + auto q0 = b.allocQubitRegister(2); + auto q1 = b.allocQubitRegister(3); + return measureAndReturn(b, {q0[0], q0[1], q1[0], q1[1], q1[2]}); +} + +std::pair, SmallVector> +allocLargeRegister(QCProgramBuilder& b) { + auto q = b.allocQubitRegister(100); + return measureAndReturn(b, {q[0], q[99]}); +} + +std::pair, SmallVector> +staticQubits(QCProgramBuilder& b) { + auto q0 = b.staticQubit(0); + auto q1 = b.staticQubit(1); + return measureAndReturn(b, {q0, q1}); +} + +std::pair, SmallVector> +staticQubitsWithOps(QCProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.h(q0); b.h(q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithParametricOps(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithParametricOps(QCProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.rx(std::numbers::pi / 4., q0); b.p(std::numbers::pi / 2., q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithTwoTargetOps(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithTwoTargetOps(QCProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.rzz(0.123, q0, q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithCtrl(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithCtrl(QCProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.cx(q0, q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithInv(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithInv(QCProgramBuilder& b) { auto q0 = b.staticQubit(0); b.inv({q0}, [&](ValueRange qubits) { b.t(qubits[0]); }); + return measureAndReturn(b, {q0}); } -void staticQubitsWithDuplicates(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithDuplicates(QCProgramBuilder& b) { const auto q0a = b.staticQubit(0); const auto q1a = b.staticQubit(1); const auto q0b = b.staticQubit(0); @@ -86,9 +144,11 @@ void staticQubitsWithDuplicates(QCProgramBuilder& b) { b.rzz(0.123, q0b, q1b); b.cx(q0b, q1b); b.inv({q0a}, [&](ValueRange qubits) { b.t(qubits[0]); }); + return measureAndReturn(b, {q0b, q1b}); } -void staticQubitsCanonical(QCProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsCanonical(QCProgramBuilder& b) { const auto q0 = b.staticQubit(0); const auto q1 = b.staticQubit(1); @@ -97,1282 +157,1710 @@ void staticQubitsCanonical(QCProgramBuilder& b) { b.rzz(0.123, q0, q1); b.cx(q0, q1); b.inv({q0}, [&](ValueRange qubits) { b.t(qubits[0]); }); + return measureAndReturn(b, {q0, q1}); } -void allocDeallocPair(QCProgramBuilder& b) { +std::pair, SmallVector> +allocDeallocPair(QCProgramBuilder& b) { auto q = b.allocQubit(); b.dealloc(q); + return measureAndReturn(b, {}); } -void mixedStaticThenDynamicQubit(QCProgramBuilder& b) { - b.staticQubit(0); - b.allocQubit(); +std::pair, SmallVector> +mixedStaticThenDynamicQubit(QCProgramBuilder& b) { + auto q0 = b.staticQubit(0); + auto q1 = b.allocQubit(); + return measureAndReturn(b, {q0, q1}); } -void mixedDynamicRegisterThenStaticQubit(QCProgramBuilder& b) { - b.allocQubitRegister(2); - b.staticQubit(0); +std::pair, SmallVector> +mixedDynamicRegisterThenStaticQubit(QCProgramBuilder& b) { + auto q0 = b.allocQubitRegister(2); + auto q1 = b.staticQubit(0); + return measureAndReturn(b, {q0[0], q0[1], q1}); } -void singleMeasurementToSingleBit(QCProgramBuilder& b) { +std::pair, SmallVector> +singleMeasurementToSingleBit(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(1); - b.measure(q[0], c[0]); + const auto outcome = b.measure(q[0], c[0]); + return {{outcome}, {b.getI1Type()}}; } -void repeatedMeasurementToSameBit(QCProgramBuilder& b) { +std::pair, SmallVector> +repeatedMeasurementToSameBit(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(1); b.measure(q[0], c[0]); b.measure(q[0], c[0]); - b.measure(q[0], c[0]); + auto c3 = b.measure(q[0], c[0]); + return {{c3}, {b.getI1Type()}}; } -void repeatedMeasurementToDifferentBits(QCProgramBuilder& b) { +std::pair, SmallVector> +repeatedMeasurementToDifferentBits(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(3); - b.measure(q[0], c[0]); - b.measure(q[0], c[1]); - b.measure(q[0], c[2]); + auto c1 = b.measure(q[0], c[0]); + auto c2 = b.measure(q[0], c[1]); + auto c3 = b.measure(q[0], c[2]); + return {{c1, c2, c3}, {b.getI1Type(), b.getI1Type(), b.getI1Type()}}; } -void multipleClassicalRegistersAndMeasurements(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleClassicalRegistersAndMeasurements(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); const auto& c0 = b.allocClassicalBitRegister(1, "c0"); const auto& c1 = b.allocClassicalBitRegister(2, "c1"); - b.measure(q[0], c0[0]); - b.measure(q[1], c1[0]); - b.measure(q[2], c1[1]); + const auto b1 = b.measure(q[0], c0[0]); + const auto b2 = b.measure(q[1], c1[0]); + const auto b3 = b.measure(q[2], c1[1]); + return {{b1, b2, b3}, {b.getI1Type(), b.getI1Type(), b.getI1Type()}}; } -void measurementWithoutRegisters(QCProgramBuilder& b) { +std::pair, SmallVector> +measurementWithoutRegisters(QCProgramBuilder& b) { auto q = b.allocQubit(); - b.measure(q); + auto c = b.measure(q); + return {{c}, {b.getI1Type()}}; } -void resetQubitWithoutOp(QCProgramBuilder& b) { +std::pair, SmallVector> +resetQubitWithoutOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetMultipleQubitsWithoutOp(QCProgramBuilder& b) { +std::pair, SmallVector> +resetMultipleQubitsWithoutOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.reset(q[0]); b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetWithoutOp(QCProgramBuilder& b) { +std::pair, SmallVector> +repeatedResetWithoutOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.reset(q[0]); b.reset(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetQubitAfterSingleOp(QCProgramBuilder& b) { +std::pair, SmallVector> +resetQubitAfterSingleOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetMultipleQubitsAfterSingleOp(QCProgramBuilder& b) { +std::pair, SmallVector> +resetMultipleQubitsAfterSingleOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.h(q[0]); b.reset(q[0]); b.h(q[1]); b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetAfterSingleOp(QCProgramBuilder& b) { +std::pair, SmallVector> +repeatedResetAfterSingleOp(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); b.reset(q[0]); b.reset(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void globalPhase(QCProgramBuilder& b) { b.gphase(0.123); } +std::pair, SmallVector> +globalPhase(QCProgramBuilder& b) { + b.gphase(0.123); + return {{b.intConstant(0)}, {b.getI64Type()}}; +} -void singleControlledGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledGlobalPhase(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.cgphase(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void multipleControlledGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledGlobalPhase(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcgphase(0.123, {q[0], q[1], q[2]}); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledGlobalPhase(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ctrl(q[0], {q[1]}, [&](ValueRange targets) { b.cgphase(0.123, targets[0]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void trivialControlledGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledGlobalPhase(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcgphase(0.123, {}); + return measureAndReturn(b, {q[0]}); } -void inverseGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseGlobalPhase(QCProgramBuilder& b) { b.inv({}, [&](ValueRange /*qubits*/) { b.gphase(-0.123); }); + return measureAndReturn(b, {}); } -void inverseMultipleControlledGlobalPhase(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledGlobalPhase(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcgphase(-0.123, qubits); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void identity(QCProgramBuilder& b) { +std::pair, SmallVector> identity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.id(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cid(q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcid({q[2], q[1]}, q[0]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ctrl(q[2], {q[0], q[1]}, [&](ValueRange targets) { b.cid(targets[1], targets[0]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void trivialControlledIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcid({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.id(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledIdentity(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledIdentity(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcid({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void x(QCProgramBuilder& b) { +std::pair, SmallVector> x(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.x(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledX(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledX(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledX(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledX(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcx({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledX(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledX(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cx(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledX(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledX(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcx({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void repeatedControlledX(QCProgramBuilder& b) { - auto q = b.allocQubitRegister(64); - b.h(q[0]); - for (auto i = 1; i < 64; i++) { - b.cx(q[0], q[i]); +std::pair, SmallVector> +repeatedControlledX(QCProgramBuilder& b) { + auto control = b.allocQubit(); + b.h(control); + mlir::SmallVector qubits = {control}; + for (auto i = 0; i < 50; i++) { + auto qubit = b.allocQubit(); + b.cx(control, qubit); + qubits.push_back(qubit); } + return measureAndReturn(b, qubits); } -void inverseX(QCProgramBuilder& b) { +std::pair, SmallVector> inverseX(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.x(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledX(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledX(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcx({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void y(QCProgramBuilder& b) { +std::pair, SmallVector> y(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.y(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledY(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cy(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledY(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcy({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledY(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledY(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cy(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledY(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcy({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseY(QCProgramBuilder& b) { +std::pair, SmallVector> inverseY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.y(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledY(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcy({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void z(QCProgramBuilder& b) { +std::pair, SmallVector> z(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.z(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledZ(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledZ(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cz(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledZ(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledZ(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcz({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledZ(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledZ(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cz(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledZ(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledZ(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcz({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseZ(QCProgramBuilder& b) { +std::pair, SmallVector> inverseZ(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.z(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledZ(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledZ(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcz({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void h(QCProgramBuilder& b) { +std::pair, SmallVector> h(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledH(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledH(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ch(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledH(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledH(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mch({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledH(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledH(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.ch(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledH(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledH(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mch({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseH(QCProgramBuilder& b) { +std::pair, SmallVector> inverseH(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.h(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledH(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledH(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mch({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void hWithoutRegister(QCProgramBuilder& b) { +std::pair, SmallVector> +hWithoutRegister(QCProgramBuilder& b) { auto q = b.allocQubit(); b.h(q); + return measureAndReturn(b, {q}); } -void s(QCProgramBuilder& b) { +std::pair, SmallVector> s(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.s(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledS(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledS(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cs(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledS(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledS(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcs({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledS(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledS(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cs(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledS(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledS(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcs({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseS(QCProgramBuilder& b) { +std::pair, SmallVector> inverseS(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.s(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledS(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledS(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcs({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sdg(QCProgramBuilder& b) { +std::pair, SmallVector> sdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSdg(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.csdg(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcsdg({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseSdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.sdg(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcsdg({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void t_(QCProgramBuilder& b) { +std::pair, SmallVector> t_(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.t(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledT(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledT(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ct(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledT(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledT(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mct({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledT(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledT(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.ct(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledT(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledT(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mct({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseT(QCProgramBuilder& b) { +std::pair, SmallVector> inverseT(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.t(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledT(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledT(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mct({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void tdg(QCProgramBuilder& b) { +std::pair, SmallVector> tdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.tdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledTdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ctdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledTdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mctdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledTdg(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.ctdg(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledTdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mctdg({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseTdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.tdg(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledTdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledTdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mctdg({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sx(QCProgramBuilder& b) { +std::pair, SmallVector> sx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sx(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSx(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSx(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsx({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSx(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSx(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.csx(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSx(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcsx({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseSx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseSx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.sx(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcsx({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sxdg(QCProgramBuilder& b) { +std::pair, SmallVector> sxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sxdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csxdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsxdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSxdg(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.csxdg(targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcsxdg({}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseSxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.sxdg(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSxdg(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSxdg(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcsxdg({qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void rx(QCProgramBuilder& b) { +std::pair, SmallVector> rx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.rx(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRx(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.crx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRx(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcrx(0.123, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRx(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRx(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.crx(0.123, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRx(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcrx(0.123, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseRx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.rx(-0.123, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcrx(-0.123, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void ry(QCProgramBuilder& b) { +std::pair, SmallVector> ry(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.ry(0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRy(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cry(0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRy(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcry(0.456, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRy(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRy(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cry(0.456, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRy(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcry(0.456, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseRy(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.ry(-0.456, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRy(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcry(-0.456, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void rz(QCProgramBuilder& b) { +std::pair, SmallVector> rz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.rz(0.789, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRz(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.crz(0.789, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRz(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcrz(0.789, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRz(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRz(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.crz(0.789, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRz(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcrz(0.789, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseRz(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.rz(-0.789, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRz(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcrz(-0.789, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void p(QCProgramBuilder& b) { +std::pair, SmallVector> p(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.p(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledP(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledP(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cp(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledP(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledP(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcp(0.123, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledP(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledP(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cp(0.123, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledP(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledP(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcp(0.123, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseP(QCProgramBuilder& b) { +std::pair, SmallVector> inverseP(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.p(-0.123, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledP(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledP(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcp(-0.123, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void r(QCProgramBuilder& b) { +std::pair, SmallVector> r(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.r(0.123, 0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledR(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledR(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cr(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledR(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledR(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcr(0.123, 0.456, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledR(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledR(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cr(0.123, 0.456, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledR(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledR(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcr(0.123, 0.456, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseR(QCProgramBuilder& b) { +std::pair, SmallVector> inverseR(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.r(-0.123, 0.456, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledR(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledR(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcr(-0.123, 0.456, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void u2(QCProgramBuilder& b) { +std::pair, SmallVector> u2(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.u2(0.234, 0.567, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU2(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledU2(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cu2(0.234, 0.567, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU2(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledU2(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcu2(0.234, 0.567, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledU2(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledU2(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cu2(0.234, 0.567, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledU2(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledU2(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcu2(0.234, 0.567, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseU2(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseU2(QCProgramBuilder& b) { constexpr double pi = std::numbers::pi; auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.u2(-0.567 + pi, -0.234 - pi, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledU2(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledU2(QCProgramBuilder& b) { constexpr double pi = std::numbers::pi; auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcu2(-0.567 + pi, -0.234 - pi, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void u(QCProgramBuilder& b) { +std::pair, SmallVector> u(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.u(0.1, 0.2, 0.3, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledU(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cu(0.1, 0.2, 0.3, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledU(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcu(0.1, 0.2, 0.3, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledU(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledU(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); b.ctrl(reg[0], {reg[1], reg[2]}, [&](ValueRange targets) { b.cu(0.1, 0.2, 0.3, targets[0], targets[1]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledU(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledU(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.mcu(0.1, 0.2, 0.3, {}, q[0]); + return measureAndReturn(b, {q[0]}); } -void inverseU(QCProgramBuilder& b) { +std::pair, SmallVector> inverseU(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.u(-0.1, -0.3, -0.2, qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledU(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledU(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.mcu(-0.1, -0.3, -0.2, {qubits[0], qubits[1]}, qubits[2]); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void swap(QCProgramBuilder& b) { +std::pair, SmallVector> swap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.swap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSwap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cswap(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSwap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcswap({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSwap(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cswap(targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSwap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcswap({}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseSwap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.swap(qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledSwap(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSwap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcswap({qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void iswap(QCProgramBuilder& b) { +std::pair, SmallVector> iswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.iswap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledIswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ciswap(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledIswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mciswap({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledIswap(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.ciswap(targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledIswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mciswap({}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseIswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.iswap(qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledIswap(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledIswap(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mciswap({qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void dcx(QCProgramBuilder& b) { +std::pair, SmallVector> dcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.dcx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledDcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cdcx(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledDcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcdcx({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledDcx(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cdcx(targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledDcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcdcx({}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseDcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.dcx(qubits[1], qubits[0]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledDcx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledDcx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[3], q[2]}, [&](ValueRange qubits) { b.mcdcx({qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ecr(QCProgramBuilder& b) { +std::pair, SmallVector> ecr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ecr(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledEcr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cecr(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledEcr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcecr({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledEcr(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cecr(targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledEcr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcecr({}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseEcr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.ecr(qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledEcr(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledEcr(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcecr({qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rxx(QCProgramBuilder& b) { +std::pair, SmallVector> rxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rxx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crxx(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrxx(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRxx(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.crxx(0.123, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcrxx(0.123, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.rxx(-0.123, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcrxx(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void tripleControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +tripleControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(5); b.mcrxx(0.123, {q[0], q[1], q[2]}, q[3], q[4]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4]}); } -void fourControlledRxx(QCProgramBuilder& b) { +std::pair, SmallVector> +fourControlledRxx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(6); b.mcrxx(0.123, {q[0], q[1], q[2], q[3]}, q[4], q[5]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4], q[5]}); } -void ryy(QCProgramBuilder& b) { +std::pair, SmallVector> ryy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ryy(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRyy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cryy(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRyy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcryy(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRyy(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cryy(0.123, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRyy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcryy(0.123, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRyy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.ryy(-0.123, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRyy(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRyy(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcryy(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rzx(QCProgramBuilder& b) { +std::pair, SmallVector> rzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rzx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crzx(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrzx(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRzx(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.crzx(0.123, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcrzx(0.123, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.rzx(-0.123, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRzx(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRzx(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcrzx(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rzz(QCProgramBuilder& b) { +std::pair, SmallVector> rzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rzz(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crzz(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrzz(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRzz(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.crzz(0.123, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcrzz(0.123, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseRzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.rzz(-0.123, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRzz(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRzz(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcrzz(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void xxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> xxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.xx_plus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledXxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cxx_plus_yy(0.123, 0.456, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledXxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcxx_plus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledXxPlusYY(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cxx_plus_yy(0.123, 0.456, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledXxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcxx_plus_yy(0.123, 0.456, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseXxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.xx_plus_yy(-0.123, 0.456, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledXxPlusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledXxPlusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcxx_plus_yy(-0.123, 0.456, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void xxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +xxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.xx_minus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledXxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cxx_minus_yy(0.123, 0.456, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledXxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcxx_minus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledXxMinusYY(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.ctrl(reg[0], {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { b.cxx_minus_yy(0.123, 0.456, targets[0], targets[1], targets[2]); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledXxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.mcxx_minus_yy(0.123, 0.456, {}, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseXxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.xx_minus_yy(-0.123, 0.456, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledXxMinusYY(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledXxMinusYY(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { b.mcxx_minus_yy(-0.123, 0.456, {qubits[0], qubits[1]}, qubits[2], qubits[3]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void barrier(QCProgramBuilder& b) { +std::pair, SmallVector> barrier(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.barrier(q[0]); + return measureAndReturn(b, {q[0]}); } -void barrierTwoQubits(QCProgramBuilder& b) { +std::pair, SmallVector> +barrierTwoQubits(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.barrier({q[0], q[1]}); + return measureAndReturn(b, {q[0], q[1]}); } -void barrierMultipleQubits(QCProgramBuilder& b) { +std::pair, SmallVector> +barrierMultipleQubits(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.barrier({q[0], q[1], q[2]}); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void singleControlledBarrier(QCProgramBuilder& b) { +std::pair, SmallVector> +singleControlledBarrier(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ctrl(q[1], q[0], [&](ValueRange targets) { b.barrier(targets[0]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseBarrier(QCProgramBuilder& b) { +std::pair, SmallVector> +inverseBarrier(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { b.barrier(qubits[0]); }); + return measureAndReturn(b, {q[0]}); } -void trivialCtrl(QCProgramBuilder& b) { +std::pair, SmallVector> +trivialCtrl(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ctrl({}, {q[0], q[1]}, [&](ValueRange targets) { b.rxx(0.123, targets[0], targets[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void emptyCtrl(QCProgramBuilder& b) { +std::pair, SmallVector> +emptyCtrl(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rxx(0.123, q[0], q[1]); b.ctrl({q[0]}, {q[1]}, [&](ValueRange /*targets*/) {}); + return measureAndReturn(b, {q[0], q[1]}); } -void nestedCtrl(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedCtrl(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl(q[0], {q[1], q[2], q[3]}, [&](ValueRange targets) { b.ctrl(targets[0], {targets[1], targets[2]}, [&](ValueRange innerTargets) { b.rxx(0.123, innerTargets[0], innerTargets[1]); }); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void tripleNestedCtrl(QCProgramBuilder& b) { +std::pair, SmallVector> +tripleNestedCtrl(QCProgramBuilder& b) { auto q = b.allocQubitRegister(5); b.ctrl(q[0], {q[1], q[2], q[3], q[4]}, [&](ValueRange targets) { b.ctrl(targets[0], {targets[1], targets[2], targets[3]}, @@ -1383,9 +1871,11 @@ void tripleNestedCtrl(QCProgramBuilder& b) { }); }); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4]}); } -void doubleNestedCtrlTwoQubits(QCProgramBuilder& b) { +std::pair, SmallVector> +doubleNestedCtrlTwoQubits(QCProgramBuilder& b) { auto q = b.allocQubitRegister(6); b.ctrl({q[0], q[1]}, {q[2], q[3], q[4], q[5]}, [&](ValueRange targets) { b.ctrl({targets[0], targets[1]}, {targets[2], targets[3]}, @@ -1393,9 +1883,11 @@ void doubleNestedCtrlTwoQubits(QCProgramBuilder& b) { b.rxx(0.123, innerTargets[0], innerTargets[1]); }); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4], q[5]}); } -void ctrlInvSandwich(QCProgramBuilder& b) { +std::pair, SmallVector> +ctrlInvSandwich(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl(q[0], {q[1], q[2], q[3]}, [&](ValueRange targets) { b.inv(targets, [&](ValueRange qubits) { @@ -1404,25 +1896,30 @@ void ctrlInvSandwich(QCProgramBuilder& b) { }); }); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlTwo(QCProgramBuilder& b) { +std::pair, SmallVector> ctrlTwo(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl({q[0], q[1]}, {q[2], q[3]}, [&](ValueRange targets) { b.x(targets[0]); b.rxx(0.123, targets[0], targets[1]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlTwoMixed(QCProgramBuilder& b) { +std::pair, SmallVector> +ctrlTwoMixed(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl({q[0], q[1]}, {q[2], q[3]}, [&](ValueRange targets) { b.cx(targets[0], targets[1]); b.rxx(0.123, targets[0], targets[1]); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedCtrlTwo(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedCtrlTwo(QCProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl(q[0], {q[1], q[2], q[3]}, [&](ValueRange targets) { b.ctrl(targets[0], {targets[1], targets[2]}, [&](ValueRange innerTargets) { @@ -1430,9 +1927,11 @@ void nestedCtrlTwo(QCProgramBuilder& b) { b.rxx(0.123, innerTargets[0], innerTargets[1]); }); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlInvTwo(QCProgramBuilder& b) { +std::pair, SmallVector> +ctrlInvTwo(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ctrl(q[0], {q[1], q[2]}, [&](ValueRange targets) { b.inv(targets, [&](ValueRange qubits) { @@ -1440,24 +1939,29 @@ void ctrlInvTwo(QCProgramBuilder& b) { b.rxx(0.123, qubits[0], qubits[1]); }); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void emptyInv(QCProgramBuilder& b) { +std::pair, SmallVector> emptyInv(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rxx(0.123, q[0], q[1]); b.inv({q[0], q[1]}, [&](ValueRange /*targets*/) {}); + return measureAndReturn(b, {q[0], q[1]}); } -void nestedInv(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedInv(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.inv(qubits, [&](ValueRange innerQubits) { b.rxx(0.123, innerQubits[0], innerQubits[1]); }); }); + return measureAndReturn(b, {q[0], q[1]}); } -void tripleNestedInv(QCProgramBuilder& b) { +std::pair, SmallVector> +tripleNestedInv(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.inv(qubits, [&](ValueRange innerQubits) { @@ -1466,9 +1970,11 @@ void tripleNestedInv(QCProgramBuilder& b) { }); }); }); + return measureAndReturn(b, {q[0], q[1]}); } -void invCtrlSandwich(QCProgramBuilder& b) { +std::pair, SmallVector> +invCtrlSandwich(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.ctrl(qubits[0], {qubits[1], qubits[2]}, [&](ValueRange targets) { @@ -1479,15 +1985,17 @@ void invCtrlSandwich(QCProgramBuilder& b) { }); } -void invTwo(QCProgramBuilder& b) { +std::pair, SmallVector> invTwo(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { b.x(qubits[0]); b.rxx(0.123, qubits[0], qubits[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void invCtrlTwo(QCProgramBuilder& b) { +std::pair, SmallVector> +invCtrlTwo(QCProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { b.ctrl(qubits[0], {qubits[1], qubits[2]}, [&](ValueRange targets) { @@ -1495,16 +2003,27 @@ void invCtrlTwo(QCProgramBuilder& b) { b.rxx(0.123, targets[0], targets[1]); }); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void simpleIf(QCProgramBuilder& b) { +std::pair, SmallVector> simpleIf(QCProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); auto cond = b.measure(q[0]); b.scfIf(cond, [&] { b.x(q[0]); }); + return measureAndReturn(b, {q[0]}); +} + +std::pair, SmallVector> ifElse(QCProgramBuilder& b) { + auto q = b.allocQubitRegister(1); + b.h(q[0]); + auto cond = b.measure(q[0]); + b.scfIf(cond, [&] { b.x(q[0]); }, [&] { b.z(q[0]); }); + return measureAndReturn(b, {q[0]}); } -void ifTwoQubits(QCProgramBuilder& b) { +std::pair, SmallVector> +ifTwoQubits(QCProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.h(q[0]); auto cond = b.measure(q[0]); @@ -1512,16 +2031,11 @@ void ifTwoQubits(QCProgramBuilder& b) { b.x(q[0]); b.x(q[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void ifElse(QCProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - b.h(q[0]); - auto cond = b.measure(q[0]); - b.scfIf(cond, [&] { b.x(q[0]); }, [&] { b.z(q[0]); }); -} - -void nestedIfOpForLoop(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedIfOpForLoop(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto q0 = b.allocQubit(); b.h(q0); @@ -1534,9 +2048,11 @@ void nestedIfOpForLoop(QCProgramBuilder& b) { b.h(q1); }); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], q0}); } -void simpleWhileReset(QCProgramBuilder& b) { +std::pair, SmallVector> +simpleWhileReset(QCProgramBuilder& b) { auto q = b.allocQubit(); b.h(q); b.scfWhile( @@ -1545,9 +2061,11 @@ void simpleWhileReset(QCProgramBuilder& b) { b.scfCondition(measureResult); }, [&] { b.h(q); }); + return measureAndReturn(b, {q}); } -void simpleDoWhileReset(QCProgramBuilder& b) { +std::pair, SmallVector> +simpleDoWhileReset(QCProgramBuilder& b) { auto q = b.allocQubit(); b.scfWhile( [&] { @@ -1556,17 +2074,21 @@ void simpleDoWhileReset(QCProgramBuilder& b) { b.scfCondition(measureResult); }, [&] {}); + return measureAndReturn(b, {q}); } -void simpleForLoop(QCProgramBuilder& b) { +std::pair, SmallVector> +simpleForLoop(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(2); b.scfFor(0, 2, 1, [&](Value iv) { auto q = b.memrefLoad(reg.value, iv); b.h(q); }); + return measureAndReturn(b, {reg[0], reg[1]}); }; -void nestedForLoopIfOp(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopIfOp(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(2); auto qCond = b.allocQubit(); b.scfFor(0, 2, 1, [&](Value iv) { @@ -1577,9 +2099,11 @@ void nestedForLoopIfOp(QCProgramBuilder& b) { b.h(q); }); }); + return measureAndReturn(b, {reg[0], reg[1], qCond}); } -void nestedForLoopWhileOp(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopWhileOp(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(2); b.scfFor(0, 2, 1, [&](Value iv) { auto q = b.memrefLoad(reg.value, iv); @@ -1594,9 +2118,11 @@ void nestedForLoopWhileOp(QCProgramBuilder& b) { }, [&] { b.h(q); }); }); + return measureAndReturn(b, {reg[0], reg[1]}); } -void nestedForLoopCtrlOpWithSeparateQubit(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopCtrlOpWithSeparateQubit(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto control = b.allocQubit(); b.h(control); @@ -1605,9 +2131,11 @@ void nestedForLoopCtrlOpWithSeparateQubit(QCProgramBuilder& b) { b.h(q0); b.cx(control, q0); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], control}); } -void nestedForLoopCtrlOpWithExtractedQubit(QCProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopCtrlOpWithExtractedQubit(QCProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.h(reg[0]); b.scfFor(1, 4, 1, [&](Value iv) { @@ -1615,6 +2143,7 @@ void nestedForLoopCtrlOpWithExtractedQubit(QCProgramBuilder& b) { b.h(q0); b.cx(reg[0], q0); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } } // namespace mlir::qc diff --git a/mlir/unittests/programs/qc_programs.h b/mlir/unittests/programs/qc_programs.h index 25d76718cc..eee8754ce2 100644 --- a/mlir/unittests/programs/qc_programs.h +++ b/mlir/unittests/programs/qc_programs.h @@ -10,906 +10,1133 @@ #pragma once +#include +#include + +#include + namespace mlir::qc { class QCProgramBuilder; /// Creates an empty QC Program. -void emptyQC(QCProgramBuilder& builder); +std::pair, SmallVector> +emptyQC(QCProgramBuilder& builder); // --- Qubit Management ----------------------------------------------------- // /// Allocates a single qubit. -void allocQubit(QCProgramBuilder& b); +std::pair, SmallVector> +allocQubit(QCProgramBuilder& b); + +/// Allocates a qubit register of size `1`. +std::pair, SmallVector> +alloc1QubitRegister(QCProgramBuilder& b); /// Allocates a qubit register of size `2`. -void allocQubitRegister(QCProgramBuilder& b); +std::pair, SmallVector> +allocQubitRegister(QCProgramBuilder& b); /// Allocates two qubit registers of size `2` and `3`. -void allocMultipleQubitRegisters(QCProgramBuilder& b); +std::pair, SmallVector> +allocMultipleQubitRegisters(QCProgramBuilder& b); /// Allocates two qubit registers of size `2` and `3` and applies operations. -void allocMultipleQubitRegistersWithOps(QCProgramBuilder& b); +std::pair, SmallVector> +allocMultipleQubitRegistersWithOps(QCProgramBuilder& b); /// Allocates a large qubit register. -void allocLargeRegister(QCProgramBuilder& b); +std::pair, SmallVector> +allocLargeRegister(QCProgramBuilder& b); /// Allocates two inline qubits. -void staticQubits(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubits(QCProgramBuilder& b); /// Allocates two static qubits and applies operations. -void staticQubitsWithOps(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithOps(QCProgramBuilder& b); /// Allocates two static qubits and applies parametric gates. -void staticQubitsWithParametricOps(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithParametricOps(QCProgramBuilder& b); /// Allocates two static qubits and applies a two-target gate. -void staticQubitsWithTwoTargetOps(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithTwoTargetOps(QCProgramBuilder& b); /// Allocates two static qubits and applies a controlled gate. -void staticQubitsWithCtrl(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithCtrl(QCProgramBuilder& b); /// Allocates a static qubit and applies an inverse modifier. -void staticQubitsWithInv(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithInv(QCProgramBuilder& b); /// Allocates duplicate static qubits and applies operations on both. -void staticQubitsWithDuplicates(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithDuplicates(QCProgramBuilder& b); /// Same as `staticQubitsWithDuplicates`, but with canonical static qubit /// retrievals. -void staticQubitsCanonical(QCProgramBuilder& b); +std::pair, SmallVector> +staticQubitsCanonical(QCProgramBuilder& b); /// Allocates and explicitly deallocates a single qubit. -void allocDeallocPair(QCProgramBuilder& b); +std::pair, SmallVector> +allocDeallocPair(QCProgramBuilder& b); // --- Invalid / mixed addressing (unit tests) -------------------------------- /// @pre `builder.initialize()`. Fatal mixed addressing: static then dynamic /// alloc. -void mixedStaticThenDynamicQubit(QCProgramBuilder& b); +std::pair, SmallVector> +mixedStaticThenDynamicQubit(QCProgramBuilder& b); /// @pre `builder.initialize()`. Fatal mixed addressing: dynamic register then /// static. -void mixedDynamicRegisterThenStaticQubit(QCProgramBuilder& b); +std::pair, SmallVector> +mixedDynamicRegisterThenStaticQubit(QCProgramBuilder& b); // --- MeasureOp ------------------------------------------------------------ // /// Measures a single qubit into a single classical bit. -void singleMeasurementToSingleBit(QCProgramBuilder& b); +std::pair, SmallVector> +singleMeasurementToSingleBit(QCProgramBuilder& b); /// Repeatedly measures a single qubit into the same classical bit. -void repeatedMeasurementToSameBit(QCProgramBuilder& b); +std::pair, SmallVector> +repeatedMeasurementToSameBit(QCProgramBuilder& b); /// Repeatedly measures a single qubit into different classical bits. -void repeatedMeasurementToDifferentBits(QCProgramBuilder& b); +std::pair, SmallVector> +repeatedMeasurementToDifferentBits(QCProgramBuilder& b); /// Measures multiple qubits into multiple classical bits. -void multipleClassicalRegistersAndMeasurements(QCProgramBuilder& b); +std::pair, SmallVector> +multipleClassicalRegistersAndMeasurements(QCProgramBuilder& b); /// Measures a single qubit into a single classical bit, without explicitly /// allocating a quantum or classical register. -void measurementWithoutRegisters(QCProgramBuilder& b); +std::pair, SmallVector> +measurementWithoutRegisters(QCProgramBuilder& b); // --- ResetOp -------------------------------------------------------------- // /// Resets a single qubit without any operations being applied. -void resetQubitWithoutOp(QCProgramBuilder& b); +std::pair, SmallVector> +resetQubitWithoutOp(QCProgramBuilder& b); /// Resets multiple qubits without any operations being applied. -void resetMultipleQubitsWithoutOp(QCProgramBuilder& b); +std::pair, SmallVector> +resetMultipleQubitsWithoutOp(QCProgramBuilder& b); /// Repeatedly resets a single qubit without any operations being applied. -void repeatedResetWithoutOp(QCProgramBuilder& b); +std::pair, SmallVector> +repeatedResetWithoutOp(QCProgramBuilder& b); /// Resets a single qubit after a single operation. -void resetQubitAfterSingleOp(QCProgramBuilder& b); +std::pair, SmallVector> +resetQubitAfterSingleOp(QCProgramBuilder& b); /// Resets multiple qubits after a single operation. -void resetMultipleQubitsAfterSingleOp(QCProgramBuilder& b); +std::pair, SmallVector> +resetMultipleQubitsAfterSingleOp(QCProgramBuilder& b); /// Repeatedly resets a single qubit after a single operation. -void repeatedResetAfterSingleOp(QCProgramBuilder& b); +std::pair, SmallVector> +repeatedResetAfterSingleOp(QCProgramBuilder& b); // --- GPhaseOp ------------------------------------------------------------- // /// Creates a circuit with just a global phase. -void globalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +globalPhase(QCProgramBuilder& b); /// Creates a controlled global phase gate with a single control qubit. -void singleControlledGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledGlobalPhase(QCProgramBuilder& b); /// Creates a multi-controlled global phase gate with multiple control qubits. -void multipleControlledGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledGlobalPhase(QCProgramBuilder& b); /// Creates a circuit with a nested controlled global phase gate. -void nestedControlledGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledGlobalPhase(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled global phase gate. -void trivialControlledGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledGlobalPhase(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a global phase gate. -void inverseGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +inverseGlobalPhase(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled global /// phase gate. -void inverseMultipleControlledGlobalPhase(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledGlobalPhase(QCProgramBuilder& b); // --- IdOp ----------------------------------------------------------------- // /// Creates a circuit with just an identity gate. -void identity(QCProgramBuilder& b); +std::pair, SmallVector> identity(QCProgramBuilder& b); /// Creates a controlled identity gate with a single control qubit. -void singleControlledIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledIdentity(QCProgramBuilder& b); /// Creates a multi-controlled identity gate with multiple control qubits. -void multipleControlledIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledIdentity(QCProgramBuilder& b); /// Creates a circuit with a nested controlled identity gate. -void nestedControlledIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledIdentity(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled identity gate. -void trivialControlledIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledIdentity(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an identity gate. -void inverseIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +inverseIdentity(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled identity /// gate. -void inverseMultipleControlledIdentity(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledIdentity(QCProgramBuilder& b); // --- XOp ------------------------------------------------------------------ // /// Creates a circuit with just an X gate. -void x(QCProgramBuilder& b); +std::pair, SmallVector> x(QCProgramBuilder& b); /// Creates a circuit with a single controlled X gate. -void singleControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledX(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled X gate. -void multipleControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledX(QCProgramBuilder& b); /// Creates a circuit with a nested controlled X gate. -void nestedControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledX(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled X gate. -void trivialControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledX(QCProgramBuilder& b); /// Creates a circuit with repeated controlled X gates. -void repeatedControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +repeatedControlledX(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an X gate. -void inverseX(QCProgramBuilder& b); +std::pair, SmallVector> inverseX(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled X gate. -void inverseMultipleControlledX(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledX(QCProgramBuilder& b); // --- YOp ------------------------------------------------------------------ // /// Creates a circuit with just a Y gate. -void y(QCProgramBuilder& b); +std::pair, SmallVector> y(QCProgramBuilder& b); /// Creates a circuit with a single controlled Y gate. -void singleControlledY(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledY(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled Y gate. -void multipleControlledY(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledY(QCProgramBuilder& b); /// Creates a circuit with a nested controlled Y gate. -void nestedControlledY(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledY(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled Y gate. -void trivialControlledY(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Y gate. -void inverseY(QCProgramBuilder& b); +std::pair, SmallVector> inverseY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Y gate. -void inverseMultipleControlledY(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledY(QCProgramBuilder& b); // --- ZOp ------------------------------------------------------------------ // /// Creates a circuit with just a Z gate. -void z(QCProgramBuilder& b); +std::pair, SmallVector> z(QCProgramBuilder& b); /// Creates a circuit with a single controlled Z gate. -void singleControlledZ(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledZ(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled Z gate. -void multipleControlledZ(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledZ(QCProgramBuilder& b); /// Creates a circuit with a nested controlled Z gate. -void nestedControlledZ(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledZ(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled Z gate. -void trivialControlledZ(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledZ(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Z gate. -void inverseZ(QCProgramBuilder& b); +std::pair, SmallVector> inverseZ(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Z gate. -void inverseMultipleControlledZ(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledZ(QCProgramBuilder& b); // --- HOp ------------------------------------------------------------------ // /// Creates a circuit with just an H gate. -void h(QCProgramBuilder& b); +std::pair, SmallVector> h(QCProgramBuilder& b); /// Creates a circuit with a single controlled H gate. -void singleControlledH(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledH(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled H gate. -void multipleControlledH(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledH(QCProgramBuilder& b); /// Creates a circuit with a nested controlled H gate. -void nestedControlledH(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledH(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled H gate. -void trivialControlledH(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledH(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an H gate. -void inverseH(QCProgramBuilder& b); +std::pair, SmallVector> inverseH(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled H gate. -void inverseMultipleControlledH(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledH(QCProgramBuilder& b); /// Creates a circuit with just an H gate and no qubit register. -void hWithoutRegister(QCProgramBuilder& b); +std::pair, SmallVector> +hWithoutRegister(QCProgramBuilder& b); // --- SOp ------------------------------------------------------------------ // /// Creates a circuit with just an S gate. -void s(QCProgramBuilder& b); +std::pair, SmallVector> s(QCProgramBuilder& b); /// Creates a circuit with a single controlled S gate. -void singleControlledS(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledS(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled S gate. -void multipleControlledS(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledS(QCProgramBuilder& b); /// Creates a circuit with a nested controlled S gate. -void nestedControlledS(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledS(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled S gate. -void trivialControlledS(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledS(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an S gate. -void inverseS(QCProgramBuilder& b); +std::pair, SmallVector> inverseS(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled S gate. -void inverseMultipleControlledS(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledS(QCProgramBuilder& b); // --- SdgOp ---------------------------------------------------------------- // /// Creates a circuit with just an Sdg gate. -void sdg(QCProgramBuilder& b); +std::pair, SmallVector> sdg(QCProgramBuilder& b); /// Creates a circuit with a single controlled Sdg gate. -void singleControlledSdg(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledSdg(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled Sdg gate. -void multipleControlledSdg(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSdg(QCProgramBuilder& b); /// Creates a circuit with a nested controlled Sdg gate. -void nestedControlledSdg(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSdg(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled Sdg gate. -void trivialControlledSdg(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an Sdg gate. -void inverseSdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseSdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Sdg gate. -void inverseMultipleControlledSdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSdg(QCProgramBuilder& b); // --- TOp ------------------------------------------------------------------ // /// Creates a circuit with just a T gate. -void t_(QCProgramBuilder& b); // NOLINT(*-identifier-naming) +std::pair, SmallVector> +t_(QCProgramBuilder& b); // NOLINT(*-identifier-naming) /// Creates a circuit with a single controlled T gate. -void singleControlledT(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledT(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled T gate. -void multipleControlledT(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledT(QCProgramBuilder& b); /// Creates a circuit with a nested controlled T gate. -void nestedControlledT(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledT(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled T gate. -void trivialControlledT(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledT(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a T gate. -void inverseT(QCProgramBuilder& b); +std::pair, SmallVector> inverseT(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled T gate. -void inverseMultipleControlledT(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledT(QCProgramBuilder& b); // --- TdgOp ---------------------------------------------------------------- // /// Creates a circuit with just a Tdg gate. -void tdg(QCProgramBuilder& b); +std::pair, SmallVector> tdg(QCProgramBuilder& b); /// Creates a circuit with a single controlled Tdg gate. -void singleControlledTdg(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledTdg(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled Tdg gate. -void multipleControlledTdg(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledTdg(QCProgramBuilder& b); /// Creates a circuit with a nested controlled Tdg gate. -void nestedControlledTdg(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledTdg(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled Tdg gate. -void trivialControlledTdg(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledTdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Tdg gate. -void inverseTdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseTdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Tdg gate. -void inverseMultipleControlledTdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledTdg(QCProgramBuilder& b); // --- SXOp ----------------------------------------------------------------- // /// Creates a circuit with just an SX gate. -void sx(QCProgramBuilder& b); +std::pair, SmallVector> sx(QCProgramBuilder& b); /// Creates a circuit with a single controlled SX gate. -void singleControlledSx(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledSx(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled SX gate. -void multipleControlledSx(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSx(QCProgramBuilder& b); /// Creates a circuit with a nested controlled SX gate. -void nestedControlledSx(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSx(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled SX gate. -void trivialControlledSx(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an SX gate. -void inverseSx(QCProgramBuilder& b); +std::pair, SmallVector> inverseSx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SX gate. -void inverseMultipleControlledSx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSx(QCProgramBuilder& b); // --- SXdgOp --------------------------------------------------------------- // /// Creates a circuit with just an SXdg gate. -void sxdg(QCProgramBuilder& b); +std::pair, SmallVector> sxdg(QCProgramBuilder& b); /// Creates a circuit with a single controlled SXdg gate. -void singleControlledSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledSxdg(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled SXdg gate. -void multipleControlledSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSxdg(QCProgramBuilder& b); /// Creates a circuit with a nested controlled SXdg gate. -void nestedControlledSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSxdg(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled SXdg gate. -void trivialControlledSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSxdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an SXdg gate. -void inverseSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseSxdg(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SXdg /// gate. -void inverseMultipleControlledSxdg(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSxdg(QCProgramBuilder& b); // --- RXOp ----------------------------------------------------------------- // /// Creates a circuit with just an RX gate. -void rx(QCProgramBuilder& b); +std::pair, SmallVector> rx(QCProgramBuilder& b); /// Creates a circuit with a single controlled RX gate. -void singleControlledRx(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRx(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RX gate. -void multipleControlledRx(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRx(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RX gate. -void nestedControlledRx(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRx(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RX gate. -void trivialControlledRx(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RX gate. -void inverseRx(QCProgramBuilder& b); +std::pair, SmallVector> inverseRx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RX gate. -void inverseMultipleControlledRx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRx(QCProgramBuilder& b); // --- RYOp ----------------------------------------------------------------- // /// Creates a circuit with just an RY gate. -void ry(QCProgramBuilder& b); +std::pair, SmallVector> ry(QCProgramBuilder& b); /// Creates a circuit with a single controlled RY gate. -void singleControlledRy(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRy(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RY gate. -void multipleControlledRy(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRy(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RY gate. -void nestedControlledRy(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRy(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RY gate. -void trivialControlledRy(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRy(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RY gate. -void inverseRy(QCProgramBuilder& b); +std::pair, SmallVector> inverseRy(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RY gate. -void inverseMultipleControlledRy(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRy(QCProgramBuilder& b); // --- RZOp ----------------------------------------------------------------- // /// Creates a circuit with just an RZ gate. -void rz(QCProgramBuilder& b); +std::pair, SmallVector> rz(QCProgramBuilder& b); /// Creates a circuit with a single controlled RZ gate. -void singleControlledRz(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRz(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RZ gate. -void multipleControlledRz(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRz(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RZ gate. -void nestedControlledRz(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRz(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RZ gate. -void trivialControlledRz(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRz(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZ gate. -void inverseRz(QCProgramBuilder& b); +std::pair, SmallVector> inverseRz(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZ gate. -void inverseMultipleControlledRz(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRz(QCProgramBuilder& b); // --- POp ------------------------------------------------------------------ // /// Creates a circuit with just a P gate. -void p(QCProgramBuilder& b); +std::pair, SmallVector> p(QCProgramBuilder& b); /// Creates a circuit with a single controlled P gate. -void singleControlledP(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledP(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled P gate. -void multipleControlledP(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledP(QCProgramBuilder& b); /// Creates a circuit with a nested controlled P gate. -void nestedControlledP(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledP(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled P gate. -void trivialControlledP(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledP(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a P gate. -void inverseP(QCProgramBuilder& b); +std::pair, SmallVector> inverseP(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled P gate. -void inverseMultipleControlledP(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledP(QCProgramBuilder& b); // --- ROp ------------------------------------------------------------------ // /// Creates a circuit with just an R gate. -void r(QCProgramBuilder& b); +std::pair, SmallVector> r(QCProgramBuilder& b); /// Creates a circuit with a single controlled R gate. -void singleControlledR(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledR(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled R gate. -void multipleControlledR(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledR(QCProgramBuilder& b); /// Creates a circuit with a nested controlled R gate. -void nestedControlledR(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledR(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled R gate. -void trivialControlledR(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledR(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an R gate. -void inverseR(QCProgramBuilder& b); +std::pair, SmallVector> inverseR(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled R gate. -void inverseMultipleControlledR(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledR(QCProgramBuilder& b); // --- U2Op ----------------------------------------------------------------- // /// Creates a circuit with just a U2 gate. -void u2(QCProgramBuilder& b); +std::pair, SmallVector> u2(QCProgramBuilder& b); /// Creates a circuit with a single controlled U2 gate. -void singleControlledU2(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledU2(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled U2 gate. -void multipleControlledU2(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledU2(QCProgramBuilder& b); /// Creates a circuit with a nested controlled U2 gate. -void nestedControlledU2(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledU2(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled U2 gate. -void trivialControlledU2(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledU2(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a U2 gate. -void inverseU2(QCProgramBuilder& b); +std::pair, SmallVector> inverseU2(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled U2 gate. -void inverseMultipleControlledU2(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledU2(QCProgramBuilder& b); // --- UOp ------------------------------------------------------------------ // /// Creates a circuit with just a U gate. -void u(QCProgramBuilder& b); +std::pair, SmallVector> u(QCProgramBuilder& b); /// Creates a circuit with a single controlled U gate. -void singleControlledU(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledU(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled U gate. -void multipleControlledU(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledU(QCProgramBuilder& b); /// Creates a circuit with a nested controlled U gate. -void nestedControlledU(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledU(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled U gate. -void trivialControlledU(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledU(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a U gate. -void inverseU(QCProgramBuilder& b); +std::pair, SmallVector> inverseU(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled U gate. -void inverseMultipleControlledU(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledU(QCProgramBuilder& b); // --- SWAPOp --------------------------------------------------------------- // /// Creates a circuit with just a SWAP gate. -void swap(QCProgramBuilder& b); +std::pair, SmallVector> swap(QCProgramBuilder& b); /// Creates a circuit with a single controlled SWAP gate. -void singleControlledSwap(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledSwap(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled SWAP gate. -void multipleControlledSwap(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSwap(QCProgramBuilder& b); /// Creates a circuit with a nested controlled SWAP gate. -void nestedControlledSwap(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSwap(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled SWAP gate. -void trivialControlledSwap(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSwap(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a SWAP gate. -void inverseSwap(QCProgramBuilder& b); +std::pair, SmallVector> +inverseSwap(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SWAP /// gate. -void inverseMultipleControlledSwap(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSwap(QCProgramBuilder& b); // --- iSWAPOp -------------------------------------------------------------- // /// Creates a circuit with just an iSWAP gate. -void iswap(QCProgramBuilder& b); +std::pair, SmallVector> iswap(QCProgramBuilder& b); /// Creates a circuit with a single controlled iSWAP gate. -void singleControlledIswap(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledIswap(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled iSWAP gate. -void multipleControlledIswap(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledIswap(QCProgramBuilder& b); /// Creates a circuit with a nested controlled iSWAP gate. -void nestedControlledIswap(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledIswap(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled iSWAP gate. -void trivialControlledIswap(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledIswap(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an iSWAP gate. -void inverseIswap(QCProgramBuilder& b); +std::pair, SmallVector> +inverseIswap(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled iSWAP /// gate. -void inverseMultipleControlledIswap(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledIswap(QCProgramBuilder& b); // --- DCXOp ---------------------------------------------------------------- // /// Creates a circuit with just a DCX gate. -void dcx(QCProgramBuilder& b); +std::pair, SmallVector> dcx(QCProgramBuilder& b); /// Creates a circuit with a single controlled DCX gate. -void singleControlledDcx(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledDcx(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled DCX gate. -void multipleControlledDcx(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledDcx(QCProgramBuilder& b); /// Creates a circuit with a nested controlled DCX gate. -void nestedControlledDcx(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledDcx(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled DCX gate. -void trivialControlledDcx(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledDcx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a DCX gate. -void inverseDcx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseDcx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled DCX gate. -void inverseMultipleControlledDcx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledDcx(QCProgramBuilder& b); // --- ECROp ---------------------------------------------------------------- // /// Creates a circuit with just an ECR gate. -void ecr(QCProgramBuilder& b); +std::pair, SmallVector> ecr(QCProgramBuilder& b); /// Creates a circuit with a single controlled ECR gate. -void singleControlledEcr(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledEcr(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled ECR gate. -void multipleControlledEcr(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledEcr(QCProgramBuilder& b); /// Creates a circuit with a nested controlled ECR gate. -void nestedControlledEcr(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledEcr(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled ECR gate. -void trivialControlledEcr(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledEcr(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an ECR gate. -void inverseEcr(QCProgramBuilder& b); +std::pair, SmallVector> +inverseEcr(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled ECR gate. -void inverseMultipleControlledEcr(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledEcr(QCProgramBuilder& b); // --- RXXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RXX gate. -void rxx(QCProgramBuilder& b); +std::pair, SmallVector> rxx(QCProgramBuilder& b); /// Creates a circuit with a single controlled RXX gate. -void singleControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRxx(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RXX gate. -void multipleControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRxx(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RXX gate. -void nestedControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRxx(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RXX gate. -void trivialControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRxx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RXX gate. -void inverseRxx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseRxx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RXX gate. -void inverseMultipleControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRxx(QCProgramBuilder& b); /// Creates a circuit with a triple-controlled RXX gate. -void tripleControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +tripleControlledRxx(QCProgramBuilder& b); /// Creates a circuit with a four-controlled RXX gate. -void fourControlledRxx(QCProgramBuilder& b); +std::pair, SmallVector> +fourControlledRxx(QCProgramBuilder& b); // --- RYYOp ---------------------------------------------------------------- // /// Creates a circuit with just an RYY gate. -void ryy(QCProgramBuilder& b); +std::pair, SmallVector> ryy(QCProgramBuilder& b); /// Creates a circuit with a single controlled RYY gate. -void singleControlledRyy(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRyy(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RYY gate. -void multipleControlledRyy(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRyy(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RYY gate. -void nestedControlledRyy(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRyy(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RYY gate. -void trivialControlledRyy(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRyy(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RYY gate. -void inverseRyy(QCProgramBuilder& b); +std::pair, SmallVector> +inverseRyy(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RYY gate. -void inverseMultipleControlledRyy(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRyy(QCProgramBuilder& b); // --- RZXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZX gate. -void rzx(QCProgramBuilder& b); +std::pair, SmallVector> rzx(QCProgramBuilder& b); /// Creates a circuit with a single controlled RZX gate. -void singleControlledRzx(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRzx(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RZX gate. -void multipleControlledRzx(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRzx(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RZX gate. -void nestedControlledRzx(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRzx(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RZX gate. -void trivialControlledRzx(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRzx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZX gate. -void inverseRzx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseRzx(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZX gate. -void inverseMultipleControlledRzx(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRzx(QCProgramBuilder& b); // --- RZZOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZZ gate. -void rzz(QCProgramBuilder& b); +std::pair, SmallVector> rzz(QCProgramBuilder& b); /// Creates a circuit with a single controlled RZZ gate. -void singleControlledRzz(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledRzz(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled RZZ gate. -void multipleControlledRzz(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRzz(QCProgramBuilder& b); /// Creates a circuit with a nested controlled RZZ gate. -void nestedControlledRzz(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRzz(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled RZZ gate. -void trivialControlledRzz(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRzz(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZZ gate. -void inverseRzz(QCProgramBuilder& b); +std::pair, SmallVector> +inverseRzz(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZZ gate. -void inverseMultipleControlledRzz(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRzz(QCProgramBuilder& b); // --- XXPlusYYOp ----------------------------------------------------------- // /// Creates a circuit with just an XXPlusYY gate. -void xxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> xxPlusYY(QCProgramBuilder& b); /// Creates a circuit with a single controlled XXPlusYY gate. -void singleControlledXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledXxPlusYY(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled XXPlusYY gate. -void multipleControlledXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledXxPlusYY(QCProgramBuilder& b); /// Creates a circuit with a nested controlled XXPlusYY gate. -void nestedControlledXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledXxPlusYY(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled XXPlusYY gate. -void trivialControlledXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledXxPlusYY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an XXPlusYY gate. -void inverseXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +inverseXxPlusYY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled XXPlusYY /// gate. -void inverseMultipleControlledXxPlusYY(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledXxPlusYY(QCProgramBuilder& b); // --- XXMinusYYOp ---------------------------------------------------------- // /// Creates a circuit with just an XXMinusYY gate. -void xxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> xxMinusYY(QCProgramBuilder& b); /// Creates a circuit with a single controlled XXMinusYY gate. -void singleControlledXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledXxMinusYY(QCProgramBuilder& b); /// Creates a circuit with a multi-controlled XXMinusYY gate. -void multipleControlledXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +multipleControlledXxMinusYY(QCProgramBuilder& b); /// Creates a circuit with a nested controlled XXMinusYY gate. -void nestedControlledXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +nestedControlledXxMinusYY(QCProgramBuilder& b); /// Creates a circuit with a trivial controlled XXMinusYY gate. -void trivialControlledXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +trivialControlledXxMinusYY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an XXMinusYY gate. -void inverseXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +inverseXxMinusYY(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled XXMinusYY /// gate. -void inverseMultipleControlledXxMinusYY(QCProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledXxMinusYY(QCProgramBuilder& b); // --- BarrierOp ------------------------------------------------------------ // /// Creates a circuit with a barrier. -void barrier(QCProgramBuilder& b); +std::pair, SmallVector> barrier(QCProgramBuilder& b); /// Creates a circuit with a barrier on two qubits. -void barrierTwoQubits(QCProgramBuilder& b); +std::pair, SmallVector> +barrierTwoQubits(QCProgramBuilder& b); /// Creates a circuit with a barrier on multiple qubits. -void barrierMultipleQubits(QCProgramBuilder& b); +std::pair, SmallVector> +barrierMultipleQubits(QCProgramBuilder& b); /// Creates a circuit with a single controlled barrier. -void singleControlledBarrier(QCProgramBuilder& b); +std::pair, SmallVector> +singleControlledBarrier(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a barrier. -void inverseBarrier(QCProgramBuilder& b); +std::pair, SmallVector> +inverseBarrier(QCProgramBuilder& b); // --- CtrlOp --------------------------------------------------------------- // /// Creates a circuit with a trivial ctrl modifier. -void trivialCtrl(QCProgramBuilder& b); +std::pair, SmallVector> +trivialCtrl(QCProgramBuilder& b); /// Creates a circuit with an empty ctrl modifier. -void emptyCtrl(QCProgramBuilder& b); +std::pair, SmallVector> emptyCtrl(QCProgramBuilder& b); /// Creates a circuit with nested ctrl modifiers. -void nestedCtrl(QCProgramBuilder& b); +std::pair, SmallVector> +nestedCtrl(QCProgramBuilder& b); /// Creates a circuit with triple nested ctrl modifiers. -void tripleNestedCtrl(QCProgramBuilder& b); +std::pair, SmallVector> +tripleNestedCtrl(QCProgramBuilder& b); /// Creates a circuit with double nested ctrl modifiers with two qubits each. -void doubleNestedCtrlTwoQubits(QCProgramBuilder& b); +std::pair, SmallVector> +doubleNestedCtrlTwoQubits(QCProgramBuilder& b); /// Creates a circuit with control modifiers interleaved by an inverse modifier. -void ctrlInvSandwich(QCProgramBuilder& b); +std::pair, SmallVector> +ctrlInvSandwich(QCProgramBuilder& b); /// Creates a circuit with a control modifier applied to two gates. -void ctrlTwo(QCProgramBuilder& b); +std::pair, SmallVector> ctrlTwo(QCProgramBuilder& b); /// Creates a circuit with a control modifier applied to a controlled and a /// non-controlled gate. -void ctrlTwoMixed(QCProgramBuilder& b); +std::pair, SmallVector> +ctrlTwoMixed(QCProgramBuilder& b); /// Creates a circuit with nested control modifiers applied to two gates. -void nestedCtrlTwo(QCProgramBuilder& b); +std::pair, SmallVector> +nestedCtrlTwo(QCProgramBuilder& b); /// Creates a circuit with a control modifier applied to a inverse modifier /// applied to two gates. -void ctrlInvTwo(QCProgramBuilder& b); +std::pair, SmallVector> +ctrlInvTwo(QCProgramBuilder& b); // --- InvOp ---------------------------------------------------------------- // /// Creates a circuit with an empty inverse modifier. -void emptyInv(QCProgramBuilder& b); +std::pair, SmallVector> emptyInv(QCProgramBuilder& b); /// Creates a circuit with nested inverse modifiers. -void nestedInv(QCProgramBuilder& b); +std::pair, SmallVector> nestedInv(QCProgramBuilder& b); /// Creates a circuit with triple nested inverse modifiers. -void tripleNestedInv(QCProgramBuilder& b); +std::pair, SmallVector> +tripleNestedInv(QCProgramBuilder& b); /// Creates a circuit with inverse modifiers interleaved by a control modifier. -void invCtrlSandwich(QCProgramBuilder& b); +std::pair, SmallVector> +invCtrlSandwich(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to two gates. -void invTwo(QCProgramBuilder& b); +std::pair, SmallVector> invTwo(QCProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a control modifier /// applied to two gates. -void invCtrlTwo(QCProgramBuilder& b); +std::pair, SmallVector> +invCtrlTwo(QCProgramBuilder& b); // --- IfOp ----------------------------------------------------------------- // /// Creates a circuit with a simple if operation with one qubit. -void simpleIf(QCProgramBuilder& b); - -/// Creates a circuit with an if operation with two qubits. -void ifTwoQubits(QCProgramBuilder& b); +std::pair, SmallVector> simpleIf(QCProgramBuilder& b); /// Creates a circuit with an if operation with an else branch. -void ifElse(QCProgramBuilder& b); +std::pair, SmallVector> ifElse(QCProgramBuilder& b); + +/// Creates a circuit with an if operation with two qubits. +std::pair, SmallVector> +ifTwoQubits(QCProgramBuilder& b); /// Creates a circuit with an if operation with a nested for operation with /// a register. -void nestedIfOpForLoop(QCProgramBuilder& b); +std::pair, SmallVector> +nestedIfOpForLoop(QCProgramBuilder& b); // --- WhileOp -------------------------------------------------------------- // /// Creates a circuit with a while operation using a while loop. -void simpleWhileReset(QCProgramBuilder& b); +std::pair, SmallVector> +simpleWhileReset(QCProgramBuilder& b); /// Creates a circuit with a while operation using a do-while loop. -void simpleDoWhileReset(QCProgramBuilder& b); +std::pair, SmallVector> +simpleDoWhileReset(QCProgramBuilder& b); // --- ForOp ---------------------------------------------------------------- // /// Creates a circuit with a simple for operation with a register. -void simpleForLoop(QCProgramBuilder& b); +std::pair, SmallVector> +simpleForLoop(QCProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested if operation. -void nestedForLoopIfOp(QCProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopIfOp(QCProgramBuilder& b); /// Creates a circuit with a for operation with a register and a nested while /// operation. -void nestedForLoopWhileOp(QCProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopWhileOp(QCProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is separately allocated from the /// register. -void nestedForLoopCtrlOpWithSeparateQubit(QCProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopCtrlOpWithSeparateQubit(QCProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is extracted from the register. -void nestedForLoopCtrlOpWithExtractedQubit(QCProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopCtrlOpWithExtractedQubit(QCProgramBuilder& b); } // namespace mlir::qc diff --git a/mlir/unittests/programs/qco_programs.cpp b/mlir/unittests/programs/qco_programs.cpp index 1fadf83eb2..85b8080ed8 100644 --- a/mlir/unittests/programs/qco_programs.cpp +++ b/mlir/unittests/programs/qco_programs.cpp @@ -14,201 +14,321 @@ #include #include +#include #include #include #include +static std::pair, mlir::SmallVector> +measureAndReturn(mlir::qco::QCOProgramBuilder& b, + mlir::SmallVector qubits) { + mlir::SmallVector bits; + mlir::SmallVector bitTypes; + auto i1Type = b.getI1Type(); + for (const auto& q : qubits) { + auto [q2, bit] = b.measure(q); + bits.push_back(bit); + bitTypes.push_back(i1Type); + } + return {bits, bitTypes}; +} + namespace mlir::qco { -void emptyQCO([[maybe_unused]] QCOProgramBuilder& builder) {} +std::pair, SmallVector> +emptyQCO(QCOProgramBuilder& b) { + return measureAndReturn(b, {}); +} -void allocQubit(QCOProgramBuilder& b) { b.allocQubit(); } +std::pair, SmallVector> +allocQubit(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + return measureAndReturn(b, {q}); +} -void allocQubitRegister(QCOProgramBuilder& b) { b.allocQubitRegister(2); } +std::pair, SmallVector> +allocQubitNoMeasure(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + return measureAndReturn(b, {}); +} -void allocMultipleQubitRegisters(QCOProgramBuilder& b) { - b.allocQubitRegister(2); - b.allocQubitRegister(3); +std::pair, SmallVector> +alloc1QubitRegister(QCOProgramBuilder& b) { + auto reg = b.allocQubitRegister(1); + return measureAndReturn(b, {reg[0]}); } -void allocLargeRegister(QCOProgramBuilder& b) { b.allocQubitRegister(100); } +std::pair, SmallVector> +alloc2QubitRegister(QCOProgramBuilder& b) { + auto reg = b.allocQubitRegister(2); + return measureAndReturn(b, {reg[0], reg[1]}); +} + +std::pair, SmallVector> +alloc3QubitRegister(QCOProgramBuilder& b) { + auto reg = b.allocQubitRegister(3); + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); +} + +std::pair, SmallVector> +allocMultipleQubitRegisters(QCOProgramBuilder& b) { + auto r1 = b.allocQubitRegister(2); + auto r2 = b.allocQubitRegister(3); + return measureAndReturn(b, {r1[0], r1[1], r2[0], r2[1], r2[2]}); +} -void staticQubits(QCOProgramBuilder& b) { - b.staticQubit(0); - b.staticQubit(1); +std::pair, SmallVector> +allocLargeRegister(QCOProgramBuilder& b) { + auto r = b.allocQubitRegister(100); + return measureAndReturn(b, {r[0]}); } -void staticQubitsWithOps(QCOProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsNoMeasure(QCOProgramBuilder& b) { + auto q1 = b.staticQubit(0); + auto q2 = b.staticQubit(1); + return measureAndReturn(b, {}); +} + +std::pair, SmallVector> +staticQubits(QCOProgramBuilder& b) { + auto q1 = b.staticQubit(0); + auto q2 = b.staticQubit(1); + return measureAndReturn(b, {q1, q2}); +} + +std::pair, SmallVector> +staticQubitsWithOps(QCOProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); q0 = b.h(q0); q1 = b.h(q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithParametricOps(QCOProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithParametricOps(QCOProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); q0 = b.rx(std::numbers::pi / 4., q0); q1 = b.p(std::numbers::pi / 2., q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithTwoTargetOps(QCOProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithTwoTargetOps(QCOProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); std::tie(q0, q1) = b.rzz(0.123, q0, q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithCtrl(QCOProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithCtrl(QCOProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); std::tie(q0, q1) = b.cx(q0, q1); + return measureAndReturn(b, {q0, q1}); } -void staticQubitsWithInv(QCOProgramBuilder& b) { +std::pair, SmallVector> +staticQubitsWithInv(QCOProgramBuilder& b) { auto q0 = b.staticQubit(0); q0 = b.inv({q0}, [&](auto targets) -> SmallVector { return {b.t(targets[0])}; })[0]; + return measureAndReturn(b, {q0}); } -void allocSinkPair(QCOProgramBuilder& b) { +std::pair, SmallVector> +allocSinkPair(QCOProgramBuilder& b) { auto q = b.allocQubit(); - b.sink(q); + auto [q1, c] = b.measure(q); + b.sink(q1); + return {{c}, {b.getI1Type()}}; } -void mixedStaticThenDynamicQubit(QCOProgramBuilder& b) { - b.staticQubit(0); - b.allocQubit(); +std::pair, SmallVector> +mixedStaticThenDynamicQubit(QCOProgramBuilder& b) { + auto q0 = b.staticQubit(0); + auto q1 = b.allocQubit(); + return measureAndReturn(b, {q0, q1}); } -void mixedDynamicRegisterThenStaticQubit(QCOProgramBuilder& b) { +std::pair, SmallVector> +mixedDynamicRegisterThenStaticQubit(QCOProgramBuilder& b) { b.qtensorAlloc(2); - b.staticQubit(0); + auto q1 = b.staticQubit(0); + return measureAndReturn(b, {q1}); } -void singleMeasurementToSingleBit(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleMeasurementToSingleBit(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(1); - q[0] = b.measure(q[0], c[0]); + const auto [q1, bit] = b.measure(q[0], c[0]); + return {{bit}, {b.getI1Type()}}; } -void repeatedMeasurementToSameBit(QCOProgramBuilder& b) { +std::pair, SmallVector> +repeatedMeasurementToSameBit(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(1); - q[0] = b.measure(q[0], c[0]); - q[0] = b.measure(q[0], c[0]); - q[0] = b.measure(q[0], c[0]); + auto [q1, _c1] = b.measure(q[0], c[0]); + auto [q2, _c2] = b.measure(q1, c[0]); + auto [q3, c3] = b.measure(q2, c[0]); + return {{c3}, {b.getI1Type()}}; } -void repeatedMeasurementToDifferentBits(QCOProgramBuilder& b) { +std::pair, SmallVector> +repeatedMeasurementToDifferentBits(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto& c = b.allocClassicalBitRegister(3); - q[0] = b.measure(q[0], c[0]); - q[0] = b.measure(q[0], c[1]); - q[0] = b.measure(q[0], c[2]); + auto [q1, c1] = b.measure(q[0], c[0]); + auto [q2, c2] = b.measure(q1, c[1]); + auto [q3, c3] = b.measure(q2, c[2]); + return {{c1, c2, c3}, {b.getI1Type(), b.getI1Type(), b.getI1Type()}}; } -void multipleClassicalRegistersAndMeasurements(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleClassicalRegistersAndMeasurements(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); const auto& c0 = b.allocClassicalBitRegister(1, "c0"); const auto& c1 = b.allocClassicalBitRegister(2, "c1"); - b.measure(q[0], c0[0]); - b.measure(q[1], c1[0]); - b.measure(q[2], c1[1]); + auto [q1, bit1] = b.measure(q[0], c0[0]); + auto [q2, bit2] = b.measure(q1, c1[0]); + auto [q3, bit3] = b.measure(q2, c1[1]); + return {{bit1, bit2, bit3}, {b.getI1Type(), b.getI1Type(), b.getI1Type()}}; } -void measurementWithoutRegisters(QCOProgramBuilder& b) { +std::pair, SmallVector> +measurementWithoutRegisters(QCOProgramBuilder& b) { auto q = b.allocQubit(); - b.measure(q); + auto [q1, c] = b.measure(q); + return {{c}, {b.getI1Type()}}; } -void resetQubitWithoutOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +resetQubitWithoutOp(QCOProgramBuilder& b) { auto q = b.allocQubit(); q = b.reset(q); + return measureAndReturn(b, {q}); } -void resetMultipleQubitsWithoutOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +resetMultipleQubitsWithoutOp(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); q[0] = b.reset(q[0]); q[1] = b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetWithoutOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +repeatedResetWithoutOp(QCOProgramBuilder& b) { auto q = b.allocQubit(); q = b.reset(q); q = b.reset(q); q = b.reset(q); + return measureAndReturn(b, {q}); } -void resetQubitAfterSingleOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +resetQubitAfterSingleOp(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.h(q[0]); q[0] = b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetMultipleQubitsAfterSingleOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +resetMultipleQubitsAfterSingleOp(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); q[0] = b.h(q[0]); q[0] = b.reset(q[0]); q[1] = b.h(q[1]); q[1] = b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetAfterSingleOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +repeatedResetAfterSingleOp(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.h(q[0]); q[0] = b.reset(q[0]); q[0] = b.reset(q[0]); q[0] = b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void globalPhase(QCOProgramBuilder& b) { b.gphase(0.123); } +std::pair, SmallVector> +globalPhase(QCOProgramBuilder& b) { + b.gphase(0.123); + return {{b.intConstant(0)}, {b.getI64Type()}}; +} -void singleControlledGlobalPhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledGlobalPhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.cgphase(0.123, q[0]); + q[0] = b.cgphase(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void multipleControlledGlobalPhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledGlobalPhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcgphase(0.123, {q[0], q[1], q[2]}); + auto qs = b.mcgphase(0.123, {q[0], q[1], q[2]}); + return measureAndReturn(b, {qs[0], qs[1], qs[2]}); } -void inverseGlobalPhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseGlobalPhase(QCOProgramBuilder& b) { b.inv({}, [&](ValueRange /*qubits*/) { b.gphase(-0.123); return SmallVector{}; }); + return measureAndReturn(b, {}); } -void inverseMultipleControlledGlobalPhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledGlobalPhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto qs = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { SmallVector controls{qubits[0], qubits[1], qubits[2]}; auto controlsOut = b.mcgphase(-0.123, controls); return SmallVector(controlsOut.begin(), controlsOut.end()); }); + return measureAndReturn(b, {qs[0], qs[1], qs[2]}); } -void identity(QCOProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - b.id(q[0]); +std::pair, SmallVector> +identity(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + q = b.id(q); + return measureAndReturn(b, {q}); } -void singleControlledIdentity(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledIdentity(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cid(q[1], q[0]); + std::tie(q[1], q[0]) = b.cid(q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledIdentity(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledIdentity(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcid({q[2], q[1]}, q[0]); + auto res = b.mcid({q[2], q[1]}, q[0]); + q[2] = res.first[0]; + q[1] = res.first[1]; + q[0] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledIdentity(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledIdentity(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.id(innerTargets[0])}; @@ -216,47 +336,71 @@ void nestedControlledIdentity(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledIdentity(QCOProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - b.mcid({}, q[0]); +std::pair, SmallVector> +trivialControlledIdentity(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + auto res = b.mcid({}, q); + q = res.second; + return measureAndReturn(b, {q}); } -void inverseIdentity(QCOProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.id(qubits[0])}; }); +std::pair, SmallVector> +inverseIdentity(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + auto res = b.inv( + {q}, [&](ValueRange qubits) { return SmallVector{b.id(qubits[0])}; }); + q = res[0]; + return measureAndReturn(b, {q}); } -void inverseMultipleControlledIdentity(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledIdentity(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcid({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void x(QCOProgramBuilder& b) { +std::pair, SmallVector> x(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.x(q[0]); + q[0] = b.x(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledX(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cx(q[0], q[1]); + std::tie(q[0], q[1]) = b.cx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledX(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcx({q[0], q[1]}, q[2]); + auto res = b.mcx({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledX(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledX(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.x(innerTargets[0])}; @@ -264,89 +408,116 @@ void nestedControlledX(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledX(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcx({}, q[0]); + auto res = b.mcx({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void repeatedControlledX(QCOProgramBuilder& b) { - auto tensor = b.qtensorAlloc(64); - - Value q0; - std::tie(tensor, q0) = b.qtensorExtract(tensor, 0); - - SmallVector values(63); - for (auto i = 1; i < 64; i++) { - Value qi; - std::tie(tensor, qi) = b.qtensorExtract(tensor, i); - values[i - 1] = qi; - } - - q0 = b.h(q0); - for (auto i = 1; i < 64; i++) { - std::tie(q0, values[i - 1]) = b.cx(q0, values[i - 1]); +std::pair, SmallVector> +repeatedControlledX(QCOProgramBuilder& b) { + auto q0 = b.allocQubit(); + auto control = b.h(q0); + std::vector targets; + for (auto i = 0; i < 50; i++) { + auto qubit = b.allocQubit(); + auto res = b.cx(control, qubit); + control = res.first; + targets.push_back(res.second); } + targets.push_back(control); + return measureAndReturn(b, + SmallVector(targets.begin(), targets.end())); } -void inverseX(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.x(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.x(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledX(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcx({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoX(QCOProgramBuilder& b) { +std::pair, SmallVector> twoX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.x(q[0]); q[0] = b.x(q[0]); + return measureAndReturn(b, {q[0]}); } -void controlledTwoX(QCOProgramBuilder& b) { +std::pair, SmallVector> +controlledTwoX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ctrl(q[0], q[1], [&](ValueRange targets) { auto q = b.x(targets[0]); q = b.x(q); return SmallVector{q}; }); + return measureAndReturn(b, {q[0], q[1]}); } -void inverseTwoX(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseTwoX(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.inv(q[0], [&](ValueRange qubits) { auto q = b.x(qubits[0]); q = b.x(q); return SmallVector{q}; }); + return measureAndReturn(b, {q[0]}); } -void y(QCOProgramBuilder& b) { +std::pair, SmallVector> y(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.y(q[0]); + q[0] = b.y(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledY(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cy(q[0], q[1]); + std::tie(q[0], q[1]) = b.cy(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledY(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcy({q[0], q[1]}, q[2]); + auto res = b.mcy({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledY(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledY(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.y(innerTargets[0])}; @@ -354,52 +525,78 @@ void nestedControlledY(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledY(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcy({}, q[0]); + auto res = b.mcy({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.y(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.y(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcy({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoY(QCOProgramBuilder& b) { +std::pair, SmallVector> twoY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.y(q[0]); q[0] = b.y(q[0]); + return measureAndReturn(b, {q[0]}); } -void z(QCOProgramBuilder& b) { +std::pair, SmallVector> z(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.z(q[0]); + q[0] = b.z(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cz(q[0], q[1]); + std::tie(q[0], q[1]) = b.cz(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcz({q[0], q[1]}, q[2]); + auto res = b.mcz({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledZ(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.z(innerTargets[0])}; @@ -407,52 +604,78 @@ void nestedControlledZ(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcz({}, q[0]); + auto res = b.mcz({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.z(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.z(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledZ(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcz({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoZ(QCOProgramBuilder& b) { +std::pair, SmallVector> twoZ(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.z(q[0]); q[0] = b.z(q[0]); + return measureAndReturn(b, {q[0]}); } -void h(QCOProgramBuilder& b) { +std::pair, SmallVector> h(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.h(q[0]); + q[0] = b.h(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledH(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ch(q[0], q[1]); + std::tie(q[0], q[1]) = b.ch(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledH(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mch({q[0], q[1]}, q[2]); + auto res = b.mch({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledH(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledH(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.h(innerTargets[0])}; @@ -460,57 +683,87 @@ void nestedControlledH(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledH(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mch({}, q[0]); + auto res = b.mch({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseH(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.h(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.h(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledH(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mch({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoH(QCOProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - q[0] = b.h(q[0]); - q[0] = b.h(q[0]); +std::pair, SmallVector> twoH(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + q = b.h(q); + q = b.h(q); + return measureAndReturn(b, {q}); } -void hWithoutRegister(QCOProgramBuilder& b) { +std::pair, SmallVector> +hWithoutRegister(QCOProgramBuilder& b) { auto q = b.allocQubit(); - b.h(q); + q = b.h(q); + return measureAndReturn(b, {q}); } -void s(QCOProgramBuilder& b) { +std::pair, SmallVector> s(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.s(q[0]); + q[0] = b.s(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledS(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cs(q[0], q[1]); + auto res = b.cs(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledS(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcs({q[0], q[1]}, q[2]); + auto res = b.mcs({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledS(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledS(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.s(innerTargets[0])}; @@ -518,58 +771,88 @@ void nestedControlledS(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledS(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcs({}, q[0]); + auto res = b.mcs({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseS(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.s(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.s(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledS(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcs({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sThenSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +sThenSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.s(q[0]); q[0] = b.sdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoS(QCOProgramBuilder& b) { +std::pair, SmallVector> twoS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.s(q[0]); q[0] = b.s(q[0]); + return measureAndReturn(b, {q[0]}); } -void sdg(QCOProgramBuilder& b) { +std::pair, SmallVector> sdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.sdg(q[0]); + q[0] = b.sdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.csdg(q[0], q[1]); + auto res = b.csdg(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcsdg({q[0], q[1]}, q[2]); + auto res = b.mcsdg({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSdg(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.sdg(innerTargets[0])}; @@ -577,59 +860,88 @@ void nestedControlledSdg(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcsdg({}, q[0]); + auto res = b.mcsdg({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.sdg(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.sdg(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcsdg({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sdgThenS(QCOProgramBuilder& b) { +std::pair, SmallVector> +sdgThenS(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sdg(q[0]); q[0] = b.s(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoSdg(QCOProgramBuilder& b) { +std::pair, SmallVector> twoSdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sdg(q[0]); q[0] = b.sdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void t_(QCOProgramBuilder& b) { +std::pair, SmallVector> t_(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.t(q[0]); + q[0] = b.t(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledT(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ct(q[0], q[1]); + auto res = b.ct(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledT(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mct({q[0], q[1]}, q[2]); + auto res = b.mct({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledT(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledT(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.t(innerTargets[0])}; @@ -637,58 +949,88 @@ void nestedControlledT(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledT(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mct({}, q[0]); + auto res = b.mct({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseT(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.t(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.t(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledT(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mct({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void tThenTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +tThenTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.t(q[0]); q[0] = b.tdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoT(QCOProgramBuilder& b) { +std::pair, SmallVector> twoT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.t(q[0]); q[0] = b.t(q[0]); + return measureAndReturn(b, {q[0]}); } -void tdg(QCOProgramBuilder& b) { +std::pair, SmallVector> tdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.tdg(q[0]); + q[0] = b.tdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ctdg(q[0], q[1]); + auto res = b.ctdg(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mctdg({q[0], q[1]}, q[2]); + auto res = b.mctdg({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledTdg(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.tdg(innerTargets[0])}; @@ -696,59 +1038,88 @@ void nestedControlledTdg(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mctdg({}, q[0]); + auto res = b.mctdg({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.tdg(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.tdg(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mctdg({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void tdgThenT(QCOProgramBuilder& b) { +std::pair, SmallVector> +tdgThenT(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.tdg(q[0]); q[0] = b.t(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoTdg(QCOProgramBuilder& b) { +std::pair, SmallVector> twoTdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.tdg(q[0]); q[0] = b.tdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void sx(QCOProgramBuilder& b) { +std::pair, SmallVector> sx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.sx(q[0]); + q[0] = b.sx(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.csx(q[0], q[1]); + auto res = b.csx(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcsx({q[0], q[1]}, q[2]); + auto res = b.mcsx({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSx(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.sx(innerTargets[0])}; @@ -756,59 +1127,88 @@ void nestedControlledSx(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcsx({}, q[0]); + auto res = b.mcsx({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.sx(qubits[0])}; }); + auto res = b.inv( + {q[0]}, [&](ValueRange qubits) { return SmallVector{b.sx(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcsx({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sxThenSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +sxThenSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sx(q[0]); q[0] = b.sxdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoSx(QCOProgramBuilder& b) { +std::pair, SmallVector> twoSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sx(q[0]); q[0] = b.sx(q[0]); + return measureAndReturn(b, {q[0]}); } -void sxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> sxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.sxdg(q[0]); + q[0] = b.sxdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.csxdg(q[0], q[1]); + auto res = b.csxdg(q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcsxdg({q[0], q[1]}, q[2]); + auto res = b.mcsxdg({q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSxdg(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.sxdg(innerTargets[0])}; @@ -816,59 +1216,89 @@ void nestedControlledSxdg(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcsxdg({}, q[0]); + auto res = b.mcsxdg({}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.sxdg(qubits[0])}; }); + auto res = b.inv({q[0]}, [&](ValueRange qubits) { + return SmallVector{b.sxdg(qubits[0])}; + }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcsxdg({qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sxdgThenSx(QCOProgramBuilder& b) { +std::pair, SmallVector> +sxdgThenSx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sxdg(q[0]); q[0] = b.sx(q[0]); + return measureAndReturn(b, {q[0]}); } -void twoSxdg(QCOProgramBuilder& b) { +std::pair, SmallVector> twoSxdg(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.sxdg(q[0]); q[0] = b.sxdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void rx(QCOProgramBuilder& b) { +std::pair, SmallVector> rx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.rx(0.123, q[0]); + q[0] = b.rx(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.crx(0.123, q[0], q[1]); + auto res = b.crx(0.123, q[0], q[1]); + q[0] = res.first; + q[1] = res.second; + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcrx(0.123, {q[0], q[1]}, q[2]); + auto res = b.mcrx(0.123, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRx(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.rx(0.123, innerTargets[0])}; @@ -876,59 +1306,87 @@ void nestedControlledRx(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcrx(0.123, {}, q[0]); + auto res = b.mcrx(0.123, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.rx(-0.123, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcrx(-0.123, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoRxOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRxOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.rx(0.123, q[0]); q[0] = b.rx(-0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void rxPiOver2(QCOProgramBuilder& b) { +std::pair, SmallVector> +rxPiOver2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.rx(std::numbers::pi / 2, q[0]); + q[0] = b.rx(std::numbers::pi / 2, q[0]); + return measureAndReturn(b, {q[0]}); } -void ry(QCOProgramBuilder& b) { +std::pair, SmallVector> ry(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.ry(0.456, q[0]); + q[0] = b.ry(0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cry(0.456, q[0], q[1]); + std::tie(q[0], q[1]) = b.cry(0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcry(0.456, {q[0], q[1]}, q[2]); + auto res = b.mcry(0.456, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRy(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.ry(0.456, innerTargets[0])}; @@ -936,58 +1394,87 @@ void nestedControlledRy(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcry(0.456, {}, q[0]); + auto res = b.mcry(0.456, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.ry(-0.456, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcry(-0.456, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoRyOppositePhase(QCOProgramBuilder& b) { + +std::pair, SmallVector> +twoRyOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.ry(0.456, q[0]); q[0] = b.ry(-0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void ryPiOver2(QCOProgramBuilder& b) { +std::pair, SmallVector> +ryPiOver2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.ry(std::numbers::pi / 2, q[0]); + q[0] = b.ry(std::numbers::pi / 2, q[0]); + return measureAndReturn(b, {q[0]}); } -void rz(QCOProgramBuilder& b) { +std::pair, SmallVector> rz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.rz(0.789, q[0]); + q[0] = b.rz(0.789, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.crz(0.789, q[0], q[1]); + std::tie(q[0], q[1]) = b.crz(0.789, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcrz(0.789, {q[0], q[1]}, q[2]); + auto res = b.mcrz(0.789, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRz(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.rz(0.789, innerTargets[0])}; @@ -995,54 +1482,80 @@ void nestedControlledRz(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcrz(0.789, {}, q[0]); + auto res = b.mcrz(0.789, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.rz(-0.789, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledRz(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcrz(-0.789, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoRzOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRzOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.rz(0.789, q[0]); q[0] = b.rz(-0.789, q[0]); + return measureAndReturn(b, {q[0]}); } -void p(QCOProgramBuilder& b) { +std::pair, SmallVector> p(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.p(0.123, q[0]); + q[0] = b.p(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledP(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cp(0.123, q[0], q[1]); + std::tie(q[0], q[1]) = b.cp(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledP(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcp(0.123, {q[0], q[1]}, q[2]); + auto res = b.mcp(0.123, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledP(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledP(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.p(0.123, innerTargets[0])}; @@ -1050,53 +1563,80 @@ void nestedControlledP(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledP(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcp(0.123, {}, q[0]); + auto res = b.mcp(0.123, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseP(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, - [&](ValueRange qubits) { return SmallVector{b.p(-0.123, qubits[0])}; }); + auto res = b.inv({q[0]}, [&](ValueRange qubits) { + return SmallVector{b.p(-0.123, qubits[0])}; + }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledP(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcp(-0.123, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void twoPOppositePhase(QCOProgramBuilder& b) { - auto q = b.allocQubitRegister(1); - q[0] = b.p(0.123, q[0]); - q[0] = b.p(-0.123, q[0]); +std::pair, SmallVector> +twoPOppositePhase(QCOProgramBuilder& b) { + auto q = b.allocQubit(); + q = b.p(0.123, q); + q = b.p(-0.123, q); + return measureAndReturn(b, {q}); } -void r(QCOProgramBuilder& b) { +std::pair, SmallVector> r(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.r(0.123, 0.456, q[0]); + q[0] = b.r(0.123, 0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledR(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledR(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cr(0.123, 0.456, q[0], q[1]); + std::tie(q[0], q[1]) = b.cr(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledR(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledR(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcr(0.123, 0.456, {q[0], q[1]}, q[2]); + auto res = b.mcr(0.123, 0.456, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledR(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledR(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.r(0.123, 0.456, innerTargets[0])}; @@ -1104,58 +1644,86 @@ void nestedControlledR(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledR(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledR(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcr(0.123, 0.456, {}, q[0]); + auto res = b.mcr(0.123, 0.456, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseR(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseR(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.r(-0.123, 0.456, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledR(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledR(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcr(-0.123, 0.456, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void canonicalizeRToRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeRToRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.r(0.123, 0., q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeRToRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeRToRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); q[0] = b.r(0.456, std::numbers::pi / 2, q[0]); + return measureAndReturn(b, {q[0]}); } -void u2(QCOProgramBuilder& b) { +std::pair, SmallVector> u2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u2(0.234, 0.567, q[0]); + q[0] = b.u2(0.234, 0.567, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledU2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cu2(0.234, 0.567, q[0], q[1]); + std::tie(q[0], q[1]) = b.cu2(0.234, 0.567, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledU2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcu2(0.234, 0.567, {q[0], q[1]}, q[2]); + auto res = b.mcu2(0.234, 0.567, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledU2(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.u2(0.234, 0.567, innerTargets[0])}; @@ -1163,63 +1731,95 @@ void nestedControlledU2(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledU2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcu2(0.234, 0.567, {}, q[0]); + auto res = b.mcu2(0.234, 0.567, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseU2(QCOProgramBuilder& b) { constexpr double pi = std::numbers::pi; auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.u2(-0.567 + pi, -0.234 - pi, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledU2(QCOProgramBuilder& b) { constexpr double pi = std::numbers::pi; auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcu2(-0.567 + pi, -0.234 - pi, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void canonicalizeU2ToH(QCOProgramBuilder& b) { + +std::pair, SmallVector> +canonicalizeU2ToH(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u2(0., std::numbers::pi, q[0]); + q[0] = b.u2(0., std::numbers::pi, q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeU2ToRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeU2ToRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u2(-std::numbers::pi / 2, std::numbers::pi / 2, q[0]); + q[0] = b.u2(-std::numbers::pi / 2, std::numbers::pi / 2, q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeU2ToRy(QCOProgramBuilder& b) { + +std::pair, SmallVector> +canonicalizeU2ToRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u2(0., 0., q[0]); + q[0] = b.u2(0., 0., q[0]); + return measureAndReturn(b, {q[0]}); } -void u(QCOProgramBuilder& b) { +std::pair, SmallVector> u(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u(0.1, 0.2, 0.3, q[0]); + q[0] = b.u(0.1, 0.2, 0.3, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledU(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.cu(0.1, 0.2, 0.3, q[0], q[1]); + std::tie(q[0], q[1]) = b.cu(0.1, 0.2, 0.3, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledU(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.mcu(0.1, 0.2, 0.3, {q[0], q[1]}, q[2]); + auto res = b.mcu(0.1, 0.2, 0.3, {q[0], q[1]}, q[2]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void nestedControlledU(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledU(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); - b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { + auto res = b.ctrl({reg[0]}, {reg[1], reg[2]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl({targets[0]}, {targets[1]}, [&](ValueRange innerTargets) { return SmallVector{b.u(0.1, 0.2, 0.3, innerTargets[0])}; @@ -1227,752 +1827,1192 @@ void nestedControlledU(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + return measureAndReturn(b, {reg[0], reg[1], reg[2]}); } -void trivialControlledU(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledU(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.mcu(0.1, 0.2, 0.3, {}, q[0]); + auto res = b.mcu(0.1, 0.2, 0.3, {}, q[0]); + q[0] = res.second; + return measureAndReturn(b, {q[0]}); } -void inverseU(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseU(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.u(-0.1, -0.3, -0.2, qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void inverseMultipleControlledU(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledU(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetOut] = b.mcu(-0.1, -0.3, -0.2, {qubits[0], qubits[1]}, qubits[2]); return llvm::to_vector( llvm::concat(controlsOut, ValueRange{targetOut})); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void canonicalizeUToP(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeUToP(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u(0., 0., 0.123, q[0]); + q[0] = b.u(0., 0., 0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeUToRx(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeUToRx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u(0.123, -std::numbers::pi / 2, std::numbers::pi / 2, q[0]); + q[0] = b.u(0.123, -std::numbers::pi / 2, std::numbers::pi / 2, q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeUToRy(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeUToRy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u(0.456, 0., 0., q[0]); + q[0] = b.u(0.456, 0., 0., q[0]); + return measureAndReturn(b, {q[0]}); } -void canonicalizeUToU2(QCOProgramBuilder& b) { +std::pair, SmallVector> +canonicalizeUToU2(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.u(std::numbers::pi / 2, 0.234, 0.567, q[0]); + q[0] = b.u(std::numbers::pi / 2, 0.234, 0.567, q[0]); + return measureAndReturn(b, {q[0]}); } -void swap(QCOProgramBuilder& b) { +std::pair, SmallVector> swap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.swap(q[0], q[1]); + std::tie(q[0], q[1]) = b.swap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cswap(q[0], q[1], q[2]); + auto res = b.cswap(q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcswap({q[0], q[1]}, q[2], q[3]); + auto res = b.mcswap({q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledSwap(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.swap(innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.swap(innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcswap({}, q[0], q[1]); + auto res = b.mcswap({}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.swap(qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcswap({qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoSwap(QCOProgramBuilder& b) { +std::pair, SmallVector> twoSwap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.swap(q[0], q[1]); std::tie(q[0], q[1]) = b.swap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoSwapSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoSwapSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.swap(q[0], q[1]); std::tie(q[1], q[0]) = b.swap(q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void iswap(QCOProgramBuilder& b) { +std::pair, SmallVector> iswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.iswap(q[0], q[1]); + std::tie(q[0], q[1]) = b.iswap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledIswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.ciswap(q[0], q[1], q[2]); + auto res = b.ciswap(q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledIswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mciswap({q[0], q[1]}, q[2], q[3]); + auto res = b.mciswap({q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledIswap(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.iswap(innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.iswap(innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledIswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mciswap({}, q[0], q[1]); + auto res = b.mciswap({}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseIswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.iswap(qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledIswap(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledIswap(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mciswap({qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void dcx(QCOProgramBuilder& b) { +std::pair, SmallVector> dcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.dcx(q[0], q[1]); + std::tie(q[0], q[1]) = b.dcx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cdcx(q[0], q[1], q[2]); + auto res = b.cdcx(q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcdcx({q[0], q[1]}, q[2], q[3]); + auto res = b.mcdcx({q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledDcx(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.dcx(innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.dcx(innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcdcx({}, q[0], q[1]); + auto res = b.mcdcx({}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[1], q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[1], q[0]}, [&](ValueRange qubits) { auto res = b.dcx(qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[1] = res[0]; + q[0] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[3], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[3], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcdcx({qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[3] = res[2]; + q[2] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoDcx(QCOProgramBuilder& b) { +std::pair, SmallVector> twoDcx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.dcx(q[0], q[1]); std::tie(q[0], q[1]) = b.dcx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoDcxSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoDcxSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.dcx(q[0], q[1]); std::tie(q[1], q[0]) = b.dcx(q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void ecr(QCOProgramBuilder& b) { +std::pair, SmallVector> ecr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ecr(q[0], q[1]); + std::tie(q[0], q[1]) = b.ecr(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cecr(q[0], q[1], q[2]); + auto res = b.cecr(q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcecr({q[0], q[1]}, q[2], q[3]); + auto res = b.mcecr({q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledEcr(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.ecr(innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.ecr(innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcecr({}, q[0], q[1]); + auto res = b.mcecr({}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.ecr(qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcecr({qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoEcr(QCOProgramBuilder& b) { +std::pair, SmallVector> twoEcr(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.ecr(q[0], q[1]); std::tie(q[0], q[1]) = b.ecr(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void rxx(QCOProgramBuilder& b) { +std::pair, SmallVector> rxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.rxx(0.123, q[0], q[1]); + std::tie(q[0], q[1]) = b.rxx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.crxx(0.123, q[0], q[1], q[2]); + auto res = b.crxx(0.123, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcrxx(0.123, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcrxx(0.123, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRxx(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.rxx(0.123, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.rxx(0.123, innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcrxx(0.123, {}, q[0], q[1]); + auto res = b.mcrxx(0.123, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.rxx(-0.123, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcrxx(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void tripleControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +tripleControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(5); - b.mcrxx(0.123, {q[0], q[1], q[2]}, q[3], q[4]); + auto res = b.mcrxx(0.123, {q[0], q[1], q[2]}, q[3], q[4]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.first[2]; + q[3] = res.second.first; + q[4] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4]}); } -void fourControlledRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> +fourControlledRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(6); - b.mcrxx(0.123, {q[0], q[1], q[2], q[3]}, q[4], q[5]); + auto res = b.mcrxx(0.123, {q[0], q[1], q[2], q[3]}, q[4], q[5]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.first[2]; + q[3] = res.first[3]; + q[4] = res.second.first; + q[5] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4], q[5]}); } -void twoRxx(QCOProgramBuilder& b) { +std::pair, SmallVector> twoRxx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.rxx(0.045, q[0], q[1]); std::tie(q[0], q[1]) = b.rxx(0.078, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRxxSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRxxSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.rxx(0.045, q[0], q[1]); std::tie(q[1], q[0]) = b.rxx(0.078, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRxxOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRxxOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rxx(0.123, q[0], q[1]); std::tie(q[0], q[1]) = b.rxx(-0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRxxOppositePhaseSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRxxOppositePhaseSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rxx(0.123, q[0], q[1]); std::tie(q[1], q[0]) = b.rxx(-0.123, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void ryy(QCOProgramBuilder& b) { +std::pair, SmallVector> ryy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ryy(0.123, q[0], q[1]); + std::tie(q[0], q[1]) = b.ryy(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cryy(0.123, q[0], q[1], q[2]); + auto res = b.cryy(0.123, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcryy(0.123, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcryy(0.123, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRyy(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.ryy(0.123, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.ryy(0.123, innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcryy(0.123, {}, q[0], q[1]); + auto res = b.mcryy(0.123, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.ryy(-0.123, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcryy(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoRyy(QCOProgramBuilder& b) { +std::pair, SmallVector> twoRyy(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.ryy(0.045, q[0], q[1]); std::tie(q[0], q[1]) = b.ryy(0.078, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRyyOppositePhaseSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRyyOppositePhaseSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.ryy(0.123, q[0], q[1]); std::tie(q[1], q[0]) = b.ryy(-0.123, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRyyOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRyyOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.ryy(0.123, q[0], q[1]); std::tie(q[0], q[1]) = b.ryy(-0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRyySwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRyySwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.ryy(0.045, q[0], q[1]); std::tie(q[1], q[0]) = b.ryy(0.078, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void rzx(QCOProgramBuilder& b) { +std::pair, SmallVector> rzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.rzx(0.123, q[0], q[1]); + std::tie(q[0], q[1]) = b.rzx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.crzx(0.123, q[0], q[1], q[2]); + auto res = b.crzx(0.123, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcrzx(0.123, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcrzx(0.123, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRzx(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.rzx(0.123, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.rzx(0.123, innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcrzx(0.123, {}, q[0], q[1]); + auto res = b.mcrzx(0.123, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.rzx(-0.123, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRzx(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRzx(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcrzx(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoRzxOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRzxOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rzx(0.123, q[0], q[1]); std::tie(q[0], q[1]) = b.rzx(-0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void rzz(QCOProgramBuilder& b) { +std::pair, SmallVector> rzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.rzz(0.123, q[0], q[1]); + std::tie(q[0], q[1]) = b.rzz(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.crzz(0.123, q[0], q[1], q[2]); + auto res = b.crzz(0.123, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcrzz(0.123, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcrzz(0.123, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledRzz(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = b.rzz(0.123, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.rzz(0.123, innerTargets[0], innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcrzz(0.123, {}, q[0], q[1]); + auto res = b.mcrzz(0.123, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.rzz(-0.123, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcrzz(-0.123, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoRzz(QCOProgramBuilder& b) { +std::pair, SmallVector> twoRzz(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.rzz(0.045, q[0], q[1]); std::tie(q[0], q[1]) = b.rzz(0.078, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRzzSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRzzSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); // 0.045 + 0.078 = 0.123 std::tie(q[0], q[1]) = b.rzz(0.045, q[0], q[1]); std::tie(q[1], q[0]) = b.rzz(0.078, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRzzOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRzzOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rzz(0.123, q[0], q[1]); std::tie(q[0], q[1]) = b.rzz(-0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void twoRzzOppositePhaseSwappedTargets(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoRzzOppositePhaseSwappedTargets(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rzz(0.123, q[0], q[1]); std::tie(q[1], q[0]) = b.rzz(-0.123, q[1], q[0]); + return measureAndReturn(b, {q[0], q[1]}); } -void xxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +xxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.xx_plus_yy(0.123, 0.456, q[0], q[1]); + std::tie(q[0], q[1]) = b.xx_plus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledXxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cxx_plus_yy(0.123, 0.456, q[0], q[1], q[2]); + auto res = b.cxx_plus_yy(0.123, 0.456, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledXxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcxx_plus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcxx_plus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledXxPlusYY(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = - b.xx_plus_yy(0.123, 0.456, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.xx_plus_yy(0.123, 0.456, innerTargets[0], + innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledXxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcxx_plus_yy(0.123, 0.456, {}, q[0], q[1]); + auto res = b.mcxx_plus_yy(0.123, 0.456, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseXxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.xx_plus_yy(-0.123, 0.456, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledXxPlusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledXxPlusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcxx_plus_yy( -0.123, 0.456, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoXxPlusYYOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoXxPlusYYOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.xx_plus_yy(0.123, 0.456, q[0], q[1]); std::tie(q[0], q[1]) = b.xx_plus_yy(-0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void xxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +xxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.xx_minus_yy(0.123, 0.456, q[0], q[1]); + std::tie(q[0], q[1]) = b.xx_minus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledXxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.cxx_minus_yy(0.123, 0.456, q[0], q[1], q[2]); + auto res = b.cxx_minus_yy(0.123, 0.456, q[0], q[1], q[2]); + q[0] = res.first; + q[1] = res.second.first; + q[2] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +multipleControlledXxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.mcxx_minus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + auto res = b.mcxx_minus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second.first; + q[3] = res.second.second; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedControlledXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedControlledXxMinusYY(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); - b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( - {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { - auto res = - b.xx_minus_yy(0.123, 0.456, innerTargets[0], innerTargets[1]); - return SmallVector{res.first, res.second}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({reg[0]}, {reg[1], reg[2], reg[3]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0]}, {targets[1], targets[2]}, + [&](ValueRange innerTargets) { + auto res = b.xx_minus_yy(0.123, 0.456, innerTargets[0], + innerTargets[1]); + return SmallVector{res.first, res.second}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + reg[0] = res.first[0]; + reg[1] = res.second[0]; + reg[2] = res.second[1]; + reg[3] = res.second[2]; + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void trivialControlledXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialControlledXxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.mcxx_minus_yy(0.123, 0.456, {}, q[0], q[1]); + auto res = b.mcxx_minus_yy(0.123, 0.456, {}, q[0], q[1]); + q[0] = res.second.first; + q[1] = res.second.second; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseXxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto res = b.xx_minus_yy(-0.123, 0.456, qubits[0], qubits[1]); return SmallVector{res.first, res.second}; }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void inverseMultipleControlledXxMinusYY(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseMultipleControlledXxMinusYY(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2], q[3]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.mcxx_minus_yy( -0.123, 0.456, {qubits[0], qubits[1]}, qubits[2], qubits[3]); SmallVector targets{targetsOut.first, targetsOut.second}; return llvm::to_vector(llvm::concat(controlsOut, targets)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + q[3] = res[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void twoXxMinusYYOppositePhase(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoXxMinusYYOppositePhase(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.xx_minus_yy(0.123, 0.456, q[0], q[1]); std::tie(q[0], q[1]) = b.xx_minus_yy(-0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void barrier(QCOProgramBuilder& b) { +std::pair, SmallVector> barrier(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.barrier(q[0]); + auto q1 = b.barrier(q[0]); + return measureAndReturn(b, {q1}); } -void barrierTwoQubits(QCOProgramBuilder& b) { +std::pair, SmallVector> +barrierTwoQubits(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.barrier({q[0], q[1]}); + auto res = b.barrier({q[0], q[1]}); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void barrierMultipleQubits(QCOProgramBuilder& b) { +std::pair, SmallVector> +barrierMultipleQubits(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.barrier({q[0], q[1], q[2]}); + auto res = b.barrier({q[0], q[1], q[2]}); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void singleControlledBarrier(QCOProgramBuilder& b) { +std::pair, SmallVector> +singleControlledBarrier(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ctrl({q[1]}, {q[0]}, [&](ValueRange targets) { + auto res = b.ctrl({q[1]}, {q[0]}, [&](ValueRange targets) { return SmallVector{b.barrier(targets[0])}; }); + q[1] = res.first[0]; + q[0] = res.second[0]; + return measureAndReturn(b, {q[0]}); } -void inverseBarrier(QCOProgramBuilder& b) { +std::pair, SmallVector> +inverseBarrier(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.inv({q[0]}, [&](ValueRange qubits) { + auto res = b.inv({q[0]}, [&](ValueRange qubits) { return SmallVector{b.barrier(qubits[0])}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void twoBarrier(QCOProgramBuilder& b) { +std::pair, SmallVector> +twoBarrier(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); auto b1 = b.barrier({q[0], q[1]}); q[0] = b1[0]; q[1] = b1[1]; - b.barrier({q[0], q[1]}); + auto b2 = b.barrier({q[0], q[1]}); + q[0] = b2[0]; + q[1] = b2[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void trivialCtrl(QCOProgramBuilder& b) { +std::pair, SmallVector> +trivialCtrl(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.ctrl({}, {q[0], q[1]}, [&](ValueRange targets) { + auto [_, q01] = b.ctrl({}, {q[0], q[1]}, [&](ValueRange targets) { auto [q0, q1] = b.rxx(0.123, targets[0], targets[1]); return SmallVector{q0, q1}; }); + return measureAndReturn(b, {q01[0], q01[1]}); } -void emptyCtrl(QCOProgramBuilder& b) { +std::pair, SmallVector> +emptyCtrl(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rxx(0.123, q[0], q[1]); b.ctrl(q[0], q[1], [&](ValueRange targets) { return targets; }); + return measureAndReturn(b, {q[0], q[1]}); } -void nestedCtrl(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedCtrl(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.ctrl({q[0]}, {q[1], q[2], q[3]}, [&](ValueRange targets) { + auto res = b.ctrl({q[0]}, {q[1], q[2], q[3]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( {targets[0]}, {targets[1], targets[2]}, [&](ValueRange innerTargets) { auto [q0, q1] = b.rxx(0.123, innerTargets[0], innerTargets[1]); @@ -1981,11 +3021,17 @@ void nestedCtrl(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + q[0] = res.first[0]; + q[1] = res.second[0]; + q[2] = res.second[1]; + q[3] = res.second[2]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void tripleNestedCtrl(QCOProgramBuilder& b) { +std::pair, SmallVector> +tripleNestedCtrl(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(5); - b.ctrl({q[0]}, {q[1], q[2], q[3], q[4]}, [&](ValueRange targets) { + auto res = b.ctrl({q[0]}, {q[1], q[2], q[3], q[4]}, [&](ValueRange targets) { const auto& [innerControlsOut, innerTargetsOut] = b.ctrl( {targets[0]}, {targets[1], targets[2], targets[3]}, [&](ValueRange innerTargets) { @@ -2002,25 +3048,42 @@ void tripleNestedCtrl(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); + q[0] = res.first[0]; + q[1] = res.second[0]; + q[2] = res.second[1]; + q[3] = res.second[2]; + q[4] = res.second[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4]}); } -void doubleNestedCtrlTwoQubits(QCOProgramBuilder& b) { +std::pair, SmallVector> +doubleNestedCtrlTwoQubits(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(6); - b.ctrl({q[0], q[1]}, {q[2], q[3], q[4], q[5]}, [&](ValueRange targets) { - const auto& [innerControlsOut, innerTargetsOut] = - b.ctrl({targets[0], targets[1]}, {targets[2], targets[3]}, - [&](ValueRange innerTargets) { - auto [q0, q1] = b.rxx(0.123, innerTargets[0], innerTargets[1]); - return SmallVector{q0, q1}; - }); - return llvm::to_vector( - llvm::concat(innerControlsOut, innerTargetsOut)); - }); + auto res = + b.ctrl({q[0], q[1]}, {q[2], q[3], q[4], q[5]}, [&](ValueRange targets) { + const auto& [innerControlsOut, innerTargetsOut] = + b.ctrl({targets[0], targets[1]}, {targets[2], targets[3]}, + [&](ValueRange innerTargets) { + auto [q0, q1] = + b.rxx(0.123, innerTargets[0], innerTargets[1]); + return SmallVector{q0, q1}; + }); + return llvm::to_vector( + llvm::concat(innerControlsOut, innerTargetsOut)); + }); + q[0] = res.first[0]; + q[1] = res.first[1]; + q[2] = res.second[0]; + q[3] = res.second[1]; + q[4] = res.second[2]; + q[5] = res.second[3]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4], q[5]}); } -void ctrlInvSandwich(QCOProgramBuilder& b) { +std::pair, SmallVector> +ctrlInvSandwich(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); - b.ctrl({q[0]}, {q[1], q[2], q[3]}, [&](ValueRange targets) { + auto res = b.ctrl({q[0]}, {q[1], q[2], q[3]}, [&](ValueRange targets) { auto inner = b.inv( {targets[0], targets[1], targets[2]}, [&](ValueRange innerTargets) { auto [innerControlsOut, innerTargetsOut] = @@ -2033,11 +3096,16 @@ void ctrlInvSandwich(QCOProgramBuilder& b) { return llvm::to_vector( llvm::concat(innerControlsOut, innerTargetsOut)); }); - return SmallVector{inner}; + return llvm::to_vector(inner); }); + q[0] = res.first[0]; + q[1] = res.second[0]; + q[2] = res.second[1]; + q[3] = res.second[2]; + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlTwo(QCOProgramBuilder& b) { +std::pair, SmallVector> ctrlTwo(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl({q[0], q[1]}, {q[2], q[3]}, [&](ValueRange targets) { auto i0 = targets[0]; @@ -2046,9 +3114,11 @@ void ctrlTwo(QCOProgramBuilder& b) { std::tie(i0, i1) = b.rxx(0.123, i0, i1); return SmallVector{i0, i1}; }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlTwoMixed(QCOProgramBuilder& b) { +std::pair, SmallVector> +ctrlTwoMixed(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl({q[0], q[1]}, {q[2], q[3]}, [&](ValueRange targets) { auto i0 = targets[0]; @@ -2057,9 +3127,11 @@ void ctrlTwoMixed(QCOProgramBuilder& b) { std::tie(i0, i1) = b.rxx(0.123, i0, i1); return SmallVector{i0, i1}; }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void nestedCtrlTwo(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedCtrlTwo(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.ctrl(q[0], {q[1], q[2], q[3]}, [&](ValueRange targets) { const auto& [controlsOut, targetsOut] = b.ctrl( @@ -2072,9 +3144,11 @@ void nestedCtrlTwo(QCOProgramBuilder& b) { }); return llvm::to_vector(llvm::concat(controlsOut, targetsOut)); }); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ctrlInvTwo(QCOProgramBuilder& b) { +std::pair, SmallVector> +ctrlInvTwo(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ctrl(q[0], {q[1], q[2]}, [&](ValueRange targets) { auto inner = b.inv(targets, [&](ValueRange qubits) { @@ -2086,28 +3160,36 @@ void ctrlInvTwo(QCOProgramBuilder& b) { }); return llvm::to_vector(inner); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void emptyInv(QCOProgramBuilder& b) { +std::pair, SmallVector> +emptyInv(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); std::tie(q[0], q[1]) = b.rxx(0.123, q[0], q[1]); b.inv({q[0], q[1]}, [&](ValueRange qubits) { return qubits; }); + return measureAndReturn(b, {q[0], q[1]}); } -void nestedInv(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedInv(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto inner = b.inv({qubits[0], qubits[1]}, [&](ValueRange innerQubits) { auto [q0, q1] = b.rxx(0.123, innerQubits[0], innerQubits[1]); return SmallVector{q0, q1}; }); - return SmallVector{inner}; + return llvm::to_vector(inner); }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void tripleNestedInv(QCOProgramBuilder& b) { +std::pair, SmallVector> +tripleNestedInv(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); - b.inv({q[0], q[1]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto inner1 = b.inv({qubits[0], qubits[1]}, [&](ValueRange innerQubits) { auto inner2 = b.inv( {innerQubits[0], innerQubits[1]}, [&](ValueRange innerInnerQubits) { @@ -2115,15 +3197,19 @@ void tripleNestedInv(QCOProgramBuilder& b) { b.rxx(-0.123, innerInnerQubits[0], innerInnerQubits[1]); return SmallVector{q0, q1}; }); - return SmallVector{inner2}; + return llvm::to_vector(inner2); }); - return SmallVector{inner1}; + return llvm::to_vector(inner1); }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void invCtrlSandwich(QCOProgramBuilder& b) { +std::pair, SmallVector> +invCtrlSandwich(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); - b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { + auto res = b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = b.ctrl({qubits[0]}, {qubits[1], qubits[2]}, [&](ValueRange targets) { auto inner = @@ -2131,13 +3217,17 @@ void invCtrlSandwich(QCOProgramBuilder& b) { auto [q0, q1] = b.rxx(0.123, innerQubits[0], innerQubits[1]); return SmallVector{q0, q1}; }); - return SmallVector{inner}; + return llvm::to_vector(inner); }); return llvm::to_vector(llvm::concat(controlsOut, targetsOut)); }); + q[0] = res[0]; + q[1] = res[1]; + q[2] = res[2]; + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void invTwo(QCOProgramBuilder& b) { +std::pair, SmallVector> invTwo(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.inv({q[0], q[1]}, [&](ValueRange qubits) { auto i0 = qubits[0]; @@ -2146,9 +3236,11 @@ void invTwo(QCOProgramBuilder& b) { std::tie(i0, i1) = b.rxx(0.123, i0, i1); return SmallVector{i0, i1}; }); + return measureAndReturn(b, {q[0], q[1]}); } -void invCtrlTwo(QCOProgramBuilder& b) { +std::pair, SmallVector> +invCtrlTwo(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.inv({q[0], q[1], q[2]}, [&](ValueRange qubits) { const auto& [controlsOut, targetsOut] = @@ -2161,19 +3253,24 @@ void invCtrlTwo(QCOProgramBuilder& b) { }); return llvm::to_vector(llvm::concat(controlsOut, targetsOut)); }); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void simpleIf(QCOProgramBuilder& b) { +std::pair, SmallVector> +simpleIf(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); auto q0 = b.h(q[0]); auto [measuredQubit, measureResult] = b.measure(q0); - b.qcoIf(measureResult, measuredQubit, [&](ValueRange args) { + auto res = b.qcoIf(measureResult, measuredQubit, [&](ValueRange args) { auto innerQubit = b.x(args[0]); return SmallVector{innerQubit}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void ifWithAngle(QCOProgramBuilder& b) { +std::pair, SmallVector> +ifWithAngle(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); auto theta = b.floatConstant(0.123); auto q0 = b.h(q[0]); @@ -2182,24 +3279,30 @@ void ifWithAngle(QCOProgramBuilder& b) { auto innerQubit = b.rx(theta, args[0]); return SmallVector{innerQubit}; }); + return measureAndReturn(b, {q[0]}); } -void ifTwoQubits(QCOProgramBuilder& b) { +std::pair, SmallVector> +ifTwoQubits(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(2); auto q0 = b.h(q[0]); auto [measuredQubit, measureResult] = b.measure(q0); - b.qcoIf(measureResult, {measuredQubit, q[1]}, [&](ValueRange args) { - auto innerQubit0 = b.x(args[0]); - auto innerQubit1 = b.x(args[1]); - return SmallVector{innerQubit0, innerQubit1}; - }); + auto res = + b.qcoIf(measureResult, {measuredQubit, q[1]}, [&](ValueRange args) { + auto innerQubit0 = b.x(args[0]); + auto innerQubit1 = b.x(args[1]); + return SmallVector{innerQubit0, innerQubit1}; + }); + q[0] = res[0]; + q[1] = res[1]; + return measureAndReturn(b, {q[0], q[1]}); } -void ifElse(QCOProgramBuilder& b) { +std::pair, SmallVector> ifElse(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); auto q0 = b.h(q[0]); auto [measuredQubit, measureResult] = b.measure(q0); - b.qcoIf( + auto res = b.qcoIf( measureResult, {measuredQubit}, [&](ValueRange args) { auto innerQubit = b.x(args[0]); @@ -2209,25 +3312,31 @@ void ifElse(QCOProgramBuilder& b) { auto innerQubit = b.z(args[0]); return SmallVector{innerQubit}; }); + q[0] = res[0]; + return measureAndReturn(b, {q[0]}); } -void ifOneQubitOneTensor(QCOProgramBuilder& b) { +std::pair, SmallVector> +ifOneQubitOneTensor(QCOProgramBuilder& b) { auto q0 = b.allocQubit(); auto t0 = b.allocQubitRegister(1); auto q1 = b.h(q0); auto [measuredQubit, measureResult] = b.measure(q1); - b.qcoIf(measureResult, {measuredQubit, t0.value}, [&](ValueRange args) { - auto innerQubit0 = b.x(args[0]); - auto [t1, innerQubit1] = b.qtensorExtract(args[1], 0); - auto innerQubit2 = b.x(innerQubit1); - auto t2 = b.qtensorInsert(innerQubit2, t1, 0); - return SmallVector{innerQubit0, t2}; - }); + auto ifRes = + b.qcoIf(measureResult, {measuredQubit, t0.value}, [&](ValueRange args) { + auto innerQubit0 = b.x(args[0]); + auto [t1, innerQubit1] = b.qtensorExtract(args[1], 0); + auto innerQubit2 = b.x(innerQubit1); + auto t2 = b.qtensorInsert(innerQubit2, t1, 0); + return SmallVector{innerQubit0, t2}; + }); + return measureAndReturn(b, {ifRes[0]}); } -void constantTrueIf(QCOProgramBuilder& b) { +std::pair, SmallVector> +constantTrueIf(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.qcoIf( + auto ifRes = b.qcoIf( true, q.qubits, [&](ValueRange args) { auto innerQubit = b.x(args[0]); @@ -2237,11 +3346,13 @@ void constantTrueIf(QCOProgramBuilder& b) { auto innerQubit = b.z(args[0]); return SmallVector{innerQubit}; }); + return measureAndReturn(b, {ifRes[0]}); } -void constantFalseIf(QCOProgramBuilder& b) { +std::pair, SmallVector> +constantFalseIf(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); - b.qcoIf( + auto ifRes = b.qcoIf( false, q.qubits, [&](ValueRange args) { auto innerQubit = b.x(args[0]); @@ -2251,13 +3362,15 @@ void constantFalseIf(QCOProgramBuilder& b) { auto innerQubit = b.z(args[0]); return SmallVector{innerQubit}; }); + return measureAndReturn(b, {ifRes[0]}); } -void nestedTrueIf(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedTrueIf(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); auto q0 = b.h(q[0]); auto [measuredQubit, measureResult] = b.measure(q0); - b.qcoIf(measureResult, measuredQubit, [&](ValueRange outerArgs) { + auto ifRes = b.qcoIf(measureResult, measuredQubit, [&](ValueRange outerArgs) { auto innerResult = b.qcoIf(measureResult, outerArgs, [&](ValueRange innerArgs) { auto innerQubit = b.x(innerArgs[0]); @@ -2265,13 +3378,15 @@ void nestedTrueIf(QCOProgramBuilder& b) { }); return llvm::to_vector(innerResult); }); + return measureAndReturn(b, {ifRes[0]}); } -void nestedFalseIf(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedFalseIf(QCOProgramBuilder& b) { auto q = b.allocQubitRegister(1); auto q0 = b.h(q[0]); auto [measuredQubit, measureResult] = b.measure(q0); - b.qcoIf( + auto ifRes = b.qcoIf( measureResult, measuredQubit, [&](ValueRange args) { auto innerQubit = b.x(args[0]); @@ -2287,65 +3402,87 @@ void nestedFalseIf(QCOProgramBuilder& b) { }); return llvm::to_vector(innerResult); }); + return measureAndReturn(b, {ifRes[0]}); } -void qtensorAlloc(QCOProgramBuilder& b) { b.qtensorAlloc(3); } +std::pair, SmallVector> +qtensorAlloc(QCOProgramBuilder& b) { + auto qtensor = b.qtensorAlloc(3); + return measureAndReturn(b, {qtensor}); +} -void qtensorDealloc(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorDealloc(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); b.qtensorDealloc(qtensor); + return measureAndReturn(b, {}); } -void qtensorFromElements(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorFromElements(QCOProgramBuilder& b) { auto q0 = b.allocQubit(); auto q1 = b.allocQubit(); auto q2 = b.allocQubit(); - b.qtensorFromElements({q0, q1, q2}); + auto t = b.qtensorFromElements({q0, q1, q2}); + return measureAndReturn(b, {t}); } -void qtensorExtract(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorExtract(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); - b.qtensorExtract(qtensor, 0); + auto [t, q] = b.qtensorExtract(qtensor, 0); + return measureAndReturn(b, {t, q}); } -void qtensorInsert(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorInsert(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); auto [extractOutTensor, q0] = b.qtensorExtract(qtensor, 0); auto q1 = b.h(q0); - b.qtensorInsert(q1, extractOutTensor, 0); + auto insertOutTensor = b.qtensorInsert(q1, extractOutTensor, 0); + return measureAndReturn(b, {insertOutTensor}); } -void qtensorExtractInsertIndexMismatch(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorExtractInsertIndexMismatch(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); auto [extractOutTensor, q0] = b.qtensorExtract(qtensor, 0); - b.qtensorInsert(q0, extractOutTensor, 1); + auto insertOutTensor = b.qtensorInsert(q0, extractOutTensor, 1); + return measureAndReturn(b, {insertOutTensor}); } -void qtensorExtractInsertSameIndex(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorExtractInsertSameIndex(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); auto [extractOutTensor, q0] = b.qtensorExtract(qtensor, 0); - b.qtensorInsert(q0, extractOutTensor, 0); + auto insertOutTensor = b.qtensorInsert(q0, extractOutTensor, 0); + return measureAndReturn(b, {insertOutTensor}); } -void qtensorInsertExtractIndexMismatch(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorInsertExtractIndexMismatch(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); auto [extractOutTensor, q0] = b.qtensorExtract(qtensor, 0); auto q1 = b.h(q0); auto insertOutTensor = b.qtensorInsert(q1, extractOutTensor, 0); auto [extractOutTensor1, q2] = b.qtensorExtract(insertOutTensor, 1); - b.qtensorInsert(q2, extractOutTensor1, 0); + auto insertOutTensor1 = b.qtensorInsert(q2, extractOutTensor1, 0); + return measureAndReturn(b, {insertOutTensor1}); } -void qtensorInsertExtractSameIndex(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorInsertExtractSameIndex(QCOProgramBuilder& b) { auto qtensor = b.qtensorAlloc(3); auto [extractOutTensor, q0] = b.qtensorExtract(qtensor, 0); auto q1 = b.h(q0); auto insertOutTensor = b.qtensorInsert(q1, extractOutTensor, 0); auto [extractOutTensor1, q2] = b.qtensorExtract(insertOutTensor, 0); - b.qtensorInsert(q2, extractOutTensor1, 0); + auto insertOutTensor1 = b.qtensorInsert(q2, extractOutTensor1, 0); + return measureAndReturn(b, {insertOutTensor1}); } -void qtensorChain(QCOProgramBuilder& b) { +std::pair, SmallVector> +qtensorChain(QCOProgramBuilder& b) { Value q0; Value q1; Value q2; @@ -2361,6 +3498,8 @@ void qtensorChain(QCOProgramBuilder& b) { qtensor = b.qtensorInsert(q1, qtensor, 1); qtensor = b.qtensorInsert(q0, qtensor, 0); b.qtensorDealloc(qtensor); + + return measureAndReturn(b, {}); } void qtensorAlternativeChain(QCOProgramBuilder& b) { @@ -2379,12 +3518,14 @@ void qtensorAlternativeChain(QCOProgramBuilder& b) { qtensor = b.qtensorInsert(q1, qtensor, 1); qtensor = b.qtensorInsert(q2, qtensor, 2); b.qtensorDealloc(qtensor); + + return measureAndReturn(b, {}); } void simpleWhileReset(QCOProgramBuilder& b) { auto q0 = b.allocQubit(); auto q1 = b.h(q0); - b.scfWhile( + auto scfWhile = b.scfWhile( ValueRange{q1}, [&](ValueRange iterArgs) { auto [q2, measureResult] = b.measure(iterArgs[0]); @@ -2395,11 +3536,13 @@ void simpleWhileReset(QCOProgramBuilder& b) { auto q3 = b.h(iterArgs[0]); return SmallVector{q3}; }); + return measureAndReturn(b, {scfWhile[0]}); } -void simpleDoWhileReset(QCOProgramBuilder& b) { +std::pair, SmallVector> +simpleDoWhileReset(QCOProgramBuilder& b) { auto q0 = b.allocQubit(); - b.scfWhile( + auto scfWhile = b.scfWhile( ValueRange{q0}, [&](ValueRange iterArgs) { auto q1 = b.h(iterArgs[0]); @@ -2408,46 +3551,57 @@ void simpleDoWhileReset(QCOProgramBuilder& b) { return SmallVector{q2}; }, [&](ValueRange iterArgs) { return llvm::to_vector(iterArgs); }); + return measureAndReturn(b, {scfWhile[0]}); } -void simpleForLoop(QCOProgramBuilder& b) { +std::pair, SmallVector> +simpleForLoop(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(2); - b.scfFor(0, 2, 1, {reg.value}, [&](Value iv, ValueRange iterArgs) { - auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); - auto q1 = b.h(q0); - auto insert = b.qtensorInsert(q1, t0, iv); - return SmallVector{insert}; - }); + auto scfFor = + b.scfFor(0, 2, 1, {reg.value}, [&](Value iv, ValueRange iterArgs) { + auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); + auto q1 = b.h(q0); + auto insert = b.qtensorInsert(q1, t0, iv); + return SmallVector{insert}; + }); + return measureAndReturn(b, {scfFor[0]}); }; -void forLoopWithAngle(QCOProgramBuilder& b) { +std::pair, SmallVector> +forLoopWithAngle(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(2); auto theta = b.floatConstant(0.123); - b.scfFor(0, 2, 1, {reg.value}, [&](Value iv, ValueRange iterArgs) { - auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); - auto q1 = b.rx(theta, q0); - auto insert = b.qtensorInsert(q1, t0, iv); - return SmallVector{insert}; - }); -}; + auto scfFor = + b.scfFor(0, 2, 1, {reg.value}, [&](Value iv, ValueRange iterArgs) { + auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); + auto q1 = b.rx(theta, q0); + auto insert = b.qtensorInsert(q1, t0, iv); + return SmallVector{insert}; + }); + return measureAndReturn(b, {scfFor[0]}); +} -void nestedForLoopIfOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopIfOp(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(2); auto q0 = b.allocQubit(); - b.scfFor(0, 2, 1, {reg.value, q0}, [&](Value iv, ValueRange iterArgs) { - auto q1 = b.h(iterArgs[1]); - auto [q2, cond] = b.measure(q1); - auto ifOp = b.qcoIf(cond, iterArgs[0], [&](ValueRange args) { - auto [t0, q3] = b.qtensorExtract(args[0], iv); - auto q4 = b.h(q3); - auto insert = b.qtensorInsert(q4, t0, iv); - return SmallVector{insert}; - }); - return SmallVector{ifOp[0], q2}; - }); + auto scfFor = + b.scfFor(0, 2, 1, {reg.value, q0}, [&](Value iv, ValueRange iterArgs) { + auto q1 = b.h(iterArgs[1]); + auto [q2, cond] = b.measure(q1); + auto ifOp = b.qcoIf(cond, iterArgs[0], [&](ValueRange args) { + auto [t0, q3] = b.qtensorExtract(args[0], iv); + auto q4 = b.h(q3); + auto insert = b.qtensorInsert(q4, t0, iv); + return SmallVector{insert}; + }); + return SmallVector{ifOp[0], q2}; + }); + return measureAndReturn(b, {scfFor[0], scfFor[1]}); } -void nestedForLoopWhileOp(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopWhileOp(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(2); auto loopResult = b.scfFor(0, 2, 1, {reg.value}, [&](Value iv, ValueRange iterArgs) { @@ -2456,61 +3610,72 @@ void nestedForLoopWhileOp(QCOProgramBuilder& b) { auto insert = b.qtensorInsert(q1, t0, iv); return SmallVector{insert}; }); - b.scfFor(0, 2, 1, loopResult, [&](Value iv, ValueRange iterArgs) { - auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); - auto whileResult = b.scfWhile( - q0, - [&](ValueRange iterArgs) { - auto [q1, measureResult] = b.measure(iterArgs[0]); - b.scfCondition(measureResult, q1); - return SmallVector{q1}; - }, - [&](ValueRange iterArgs) { - auto q2 = b.h(iterArgs[0]); - return SmallVector{q2}; - }); - auto insert = b.qtensorInsert(whileResult[0], t0, iv); - return SmallVector{insert}; - }); + auto scfFor = + b.scfFor(0, 2, 1, loopResult, [&](Value iv, ValueRange iterArgs) { + auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); + auto whileResult = b.scfWhile( + q0, + [&](ValueRange iterArgs) { + auto [q1, measureResult] = b.measure(iterArgs[0]); + b.scfCondition(measureResult, q1); + return SmallVector{q1}; + }, + [&](ValueRange iterArgs) { + auto q2 = b.h(iterArgs[0]); + return SmallVector{q2}; + }); + auto insert = b.qtensorInsert(whileResult[0], t0, iv); + return SmallVector{insert}; + }); + return measureAndReturn(b, {scfFor[0]}); } -void nestedForLoopCtrlOpWithSeparateQubit(QCOProgramBuilder& b) { +std::pair, SmallVector> +nestedForLoopCtrlOpWithSeparateQubit(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto control0 = b.allocQubit(); auto control1 = b.h(control0); - b.scfFor(0, 3, 1, {reg.value, control1}, [&](Value iv, ValueRange iterArgs) { - auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); - auto q1 = b.h(q0); - auto [controls, targets] = b.ctrl(iterArgs[1], q1, [&](ValueRange args) { - auto q2 = b.x(args[0]); - return SmallVector{q2}; - }); - auto insert = b.qtensorInsert(targets[0], t0, iv); - return SmallVector{insert, controls[0]}; - }); -} - -void nestedForLoopCtrlOpWithExtractedQubit(QCOProgramBuilder& b) { + auto scfFor = b.scfFor(0, 3, 1, {reg.value, control1}, + [&](Value iv, ValueRange iterArgs) { + auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); + auto q1 = b.h(q0); + auto [controls, targets] = + b.ctrl(iterArgs[1], q1, [&](ValueRange args) { + auto q2 = b.x(args[0]); + return SmallVector{q2}; + }); + auto insert = b.qtensorInsert(targets[0], t0, iv); + return SmallVector{insert, controls[0]}; + }); + return measureAndReturn(b, {scfFor[0], scfFor[1]}); +} + +std::pair, SmallVector> +nestedForLoopCtrlOpWithExtractedQubit(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(4); auto control = b.h(reg[0]); - b.scfFor(1, 4, 1, {reg.value, control}, [&](Value iv, ValueRange iterArgs) { - auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); - auto q1 = b.h(q0); - auto [controls, targets] = b.ctrl(iterArgs[1], q1, [&](ValueRange args) { - auto q2 = b.x(args[0]); - return SmallVector{q2}; - }); - auto insert = b.qtensorInsert(targets[0], t0, iv); - return SmallVector{insert, controls[0]}; - }); -} - -void nestedIfOpForLoop(QCOProgramBuilder& b) { + auto scfFor = b.scfFor(1, 4, 1, {reg.value, control}, + [&](Value iv, ValueRange iterArgs) { + auto [t0, q0] = b.qtensorExtract(iterArgs[0], iv); + auto q1 = b.h(q0); + auto [controls, targets] = + b.ctrl(iterArgs[1], q1, [&](ValueRange args) { + auto q2 = b.x(args[0]); + return SmallVector{q2}; + }); + auto insert = b.qtensorInsert(targets[0], t0, iv); + return SmallVector{insert, controls[0]}; + }); + return measureAndReturn(b, {scfFor[0], scfFor[1]}); +} + +std::pair, SmallVector> +nestedIfOpForLoop(QCOProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto q0 = b.allocQubit(); auto q1 = b.h(q0); auto [q2, cond] = b.measure(q1); - b.qcoIf( + auto ifRes = b.qcoIf( cond, {reg.value, q2}, [&](ValueRange args) { auto q3 = b.h(args[1]); @@ -2526,6 +3691,7 @@ void nestedIfOpForLoop(QCOProgramBuilder& b) { }); return SmallVector{scfFor[0], args[1]}; }); + return measureAndReturn(b, {ifRes[0], ifRes[1]}); } void nestedIfOpForLoopWithAngle(QCOProgramBuilder& b) { diff --git a/mlir/unittests/programs/qco_programs.h b/mlir/unittests/programs/qco_programs.h index 1a5f5ce229..16a77a16ae 100644 --- a/mlir/unittests/programs/qco_programs.h +++ b/mlir/unittests/programs/qco_programs.h @@ -10,1125 +10,1420 @@ #pragma once +#include +#include + +#include + namespace mlir::qco { class QCOProgramBuilder; /// Creates an empty QCO program. -void emptyQCO(QCOProgramBuilder& builder); +std::pair, SmallVector> +emptyQCO(QCOProgramBuilder& builder); // --- Qubit Management ----------------------------------------------------- // /// Allocates a single qubit. -void allocQubit(QCOProgramBuilder& b); +std::pair, SmallVector> +allocQubit(QCOProgramBuilder& b); + +/// Allocates a single qubit that is not measured. +std::pair, SmallVector> +allocQubitNoMeasure(QCOProgramBuilder& b); + +/// Allocates a qubit register of size `1`. +std::pair, SmallVector> +alloc1QubitRegister(QCOProgramBuilder& b); /// Allocates a qubit register of size `2`. -void allocQubitRegister(QCOProgramBuilder& b); +std::pair, SmallVector> +alloc2QubitRegister(QCOProgramBuilder& b); + +/// Allocates a qubit register of size `3`. +std::pair, SmallVector> +alloc3QubitRegister(QCOProgramBuilder& b); /// Allocates two qubit registers of size `2` and `3`. -void allocMultipleQubitRegisters(QCOProgramBuilder& b); +std::pair, SmallVector> +allocMultipleQubitRegisters(QCOProgramBuilder& b); /// Allocates a large qubit register. -void allocLargeRegister(QCOProgramBuilder& b); +std::pair, SmallVector> +allocLargeRegister(QCOProgramBuilder& b); /// Allocates two inline qubits. -void staticQubits(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubits(QCOProgramBuilder& b); + +/// Allocates two inline qubits without measuring them. +std::pair, SmallVector> +staticQubitsNoMeasure(QCOProgramBuilder& b); /// Allocates two static qubits and applies operations. -void staticQubitsWithOps(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithOps(QCOProgramBuilder& b); /// Allocates two static qubits and applies parametric gates. -void staticQubitsWithParametricOps(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithParametricOps(QCOProgramBuilder& b); /// Allocates two static qubits and applies a two-target gate. -void staticQubitsWithTwoTargetOps(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithTwoTargetOps(QCOProgramBuilder& b); /// Allocates two static qubits and applies a controlled gate. -void staticQubitsWithCtrl(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithCtrl(QCOProgramBuilder& b); /// Allocates a static qubit and applies an inverse modifier. -void staticQubitsWithInv(QCOProgramBuilder& b); +std::pair, SmallVector> +staticQubitsWithInv(QCOProgramBuilder& b); /// Allocates and explicitly sinks a single qubit. -void allocSinkPair(QCOProgramBuilder& b); +std::pair, SmallVector> +allocSinkPair(QCOProgramBuilder& b); // --- Invalid / mixed addressing (unit tests) -------------------------------- /// @pre `builder.initialize()`. Fatal mixed addressing: static then dynamic /// alloc. -void mixedStaticThenDynamicQubit(QCOProgramBuilder& b); +std::pair, SmallVector> +mixedStaticThenDynamicQubit(QCOProgramBuilder& b); /// @pre `builder.initialize()`. Fatal mixed addressing: `qtensor` alloc then /// static. -void mixedDynamicRegisterThenStaticQubit(QCOProgramBuilder& b); +std::pair, SmallVector> +mixedDynamicRegisterThenStaticQubit(QCOProgramBuilder& b); // --- MeasureOp ------------------------------------------------------------ // /// Measures a single qubit into a single classical bit. -void singleMeasurementToSingleBit(QCOProgramBuilder& b); +std::pair, SmallVector> +singleMeasurementToSingleBit(QCOProgramBuilder& b); /// Repeatedly measures a single qubit into the same classical bit. -void repeatedMeasurementToSameBit(QCOProgramBuilder& b); +std::pair, SmallVector> +repeatedMeasurementToSameBit(QCOProgramBuilder& b); /// Repeatedly measures a single qubit into different classical bits. -void repeatedMeasurementToDifferentBits(QCOProgramBuilder& b); +std::pair, SmallVector> +repeatedMeasurementToDifferentBits(QCOProgramBuilder& b); /// Measures multiple qubits into multiple classical bits. -void multipleClassicalRegistersAndMeasurements(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleClassicalRegistersAndMeasurements(QCOProgramBuilder& b); /// Measures a single qubit into a single classical bit, without explicitly /// allocating a quantum or classical register. -void measurementWithoutRegisters(QCOProgramBuilder& b); +std::pair, SmallVector> +measurementWithoutRegisters(QCOProgramBuilder& b); // --- ResetOp -------------------------------------------------------------- // /// Resets a single qubit without any operations being applied. -void resetQubitWithoutOp(QCOProgramBuilder& b); +std::pair, SmallVector> +resetQubitWithoutOp(QCOProgramBuilder& b); /// Resets multiple qubits without any operations being applied. -void resetMultipleQubitsWithoutOp(QCOProgramBuilder& b); +std::pair, SmallVector> +resetMultipleQubitsWithoutOp(QCOProgramBuilder& b); /// Repeatedly resets a single qubit without any operations being applied. -void repeatedResetWithoutOp(QCOProgramBuilder& b); +std::pair, SmallVector> +repeatedResetWithoutOp(QCOProgramBuilder& b); /// Resets a single qubit after a single operation. -void resetQubitAfterSingleOp(QCOProgramBuilder& b); +std::pair, SmallVector> +resetQubitAfterSingleOp(QCOProgramBuilder& b); /// Resets multiple qubits after a single operation. -void resetMultipleQubitsAfterSingleOp(QCOProgramBuilder& b); +std::pair, SmallVector> +resetMultipleQubitsAfterSingleOp(QCOProgramBuilder& b); /// Repeatedly resets a single qubit after a single operation. -void repeatedResetAfterSingleOp(QCOProgramBuilder& b); +std::pair, SmallVector> +repeatedResetAfterSingleOp(QCOProgramBuilder& b); // --- GPhaseOp ------------------------------------------------------------- // /// Creates a circuit with just a global phase. -void globalPhase(QCOProgramBuilder& b); +std::pair, SmallVector> +globalPhase(QCOProgramBuilder& b); /// Creates a controlled global phase gate with a single control qubit. -void singleControlledGlobalPhase(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledGlobalPhase(QCOProgramBuilder& b); /// Creates a multi-controlled global phase gate with multiple control qubits. -void multipleControlledGlobalPhase(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledGlobalPhase(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a global phase gate. -void inverseGlobalPhase(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseGlobalPhase(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled global /// phase gate. -void inverseMultipleControlledGlobalPhase(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledGlobalPhase(QCOProgramBuilder& b); // --- IdOp ----------------------------------------------------------------- // /// Creates a circuit with just an identity gate. -void identity(QCOProgramBuilder& b); +std::pair, SmallVector> identity(QCOProgramBuilder& b); /// Creates a controlled identity gate with a single control qubit. -void singleControlledIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledIdentity(QCOProgramBuilder& b); /// Creates a multi-controlled identity gate with multiple control qubits. -void multipleControlledIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledIdentity(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled identity gate. -void nestedControlledIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledIdentity(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled identity gate. -void trivialControlledIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledIdentity(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an identity gate. -void inverseIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseIdentity(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled identity /// gate. -void inverseMultipleControlledIdentity(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledIdentity(QCOProgramBuilder& b); // --- XOp ------------------------------------------------------------------ // /// Creates a circuit with just an X gate. -void x(QCOProgramBuilder& b); +std::pair, SmallVector> x(QCOProgramBuilder& b); /// Creates a circuit with a single controlled X gate. -void singleControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledX(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled X gate. -void multipleControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledX(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled X gate. -void nestedControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledX(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled X gate. -void trivialControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledX(QCOProgramBuilder& b); /// Creates a circuit with repeated controlled X gates. -void repeatedControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +repeatedControlledX(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an X gate. -void inverseX(QCOProgramBuilder& b); +std::pair, SmallVector> inverseX(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled X gate. -void inverseMultipleControlledX(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledX(QCOProgramBuilder& b); /// Creates a circuit with two subsequent X gates. -void twoX(QCOProgramBuilder& b); +std::pair, SmallVector> twoX(QCOProgramBuilder& b); /// Creates a circuit with a control modifier applied to two subsequent X gates. -void controlledTwoX(QCOProgramBuilder& b); +std::pair, SmallVector> +controlledTwoX(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to two subsequent X /// gates. -void inverseTwoX(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseTwoX(QCOProgramBuilder& b); // --- YOp ------------------------------------------------------------------ // /// Creates a circuit with just a Y gate. -void y(QCOProgramBuilder& b); +std::pair, SmallVector> y(QCOProgramBuilder& b); /// Creates a circuit with a single controlled Y gate. -void singleControlledY(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledY(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled Y gate. -void multipleControlledY(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledY(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled Y gate. -void nestedControlledY(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledY(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled Y gate. -void trivialControlledY(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Y gate. -void inverseY(QCOProgramBuilder& b); +std::pair, SmallVector> inverseY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Y gate. -void inverseMultipleControlledY(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledY(QCOProgramBuilder& b); /// Creates a circuit with two Y gates in a row. -void twoY(QCOProgramBuilder& b); +std::pair, SmallVector> twoY(QCOProgramBuilder& b); // --- ZOp ------------------------------------------------------------------ // /// Creates a circuit with just a Z gate. -void z(QCOProgramBuilder& b); +std::pair, SmallVector> z(QCOProgramBuilder& b); /// Creates a circuit with a single controlled Z gate. -void singleControlledZ(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledZ(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled Z gate. -void multipleControlledZ(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledZ(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled Z gate. -void nestedControlledZ(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledZ(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled Z gate. -void trivialControlledZ(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledZ(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Z gate. -void inverseZ(QCOProgramBuilder& b); +std::pair, SmallVector> inverseZ(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Z gate. -void inverseMultipleControlledZ(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledZ(QCOProgramBuilder& b); /// Creates a circuit with two Z gates in a row. -void twoZ(QCOProgramBuilder& b); +std::pair, SmallVector> twoZ(QCOProgramBuilder& b); // --- HOp ------------------------------------------------------------------ // /// Creates a circuit with just an H gate. -void h(QCOProgramBuilder& b); +std::pair, SmallVector> h(QCOProgramBuilder& b); /// Creates a circuit with a single controlled H gate. -void singleControlledH(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledH(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled H gate. -void multipleControlledH(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledH(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled H gate. -void nestedControlledH(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledH(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled H gate. -void trivialControlledH(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledH(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an H gate. -void inverseH(QCOProgramBuilder& b); +std::pair, SmallVector> inverseH(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled H gate. -void inverseMultipleControlledH(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledH(QCOProgramBuilder& b); /// Creates a circuit with two H gates in a row. -void twoH(QCOProgramBuilder& b); +std::pair, SmallVector> twoH(QCOProgramBuilder& b); /// Creates a circuit with just an H gate and no qubit register. -void hWithoutRegister(QCOProgramBuilder& b); +std::pair, SmallVector> +hWithoutRegister(QCOProgramBuilder& b); // --- SOp ------------------------------------------------------------------ // /// Creates a circuit with just an S gate. -void s(QCOProgramBuilder& b); +std::pair, SmallVector> s(QCOProgramBuilder& b); /// Creates a circuit with a single controlled S gate. -void singleControlledS(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledS(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled S gate. -void multipleControlledS(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledS(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled S gate. -void nestedControlledS(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledS(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled S gate. -void trivialControlledS(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledS(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an S gate. -void inverseS(QCOProgramBuilder& b); +std::pair, SmallVector> inverseS(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled S gate. -void inverseMultipleControlledS(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledS(QCOProgramBuilder& b); /// Creates a circuit with an S gate followed by an Sdg gate. -void sThenSdg(QCOProgramBuilder& b); +std::pair, SmallVector> sThenSdg(QCOProgramBuilder& b); /// Creates a circuit with two S gates in a row. -void twoS(QCOProgramBuilder& b); +std::pair, SmallVector> twoS(QCOProgramBuilder& b); // --- SdgOp ---------------------------------------------------------------- // /// Creates a circuit with just an Sdg gate. -void sdg(QCOProgramBuilder& b); +std::pair, SmallVector> sdg(QCOProgramBuilder& b); /// Creates a circuit with a single controlled Sdg gate. -void singleControlledSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledSdg(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled Sdg gate. -void multipleControlledSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSdg(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled Sdg gate. -void nestedControlledSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSdg(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled Sdg gate. -void trivialControlledSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an Sdg gate. -void inverseSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseSdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Sdg gate. -void inverseMultipleControlledSdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSdg(QCOProgramBuilder& b); /// Creates a circuit with an Sdg gate followed an S gate. -void sdgThenS(QCOProgramBuilder& b); +std::pair, SmallVector> sdgThenS(QCOProgramBuilder& b); /// Creates a circuit with two Sdg gates in a row. -void twoSdg(QCOProgramBuilder& b); +std::pair, SmallVector> twoSdg(QCOProgramBuilder& b); // --- TOp ------------------------------------------------------------------ // /// Creates a circuit with just a T gate. -void t_(QCOProgramBuilder& b); // NOLINT(*-identifier-naming) +std::pair, SmallVector> +t_(QCOProgramBuilder& b); // NOLINT(*-identifier-naming) /// Creates a circuit with a single controlled T gate. -void singleControlledT(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledT(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled T gate. -void multipleControlledT(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledT(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled T gate. -void nestedControlledT(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledT(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled T gate. -void trivialControlledT(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledT(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a T gate. -void inverseT(QCOProgramBuilder& b); +std::pair, SmallVector> inverseT(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled T gate. -void inverseMultipleControlledT(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledT(QCOProgramBuilder& b); /// Creates a circuit with a T gate followed by a Tdg gate. -void tThenTdg(QCOProgramBuilder& b); +std::pair, SmallVector> tThenTdg(QCOProgramBuilder& b); /// Creates a circuit with two T gates in a row. -void twoT(QCOProgramBuilder& b); +std::pair, SmallVector> twoT(QCOProgramBuilder& b); // --- TdgOp ---------------------------------------------------------------- // /// Creates a circuit with just a Tdg gate. -void tdg(QCOProgramBuilder& b); +std::pair, SmallVector> tdg(QCOProgramBuilder& b); /// Creates a circuit with a single controlled Tdg gate. -void singleControlledTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledTdg(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled Tdg gate. -void multipleControlledTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledTdg(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled Tdg gate. -void nestedControlledTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledTdg(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled Tdg gate. -void trivialControlledTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledTdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a Tdg gate. -void inverseTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseTdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled Tdg gate. -void inverseMultipleControlledTdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledTdg(QCOProgramBuilder& b); /// Creates a circuit with a Tdg gate followed by a T gate. -void tdgThenT(QCOProgramBuilder& b); +std::pair, SmallVector> tdgThenT(QCOProgramBuilder& b); /// Creates a circuit with two Tdg gates in a row. -void twoTdg(QCOProgramBuilder& b); +std::pair, SmallVector> twoTdg(QCOProgramBuilder& b); // --- SXOp ----------------------------------------------------------------- // /// Creates a circuit with just an SX gate. -void sx(QCOProgramBuilder& b); +std::pair, SmallVector> sx(QCOProgramBuilder& b); /// Creates a circuit with a single controlled SX gate. -void singleControlledSx(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledSx(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled SX gate. -void multipleControlledSx(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSx(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled SX gate. -void nestedControlledSx(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSx(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled SX gate. -void trivialControlledSx(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an SX gate. -void inverseSx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseSx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SX gate. -void inverseMultipleControlledSx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSx(QCOProgramBuilder& b); /// Creates a circuit with an SX gate followed by an SXdg gate. -void sxThenSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +sxThenSxdg(QCOProgramBuilder& b); /// Creates a circuit with two SX gates in a row. -void twoSx(QCOProgramBuilder& b); +std::pair, SmallVector> twoSx(QCOProgramBuilder& b); // --- SXdgOp --------------------------------------------------------------- // /// Creates a circuit with just an SXdg gate. -void sxdg(QCOProgramBuilder& b); +std::pair, SmallVector> sxdg(QCOProgramBuilder& b); /// Creates a circuit with a single controlled SXdg gate. -void singleControlledSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledSxdg(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled SXdg gate. -void multipleControlledSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSxdg(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled SXdg gate. -void nestedControlledSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSxdg(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled SXdg gate. -void trivialControlledSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSxdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an SXdg gate. -void inverseSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseSxdg(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SXdg /// gate. -void inverseMultipleControlledSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSxdg(QCOProgramBuilder& b); /// Creates a circuit with an SXdg gate followed by an SX gate. -void sxdgThenSx(QCOProgramBuilder& b); +std::pair, SmallVector> +sxdgThenSx(QCOProgramBuilder& b); /// Creates a circuit with two SXdg gates in a row. -void twoSxdg(QCOProgramBuilder& b); +std::pair, SmallVector> twoSxdg(QCOProgramBuilder& b); // --- RXOp ----------------------------------------------------------------- // /// Creates a circuit with just an RX gate. -void rx(QCOProgramBuilder& b); +std::pair, SmallVector> rx(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RX gate. -void singleControlledRx(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRx(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RX gate. -void multipleControlledRx(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRx(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RX gate. -void nestedControlledRx(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRx(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RX gate. -void trivialControlledRx(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RX gate. -void inverseRx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RX gate. -void inverseMultipleControlledRx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRx(QCOProgramBuilder& b); /// Creates a circuit with two RX gates in a row with opposite phases. -void twoRxOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRxOppositePhase(QCOProgramBuilder& b); /// Creates a circuit with an RX gate with an angle of pi/2. -void rxPiOver2(QCOProgramBuilder& b); +std::pair, SmallVector> +rxPiOver2(QCOProgramBuilder& b); // --- RYOp ----------------------------------------------------------------- // /// Creates a circuit with just an RY gate. -void ry(QCOProgramBuilder& b); +std::pair, SmallVector> ry(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RY gate. -void singleControlledRy(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRy(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RY gate. -void multipleControlledRy(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRy(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RY gate. -void nestedControlledRy(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRy(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RY gate. -void trivialControlledRy(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRy(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RY gate. -void inverseRy(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRy(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RY gate. -void inverseMultipleControlledRy(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRy(QCOProgramBuilder& b); /// Creates a circuit with two RY gates in a row with opposite phases. -void twoRyOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRyOppositePhase(QCOProgramBuilder& b); /// Creates a circuit with an RY gate with an angle of pi/2. -void ryPiOver2(QCOProgramBuilder& b); +std::pair, SmallVector> +ryPiOver2(QCOProgramBuilder& b); // --- RZOp ----------------------------------------------------------------- // /// Creates a circuit with just an RZ gate. -void rz(QCOProgramBuilder& b); +std::pair, SmallVector> rz(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RZ gate. -void singleControlledRz(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRz(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RZ gate. -void multipleControlledRz(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRz(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RZ gate. -void nestedControlledRz(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRz(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RZ gate. -void trivialControlledRz(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRz(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZ gate. -void inverseRz(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRz(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZ gate. -void inverseMultipleControlledRz(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRz(QCOProgramBuilder& b); /// Creates a circuit with two RZ gates in a row with opposite phases. -void twoRzOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRzOppositePhase(QCOProgramBuilder& b); // --- POp ------------------------------------------------------------------ // /// Creates a circuit with just a P gate. -void p(QCOProgramBuilder& b); +std::pair, SmallVector> p(QCOProgramBuilder& b); /// Creates a circuit with a single controlled P gate. -void singleControlledP(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledP(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled P gate. -void multipleControlledP(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledP(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled P gate. -void nestedControlledP(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledP(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled P gate. -void trivialControlledP(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledP(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a P gate. -void inverseP(QCOProgramBuilder& b); +std::pair, SmallVector> inverseP(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled P gate. -void inverseMultipleControlledP(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledP(QCOProgramBuilder& b); /// Creates a circuit with two P gates in a row with opposite phases. -void twoPOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoPOppositePhase(QCOProgramBuilder& b); // --- ROp ------------------------------------------------------------------ // /// Creates a circuit with just an R gate. -void r(QCOProgramBuilder& b); +std::pair, SmallVector> r(QCOProgramBuilder& b); /// Creates a circuit with a single controlled R gate. -void singleControlledR(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledR(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled R gate. -void multipleControlledR(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledR(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled R gate. -void nestedControlledR(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledR(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled R gate. -void trivialControlledR(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledR(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an R gate. -void inverseR(QCOProgramBuilder& b); +std::pair, SmallVector> inverseR(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled R gate. -void inverseMultipleControlledR(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledR(QCOProgramBuilder& b); /// Creates a circuit with an R gate that can be canonicalized to an RX gate. -void canonicalizeRToRx(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeRToRx(QCOProgramBuilder& b); /// Creates a circuit with an R gate that can be canonicalized to an RY gate. -void canonicalizeRToRy(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeRToRy(QCOProgramBuilder& b); // --- U2Op ----------------------------------------------------------------- // /// Creates a circuit with just a U2 gate. -void u2(QCOProgramBuilder& b); +std::pair, SmallVector> u2(QCOProgramBuilder& b); /// Creates a circuit with a single controlled U2 gate. -void singleControlledU2(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledU2(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled U2 gate. -void multipleControlledU2(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledU2(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled U2 gate. -void nestedControlledU2(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledU2(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled U2 gate. -void trivialControlledU2(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledU2(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a U2 gate. -void inverseU2(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseU2(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled U2 gate. -void inverseMultipleControlledU2(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledU2(QCOProgramBuilder& b); /// Creates a circuit with a U2 gate that can be canonicalized to an H gate. -void canonicalizeU2ToH(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeU2ToH(QCOProgramBuilder& b); /// Creates a circuit with a U2 gate that can be canonicalized to an RX gate. -void canonicalizeU2ToRx(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeU2ToRx(QCOProgramBuilder& b); /// Creates a circuit with a U2 gate that can be canonicalized to an RY gate. -void canonicalizeU2ToRy(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeU2ToRy(QCOProgramBuilder& b); // --- UOp ------------------------------------------------------------------ // /// Creates a circuit with just a U gate. -void u(QCOProgramBuilder& b); +std::pair, SmallVector> u(QCOProgramBuilder& b); /// Creates a circuit with a single controlled U gate. -void singleControlledU(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledU(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled U gate. -void multipleControlledU(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledU(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled U gate. -void nestedControlledU(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledU(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled U gate. -void trivialControlledU(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledU(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a U gate. -void inverseU(QCOProgramBuilder& b); +std::pair, SmallVector> inverseU(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled U gate. -void inverseMultipleControlledU(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledU(QCOProgramBuilder& b); /// Creates a circuit with a U gate that can be canonicalized to a P gate. -void canonicalizeUToP(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeUToP(QCOProgramBuilder& b); /// Creates a circuit with a U gate that can be canonicalized to an RX gate. -void canonicalizeUToRx(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeUToRx(QCOProgramBuilder& b); /// Creates a circuit with a U gate that can be canonicalized to an RY gate. -void canonicalizeUToRy(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeUToRy(QCOProgramBuilder& b); /// Creates a circuit with a U gate that can be canonicalized to a U2 gate. -void canonicalizeUToU2(QCOProgramBuilder& b); +std::pair, SmallVector> +canonicalizeUToU2(QCOProgramBuilder& b); // --- SWAPOp --------------------------------------------------------------- // /// Creates a circuit with just a SWAP gate. -void swap(QCOProgramBuilder& b); +std::pair, SmallVector> swap(QCOProgramBuilder& b); /// Creates a circuit with a single controlled SWAP gate. -void singleControlledSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledSwap(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled SWAP gate. -void multipleControlledSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledSwap(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled SWAP gate. -void nestedControlledSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledSwap(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled SWAP gate. -void trivialControlledSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledSwap(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a SWAP gate. -void inverseSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseSwap(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled SWAP /// gate. -void inverseMultipleControlledSwap(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledSwap(QCOProgramBuilder& b); /// Creates a circuit with two SWAP gates in a row. -void twoSwap(QCOProgramBuilder& b); +std::pair, SmallVector> twoSwap(QCOProgramBuilder& b); /// Creates a circuit with two SWAP gates in a row with swapped targets. -void twoSwapSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoSwapSwappedTargets(QCOProgramBuilder& b); // --- iSWAPOp -------------------------------------------------------------- // /// Creates a circuit with just an iSWAP gate. -void iswap(QCOProgramBuilder& b); +std::pair, SmallVector> iswap(QCOProgramBuilder& b); /// Creates a circuit with a single controlled iSWAP gate. -void singleControlledIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledIswap(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled iSWAP gate. -void multipleControlledIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledIswap(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled iSWAP gate. -void nestedControlledIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledIswap(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled iSWAP gate. -void trivialControlledIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledIswap(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an iSWAP gate. -void inverseIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseIswap(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled iSWAP /// gate. -void inverseMultipleControlledIswap(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledIswap(QCOProgramBuilder& b); // --- DCXOp ---------------------------------------------------------------- // /// Creates a circuit with just a DCX gate. -void dcx(QCOProgramBuilder& b); +std::pair, SmallVector> dcx(QCOProgramBuilder& b); /// Creates a circuit with a single controlled DCX gate. -void singleControlledDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledDcx(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled DCX gate. -void multipleControlledDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledDcx(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled DCX gate. -void nestedControlledDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledDcx(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled DCX gate. -void trivialControlledDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledDcx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a DCX gate. -void inverseDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseDcx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled DCX gate. -void inverseMultipleControlledDcx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledDcx(QCOProgramBuilder& b); /// Creates a circuit with two DCX gates in a row with identical targets. -void twoDcx(QCOProgramBuilder& b); +std::pair, SmallVector> twoDcx(QCOProgramBuilder& b); /// Creates a circuit with two DCX gates in a row with swapped targets. -void twoDcxSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoDcxSwappedTargets(QCOProgramBuilder& b); // --- ECROp ---------------------------------------------------------------- // /// Creates a circuit with just an ECR gate. -void ecr(QCOProgramBuilder& b); +std::pair, SmallVector> ecr(QCOProgramBuilder& b); /// Creates a circuit with a single controlled ECR gate. -void singleControlledEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledEcr(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled ECR gate. -void multipleControlledEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledEcr(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled ECR gate. -void nestedControlledEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledEcr(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled ECR gate. -void trivialControlledEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledEcr(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an ECR gate. -void inverseEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseEcr(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled ECR gate. -void inverseMultipleControlledEcr(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledEcr(QCOProgramBuilder& b); /// Creates a circuit with two ECR gates in a row. -void twoEcr(QCOProgramBuilder& b); +std::pair, SmallVector> twoEcr(QCOProgramBuilder& b); // --- RXXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RXX gate. -void rxx(QCOProgramBuilder& b); +std::pair, SmallVector> rxx(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RXX gate. -void singleControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RXX gate. -void multipleControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RXX gate. -void nestedControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RXX gate. -void trivialControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RXX gate. -void inverseRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRxx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RXX gate. -void inverseMultipleControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with a triple-controlled RXX gate. -void tripleControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +tripleControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with a four-controlled RXX gate. -void fourControlledRxx(QCOProgramBuilder& b); +std::pair, SmallVector> +fourControlledRxx(QCOProgramBuilder& b); /// Creates a circuit with two RXX gates in a row. -void twoRxx(QCOProgramBuilder& b); +std::pair, SmallVector> twoRxx(QCOProgramBuilder& b); /// Creates a circuit with two RXX gates in a row with swapped targets. -void twoRxxSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRxxSwappedTargets(QCOProgramBuilder& b); /// Creates a circuit with two RXX gates in a row with opposite phases. -void twoRxxOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRxxOppositePhase(QCOProgramBuilder& b); /// Creates a circuit with two RXX gates in a row with opposite phases and /// swapped targets. -void twoRxxOppositePhaseSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRxxOppositePhaseSwappedTargets(QCOProgramBuilder& b); // --- RYYOp ---------------------------------------------------------------- // /// Creates a circuit with just an RYY gate. -void ryy(QCOProgramBuilder& b); +std::pair, SmallVector> ryy(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RYY gate. -void singleControlledRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRyy(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RYY gate. -void multipleControlledRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRyy(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RYY gate. -void nestedControlledRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRyy(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RYY gate. -void trivialControlledRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRyy(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RYY gate. -void inverseRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRyy(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RYY gate. -void inverseMultipleControlledRyy(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRyy(QCOProgramBuilder& b); /// Creates a circuit with two RYY gates in a row. -void twoRyy(QCOProgramBuilder& b); +std::pair, SmallVector> twoRyy(QCOProgramBuilder& b); /// Creates a circuit with two RYY gates in a row with swapped targets. -void twoRyySwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRyySwappedTargets(QCOProgramBuilder& b); /// Creates a circuit with two RYY gates in a row with opposite phases. -void twoRyyOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRyyOppositePhase(QCOProgramBuilder& b); /// Creates a circuit with two RYY gates in a row with opposite phases and /// swapped targets. -void twoRyyOppositePhaseSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRyyOppositePhaseSwappedTargets(QCOProgramBuilder& b); // --- RZXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZX gate. -void rzx(QCOProgramBuilder& b); +std::pair, SmallVector> rzx(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RZX gate. -void singleControlledRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRzx(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RZX gate. -void multipleControlledRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRzx(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RZX gate. -void nestedControlledRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRzx(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RZX gate. -void trivialControlledRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRzx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZX gate. -void inverseRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRzx(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZX gate. -void inverseMultipleControlledRzx(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRzx(QCOProgramBuilder& b); /// Creates a circuit with two RZX gates in a row with opposite phases. -void twoRzxOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRzxOppositePhase(QCOProgramBuilder& b); // --- RZZOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZZ gate. -void rzz(QCOProgramBuilder& b); +std::pair, SmallVector> rzz(QCOProgramBuilder& b); /// Creates a circuit with a single controlled RZZ gate. -void singleControlledRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledRzz(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled RZZ gate. -void multipleControlledRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledRzz(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled RZZ gate. -void nestedControlledRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledRzz(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled RZZ gate. -void trivialControlledRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledRzz(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an RZZ gate. -void inverseRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseRzz(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled RZZ gate. -void inverseMultipleControlledRzz(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledRzz(QCOProgramBuilder& b); /// Creates a circuit with two RZZ gates in a row. -void twoRzz(QCOProgramBuilder& b); +std::pair, SmallVector> twoRzz(QCOProgramBuilder& b); /// Creates a circuit with two RZZ gates in a row with swapped targets. -void twoRzzSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRzzSwappedTargets(QCOProgramBuilder& b); /// Creates a circuit with two RZZ gates in a row with opposite phases. -void twoRzzOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRzzOppositePhase(QCOProgramBuilder& b); /// Creates a circuit with two RZZ gates in a row with opposite phases and /// swapped targets. -void twoRzzOppositePhaseSwappedTargets(QCOProgramBuilder& b); +std::pair, SmallVector> +twoRzzOppositePhaseSwappedTargets(QCOProgramBuilder& b); // --- XXPlusYYOp ----------------------------------------------------------- // /// Creates a circuit with just an XXPlusYY gate. -void xxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> xxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with a single controlled XXPlusYY gate. -void singleControlledXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled XXPlusYY gate. -void multipleControlledXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled XXPlusYY gate. -void nestedControlledXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled XXPlusYY gate. -void trivialControlledXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an XXPlusYY gate. -void inverseXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled XXPlusYY /// gate. -void inverseMultipleControlledXxPlusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledXxPlusYY(QCOProgramBuilder& b); /// Creates a circuit with two XXPlusYY gates in a row with opposite phases. -void twoXxPlusYYOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoXxPlusYYOppositePhase(QCOProgramBuilder& b); // --- XXMinusYYOp ---------------------------------------------------------- // /// Creates a circuit with just an XXMinusYY gate. -void xxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +xxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with a single controlled XXMinusYY gate. -void singleControlledXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with a multi-controlled XXMinusYY gate. -void multipleControlledXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +multipleControlledXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with a nested controlled XXMinusYY gate. -void nestedControlledXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedControlledXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with a trivial controlled XXMinusYY gate. -void trivialControlledXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialControlledXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to an XXMinusYY gate. -void inverseXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a controlled XXMinusYY /// gate. -void inverseMultipleControlledXxMinusYY(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseMultipleControlledXxMinusYY(QCOProgramBuilder& b); /// Creates a circuit with two XXMinusYY gates in a row with opposite phases. -void twoXxMinusYYOppositePhase(QCOProgramBuilder& b); +std::pair, SmallVector> +twoXxMinusYYOppositePhase(QCOProgramBuilder& b); // --- BarrierOp ------------------------------------------------------------ // /// Creates a circuit with a barrier. -void barrier(QCOProgramBuilder& b); +std::pair, SmallVector> barrier(QCOProgramBuilder& b); /// Creates a circuit with a barrier on two qubits. -void barrierTwoQubits(QCOProgramBuilder& b); +std::pair, SmallVector> +barrierTwoQubits(QCOProgramBuilder& b); /// Creates a circuit with a barrier on multiple qubits. -void barrierMultipleQubits(QCOProgramBuilder& b); +std::pair, SmallVector> +barrierMultipleQubits(QCOProgramBuilder& b); /// Creates a circuit with a single controlled barrier. -void singleControlledBarrier(QCOProgramBuilder& b); +std::pair, SmallVector> +singleControlledBarrier(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a barrier. -void inverseBarrier(QCOProgramBuilder& b); +std::pair, SmallVector> +inverseBarrier(QCOProgramBuilder& b); /// Creates a circuit with two barriers in a row with overlapping qubits. -void twoBarrier(QCOProgramBuilder& b); +std::pair, SmallVector> +twoBarrier(QCOProgramBuilder& b); // --- CtrlOp --------------------------------------------------------------- // /// Creates a circuit with a trivial ctrl modifier. -void trivialCtrl(QCOProgramBuilder& b); +std::pair, SmallVector> +trivialCtrl(QCOProgramBuilder& b); /// Creates a circuit with an empty ctrl modifier. -void emptyCtrl(QCOProgramBuilder& b); +std::pair, SmallVector> +emptyCtrl(QCOProgramBuilder& b); /// Creates a circuit with nested ctrl modifiers. -void nestedCtrl(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedCtrl(QCOProgramBuilder& b); /// Creates a circuit with triple nested ctrl modifiers. -void tripleNestedCtrl(QCOProgramBuilder& b); +std::pair, SmallVector> +tripleNestedCtrl(QCOProgramBuilder& b); /// Creates a circuit with double nested ctrl modifiers with two qubits each. -void doubleNestedCtrlTwoQubits(QCOProgramBuilder& b); +std::pair, SmallVector> +doubleNestedCtrlTwoQubits(QCOProgramBuilder& b); /// Creates a circuit with control modifiers interleaved by an inverse modifier. -void ctrlInvSandwich(QCOProgramBuilder& b); +std::pair, SmallVector> +ctrlInvSandwich(QCOProgramBuilder& b); /// Creates a circuit with a control modifier applied to two gates. -void ctrlTwo(QCOProgramBuilder& b); +std::pair, SmallVector> ctrlTwo(QCOProgramBuilder& b); /// Creates a circuit with a control modifier applied to a controlled and a /// non-controlled gate. -void ctrlTwoMixed(QCOProgramBuilder& b); +std::pair, SmallVector> +ctrlTwoMixed(QCOProgramBuilder& b); /// Creates a circuit with nested control modifiers applied to two gates. -void nestedCtrlTwo(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedCtrlTwo(QCOProgramBuilder& b); /// Creates a circuit with a control modifier applied to an inverse modifier /// applied to two gates. -void ctrlInvTwo(QCOProgramBuilder& b); +std::pair, SmallVector> +ctrlInvTwo(QCOProgramBuilder& b); // --- InvOp ---------------------------------------------------------------- // /// Creates a circuit with an empty inverse modifier. -void emptyInv(QCOProgramBuilder& b); +std::pair, SmallVector> emptyInv(QCOProgramBuilder& b); /// Creates a circuit with nested inverse modifiers. -void nestedInv(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedInv(QCOProgramBuilder& b); /// Creates a circuit with triple nested inverse modifiers. -void tripleNestedInv(QCOProgramBuilder& b); +std::pair, SmallVector> +tripleNestedInv(QCOProgramBuilder& b); /// Creates a circuit with inverse modifiers interleaved by a control modifier. -void invCtrlSandwich(QCOProgramBuilder& b); +std::pair, SmallVector> +invCtrlSandwich(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to two gates. -void invTwo(QCOProgramBuilder& b); +std::pair, SmallVector> invTwo(QCOProgramBuilder& b); /// Creates a circuit with an inverse modifier applied to a control modifier /// applied to two gates. -void invCtrlTwo(QCOProgramBuilder& b); +std::pair, SmallVector> +invCtrlTwo(QCOProgramBuilder& b); // --- IfOp ---------------------------------------------------------------- // /// Creates a circuit with a simple if operation with one qubit. -void simpleIf(QCOProgramBuilder& b); +std::pair, SmallVector> simpleIf(QCOProgramBuilder& b); /// Creates a circuit with an if operation with a parameterized gate. -void ifWithAngle(QCOProgramBuilder& b); +std::pair, SmallVector> +ifWithAngle(QCOProgramBuilder& b); /// Creates a circuit with an if operation with two qubits. -void ifTwoQubits(QCOProgramBuilder& b); +std::pair, SmallVector> +ifTwoQubits(QCOProgramBuilder& b); /// Creates a circuit with an if operation with an else branch. -void ifElse(QCOProgramBuilder& b); +std::pair, SmallVector> ifElse(QCOProgramBuilder& b); /// Creates a circuit with an if operation with one qubit and one register. -void ifOneQubitOneTensor(QCOProgramBuilder& b); +std::pair, SmallVector> +ifOneQubitOneTensor(QCOProgramBuilder& b); /// Creates a circuit with an if operation that uses a constant true as /// condition. -void constantTrueIf(QCOProgramBuilder& b); +std::pair, SmallVector> +constantTrueIf(QCOProgramBuilder& b); /// Creates a circuit with an if operation that uses a constant false as /// condition. -void constantFalseIf(QCOProgramBuilder& b); +std::pair, SmallVector> +constantFalseIf(QCOProgramBuilder& b); /// Creates a circuit with a nested if operation in the then branch that uses /// the same condition. -void nestedTrueIf(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedTrueIf(QCOProgramBuilder& b); /// Creates a circuit with a nested if operation in the else branch that uses /// the same condition. -void nestedFalseIf(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedFalseIf(QCOProgramBuilder& b); /// Creates a circuit with an if operation with a nested for operation with /// a register. -void nestedIfOpForLoop(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedIfOpForLoop(QCOProgramBuilder& b); /// Creates a circuit with an if operation with a nested for operation and /// parameterized gates. -void nestedIfOpForLoopWithAngle(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedIfOpForLoopWithAngle(QCOProgramBuilder& b); // --- WhileOp -------------------------------------------------------------- // /// Creates a circuit with a while operation using a while loop. -void simpleWhileReset(QCOProgramBuilder& b); +std::pair, SmallVector> +simpleWhileReset(QCOProgramBuilder& b); /// Creates a circuit with a while operation using a do-while loop. -void simpleDoWhileReset(QCOProgramBuilder& b); +std::pair, SmallVector> +simpleDoWhileReset(QCOProgramBuilder& b); // --- ForOp ---------------------------------------------------------------- // /// Creates a circuit with a simple for operation with a register. -void simpleForLoop(QCOProgramBuilder& b); +std::pair, SmallVector> +simpleForLoop(QCOProgramBuilder& b); /// Creates a circuit with a for operation with a parameterized gate. -void forLoopWithAngle(QCOProgramBuilder& b); +std::pair, SmallVector> +forLoopWithAngle(QCOProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested if operation. -void nestedForLoopIfOp(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopIfOp(QCOProgramBuilder& b); /// Creates a circuit with a for operation with a register and a nested while /// operation. -void nestedForLoopWhileOp(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopWhileOp(QCOProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is separately allocated from the /// register. -void nestedForLoopCtrlOpWithSeparateQubit(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopCtrlOpWithSeparateQubit(QCOProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is extracted from the register. -void nestedForLoopCtrlOpWithExtractedQubit(QCOProgramBuilder& b); +std::pair, SmallVector> +nestedForLoopCtrlOpWithExtractedQubit(QCOProgramBuilder& b); // --- QTensor Operations -------------------------------------------------- // /// Allocates a tensor of size `3`. -void qtensorAlloc(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorAlloc(QCOProgramBuilder& b); /// Allocates and explicitly deallocates a tensor. -void qtensorDealloc(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorDealloc(QCOProgramBuilder& b); /// Constructs a tensor with from_elements. -void qtensorFromElements(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorFromElements(QCOProgramBuilder& b); /// Extracts a qubit from a tensor. -void qtensorExtract(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorExtract(QCOProgramBuilder& b); /// Inserts a qubit into a tensor. -void qtensorInsert(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorInsert(QCOProgramBuilder& b); /// Extracts a qubit from a tensor and inserts it immediately at a different /// index. -void qtensorExtractInsertIndexMismatch(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorExtractInsertIndexMismatch(QCOProgramBuilder& b); /// Extracts a qubit from a tensor and inserts it immediately at the same index. -void qtensorExtractInsertSameIndex(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorExtractInsertSameIndex(QCOProgramBuilder& b); /// Inserts a qubit into a tensor and extracts it immediately at a different /// index. -void qtensorInsertExtractIndexMismatch(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorInsertExtractIndexMismatch(QCOProgramBuilder& b); /// Inserts a qubit into a tensor and extracts it immediately at the same index. -void qtensorInsertExtractSameIndex(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorInsertExtractSameIndex(QCOProgramBuilder& b); /// Extracts three qubits with ascending index (0, 1, 2), performs a /// computation, and finally inserts the qubits in ascending order (0, 1, 2). -void qtensorChain(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorChain(QCOProgramBuilder& b); /// Performs the same computation as the `qtensorChain` function, but uses /// qubits immediately after the extract and inserts the qubits in descending /// order (2, 1, 0). -void qtensorAlternativeChain(QCOProgramBuilder& b); +std::pair, SmallVector> +qtensorAlternativeChain(QCOProgramBuilder& b); } // namespace mlir::qco diff --git a/mlir/unittests/programs/qir_programs.cpp b/mlir/unittests/programs/qir_programs.cpp index 948a74b889..8fb5b513e3 100644 --- a/mlir/unittests/programs/qir_programs.cpp +++ b/mlir/unittests/programs/qir_programs.cpp @@ -12,22 +12,140 @@ #include "mlir/Dialect/QIR/Builder/QIRProgramBuilder.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include +/** + * @brief Creates a struct value using an `llvm.poison` operation with the given + * types. + * @param b The QIRProgramBuilder used to create the struct. + * @param types The types of the elements in the struct. + * @return The created struct value. + */ +mlir::Value createStruct(mlir::qir::QIRProgramBuilder& b, + mlir::SmallVector types) { + auto structType = + mlir::LLVM::LLVMStructType::getLiteral(b.getContext(), types); + mlir::Value structValue = mlir::LLVM::PoisonOp::create(b, structType); + return structValue; +} + +/** + * @brief Collects measurement outcomes into a struct value. + * @param b The QIRProgramBuilder used to create the struct. + * @param outcomes The measurement outcomes to be read and collected. + * @param structValue The struct value to insert the measurement outcomes into. + * @return The struct value with the measurement outcomes inserted. + */ +mlir::Value +collectMeasurementOutcomesInStruct(mlir::qir::QIRProgramBuilder& b, + mlir::SmallVector outcomes, + mlir::Value structValue) { + int64_t index = 0; + for (auto bit : outcomes) { + auto c = b.readResult(bit); + auto insert = mlir::LLVM::InsertValueOp::create( + b, structValue, c, mlir::ArrayRef(index++)); + structValue = insert.getResult(); + } + return structValue; +} + +/** + * @brief Measures the given qubits and returns the measurement outcomes as a + * struct value or a single `i1`. + * @param b The QIRProgramBuilder used to perform the measurements and create + * the struct. + * @param qubits The qubits to be measured. + * @param inRegister Whether to store the results in a classical result array or + * not. + * @return A pair containing the result value and its type. + */ +static std::pair +measureAndReturn(mlir::qir::QIRProgramBuilder& b, + mlir::SmallVector qubits, bool inRegister) { + + if (qubits.empty()) { + auto zeroConst = b.intConstant(0); + return {zeroConst, b.getI64Type()}; + } + mlir::qir::QIRProgramBuilder::ClassicalRegister resultArray; + if (inRegister) { + resultArray = b.allocClassicalBitRegister(qubits.size(), "meas"); + } + + if (qubits.size() == 1) { + auto outcome = inRegister ? b.measure(qubits[0], resultArray[0]) + : b.measure(qubits[0], 0); + auto result = b.readResult(outcome); + return {result, b.getI1Type()}; + } + + llvm::SmallVector elementTypes(qubits.size(), b.getI1Type()); + mlir::Value structValue = createStruct(b, elementTypes); + + for (auto i = 0L; i < qubits.size(); ++i) { + auto outcome = inRegister ? b.measure(qubits[i], resultArray[i]) + : b.measure(qubits[i], i); + auto result = b.readResult(outcome); + auto insert = mlir::LLVM::InsertValueOp::create(b, structValue, result, i); + structValue = insert.getResult(); + } + return {structValue, structValue.getType()}; +} + +/** + * @brief Measures the given qubits and returns the measurement outcomes as a + * struct value or a single `i1`. + * + * @detail The measurement outcomes are stored in a classical result array. + * @param b The QIRProgramBuilder used to perform the measurements and create + * the struct. + * @param qubits The qubits to be measured. + * @return The result value and its type as a pair. + */ +static std::pair +measureAndReturn(mlir::qir::QIRProgramBuilder& b, + mlir::SmallVector qubits) { + return measureAndReturn(b, qubits, true); +} + namespace mlir::qir { +std::pair emptyQIR(QIRProgramBuilder& b) { + return measureAndReturn(b, {}); +} -void emptyQIR([[maybe_unused]] QIRProgramBuilder& builder) {} +std::pair allocQubit(QIRProgramBuilder& b) { + auto q = b.allocQubit(); + return measureAndReturn(b, {q}); +} -void allocQubit(QIRProgramBuilder& b) { b.allocQubitRegister(1); } +std::pair alloc1QubitRegister(QIRProgramBuilder& b) { + auto q = b.allocQubitRegister(1); + return measureAndReturn(b, {q[0]}); +} -void allocQubitRegister(QIRProgramBuilder& b) { b.allocQubitRegister(2); } +std::pair allocQubitRegister(QIRProgramBuilder& b) { + auto q = b.allocQubitRegister(2); + return measureAndReturn(b, {q[0], q[1]}); +} -void allocMultipleQubitRegisters(QIRProgramBuilder& b) { - b.allocQubitRegister(2); - b.allocQubitRegister(3); +std::pair allocMultipleQubitRegisters(QIRProgramBuilder& b) { + auto q0 = b.allocQubitRegister(2); + auto q1 = b.allocQubitRegister(3); + return measureAndReturn(b, {q0[0], q0[1], q1[0], q1[1], q1[2]}); } -void allocMultipleQubitRegistersWithOps(QIRProgramBuilder& b) { +std::pair +allocMultipleQubitRegistersWithOps(QIRProgramBuilder& b) { auto q0 = b.allocQubitRegister(2); auto q1 = b.allocQubitRegister(3); b.h(q0[0]); @@ -35,47 +153,57 @@ void allocMultipleQubitRegistersWithOps(QIRProgramBuilder& b) { b.h(q1[0]); b.h(q1[1]); b.h(q1[2]); + return measureAndReturn(b, {q0[0], q0[1], q1[0], q1[1], q1[2]}); } -void allocLargeRegister(QIRProgramBuilder& b) { b.allocQubitRegister(100); } +std::pair allocLargeRegister(QIRProgramBuilder& b) { + auto q = b.allocQubitRegister(100); + return measureAndReturn(b, {q[0], q[99]}); +} -void staticQubits(QIRProgramBuilder& b) { - b.staticQubit(0); - b.staticQubit(1); +std::pair staticQubits(QIRProgramBuilder& b) { + auto q0 = b.staticQubit(0); + auto q1 = b.staticQubit(1); + return measureAndReturn(b, {q0, q1}, false); } -void staticQubitsWithOps(QIRProgramBuilder& b) { +std::pair staticQubitsWithOps(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.h(q0); b.h(q1); + return measureAndReturn(b, {q0, q1}, false); } -void staticQubitsWithParametricOps(QIRProgramBuilder& b) { +std::pair staticQubitsWithParametricOps(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.rx(std::numbers::pi / 4., q0); b.p(std::numbers::pi / 2., q1); + return measureAndReturn(b, {q0, q1}, false); } -void staticQubitsWithTwoTargetOps(QIRProgramBuilder& b) { +std::pair staticQubitsWithTwoTargetOps(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.rzz(0.123, q0, q1); + return measureAndReturn(b, {q0, q1}, false); } -void staticQubitsWithCtrl(QIRProgramBuilder& b) { +std::pair staticQubitsWithCtrl(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.cx(q0, q1); + return measureAndReturn(b, {q0, q1}, false); } -void staticQubitsWithInv(QIRProgramBuilder& b) { +std::pair staticQubitsWithInv(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); b.tdg(q0); + return measureAndReturn(b, {q0}, false); } -void staticQubitsWithDuplicates(QIRProgramBuilder& b) { +std::pair staticQubitsWithDuplicates(QIRProgramBuilder& b) { auto q0a = b.staticQubit(0); auto q1a = b.staticQubit(1); auto q0b = b.staticQubit(0); @@ -85,9 +213,10 @@ void staticQubitsWithDuplicates(QIRProgramBuilder& b) { b.rzz(0.123, q0b, q1b); b.cx(q0b, q1b); b.tdg(q0a); + return measureAndReturn(b, {q0b, q1b}, false); } -void staticQubitsCanonical(QIRProgramBuilder& b) { +std::pair staticQubitsCanonical(QIRProgramBuilder& b) { auto q0 = b.staticQubit(0); auto q1 = b.staticQubit(1); b.rx(std::numbers::pi / 4., q0); @@ -95,541 +224,660 @@ void staticQubitsCanonical(QIRProgramBuilder& b) { b.rzz(0.123, q0, q1); b.cx(q0, q1); b.tdg(q0); + return measureAndReturn(b, {q0, q1}, false); } -void mixedStaticThenDynamicQubit(QIRProgramBuilder& b) { - b.staticQubit(0); - b.allocQubit(); +std::pair mixedStaticThenDynamicQubit(QIRProgramBuilder& b) { + auto q0 = b.staticQubit(0); + auto q1 = b.allocQubit(); + return measureAndReturn(b, {q0, q1}, false); } -void mixedDynamicRegisterThenStaticQubit(QIRProgramBuilder& b) { - b.allocQubitRegister(2); - b.staticQubit(0); +std::pair +mixedDynamicRegisterThenStaticQubit(QIRProgramBuilder& b) { + auto q0 = b.allocQubitRegister(2); + auto q1 = b.staticQubit(0); + return measureAndReturn(b, {q0[0], q0[1], q1}, false); } -void singleMeasurementToSingleBit(QIRProgramBuilder& b) { +std::pair singleMeasurementToSingleBit(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto c = b.allocClassicalBitRegister(1); - b.measure(q[0], c[0]); + const auto v = b.measure(q[0], c[0]); + const auto read = b.readResult(v); + return {read, b.getI1Type()}; } -void repeatedMeasurementToSameBit(QIRProgramBuilder& b) { +std::pair repeatedMeasurementToSameBit(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto c = b.allocClassicalBitRegister(1); b.measure(q[0], c[0]); b.measure(q[0], c[0]); - b.measure(q[0], c[0]); + auto b3 = b.measure(q[0], c[0]); + auto c3 = b.readResult(b3); + return {c3, b.getI1Type()}; } -void repeatedMeasurementToDifferentBits(QIRProgramBuilder& b) { +std::pair +repeatedMeasurementToDifferentBits(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); const auto c = b.allocClassicalBitRegister(3); - b.measure(q[0], c[0]); - b.measure(q[0], c[1]); - b.measure(q[0], c[2]); -} - -void multipleClassicalRegistersAndMeasurements(QIRProgramBuilder& b) { + auto b1 = b.measure(q[0], c[0]); + auto b2 = b.measure(q[0], c[1]); + auto b3 = b.measure(q[0], c[2]); + auto structValue = + createStruct(b, {b.getI1Type(), b.getI1Type(), b.getI1Type()}); + auto filledStruct = + collectMeasurementOutcomesInStruct(b, {b1, b2, b3}, structValue); + return {filledStruct, filledStruct.getType()}; +} + +std::pair +multipleClassicalRegistersAndMeasurements(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); const auto& c0 = b.allocClassicalBitRegister(1, "c0"); const auto& c1 = b.allocClassicalBitRegister(2, "c1"); - b.measure(q[0], c0[0]); - b.measure(q[1], c1[0]); - b.measure(q[2], c1[1]); + auto b1 = b.measure(q[0], c0[0]); + auto b2 = b.measure(q[1], c1[0]); + auto b3 = b.measure(q[2], c1[1]); + auto structValue = + createStruct(b, {b.getI1Type(), b.getI1Type(), b.getI1Type()}); + auto filledStruct = + collectMeasurementOutcomesInStruct(b, {b1, b2, b3}, structValue); + return {filledStruct, filledStruct.getType()}; } -void measurementWithoutRegisters(QIRProgramBuilder& b) { +std::pair measurementWithoutRegisters(QIRProgramBuilder& b) { auto q = b.allocQubit(); - b.measure(q, 0); + auto bit = b.measure(q, 0); + auto c = b.readResult(bit); + return {c, b.getI1Type()}; } -void resetQubitWithoutOp(QIRProgramBuilder& b) { +std::pair resetQubitWithoutOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetMultipleQubitsWithoutOp(QIRProgramBuilder& b) { +std::pair resetMultipleQubitsWithoutOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.reset(q[0]); b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetWithoutOp(QIRProgramBuilder& b) { +std::pair repeatedResetWithoutOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.reset(q[0]); b.reset(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetQubitAfterSingleOp(QIRProgramBuilder& b) { +std::pair resetQubitAfterSingleOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void resetMultipleQubitsAfterSingleOp(QIRProgramBuilder& b) { +std::pair resetMultipleQubitsAfterSingleOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.h(q[0]); b.reset(q[0]); b.h(q[1]); b.reset(q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void repeatedResetAfterSingleOp(QIRProgramBuilder& b) { +std::pair repeatedResetAfterSingleOp(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); b.reset(q[0]); b.reset(q[0]); b.reset(q[0]); + return measureAndReturn(b, {q[0]}); } -void globalPhase(QIRProgramBuilder& b) { b.gphase(0.123); } +std::pair globalPhase(QIRProgramBuilder& b) { + b.gphase(0.123); + return measureAndReturn(b, {}); +} -void identity(QIRProgramBuilder& b) { +std::pair identity(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.id(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledIdentity(QIRProgramBuilder& b) { +std::pair singleControlledIdentity(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cid(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledIdentity(QIRProgramBuilder& b) { +std::pair multipleControlledIdentity(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcid({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void x(QIRProgramBuilder& b) { +std::pair x(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.x(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledX(QIRProgramBuilder& b) { +std::pair singleControlledX(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledX(QIRProgramBuilder& b) { +std::pair multipleControlledX(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcx({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void y(QIRProgramBuilder& b) { +std::pair y(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.y(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledY(QIRProgramBuilder& b) { +std::pair singleControlledY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cy(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledY(QIRProgramBuilder& b) { +std::pair multipleControlledY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcy({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void z(QIRProgramBuilder& b) { +std::pair z(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.z(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledZ(QIRProgramBuilder& b) { +std::pair singleControlledZ(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cz(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledZ(QIRProgramBuilder& b) { +std::pair multipleControlledZ(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcz({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void h(QIRProgramBuilder& b) { +std::pair h(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledH(QIRProgramBuilder& b) { +std::pair singleControlledH(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ch(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledH(QIRProgramBuilder& b) { +std::pair multipleControlledH(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mch({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void hWithoutRegister(QIRProgramBuilder& b) { +std::pair hWithoutRegister(QIRProgramBuilder& b) { auto q = b.allocQubit(); b.h(q); + return measureAndReturn(b, {q}, false); } -void s(QIRProgramBuilder& b) { +std::pair s(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.s(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledS(QIRProgramBuilder& b) { +std::pair singleControlledS(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cs(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledS(QIRProgramBuilder& b) { +std::pair multipleControlledS(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcs({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sdg(QIRProgramBuilder& b) { +std::pair sdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSdg(QIRProgramBuilder& b) { +std::pair singleControlledSdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSdg(QIRProgramBuilder& b) { +std::pair multipleControlledSdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void t_(QIRProgramBuilder& b) { +std::pair t_(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.t(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledT(QIRProgramBuilder& b) { +std::pair singleControlledT(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ct(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledT(QIRProgramBuilder& b) { +std::pair multipleControlledT(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mct({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void tdg(QIRProgramBuilder& b) { +std::pair tdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.tdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledTdg(QIRProgramBuilder& b) { +std::pair singleControlledTdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ctdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledTdg(QIRProgramBuilder& b) { +std::pair multipleControlledTdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mctdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sx(QIRProgramBuilder& b) { +std::pair sx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sx(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSx(QIRProgramBuilder& b) { +std::pair singleControlledSx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSx(QIRProgramBuilder& b) { +std::pair multipleControlledSx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsx({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void sxdg(QIRProgramBuilder& b) { +std::pair sxdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.sxdg(q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledSxdg(QIRProgramBuilder& b) { +std::pair singleControlledSxdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.csxdg(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledSxdg(QIRProgramBuilder& b) { +std::pair multipleControlledSxdg(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcsxdg({q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void rx(QIRProgramBuilder& b) { +std::pair rx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.rx(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRx(QIRProgramBuilder& b) { +std::pair singleControlledRx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.crx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRx(QIRProgramBuilder& b) { +std::pair multipleControlledRx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcrx(0.123, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void ry(QIRProgramBuilder& b) { +std::pair ry(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.ry(0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRy(QIRProgramBuilder& b) { +std::pair singleControlledRy(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cry(0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRy(QIRProgramBuilder& b) { +std::pair multipleControlledRy(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcry(0.456, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void rz(QIRProgramBuilder& b) { +std::pair rz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.rz(0.789, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledRz(QIRProgramBuilder& b) { +std::pair singleControlledRz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.crz(0.789, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledRz(QIRProgramBuilder& b) { +std::pair multipleControlledRz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcrz(0.789, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void p(QIRProgramBuilder& b) { +std::pair p(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.p(0.123, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledP(QIRProgramBuilder& b) { +std::pair singleControlledP(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cp(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledP(QIRProgramBuilder& b) { +std::pair multipleControlledP(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcp(0.123, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void r(QIRProgramBuilder& b) { +std::pair r(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.r(0.123, 0.456, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledR(QIRProgramBuilder& b) { +std::pair singleControlledR(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cr(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledR(QIRProgramBuilder& b) { +std::pair multipleControlledR(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcr(0.123, 0.456, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void u2(QIRProgramBuilder& b) { +std::pair u2(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.u2(0.234, 0.567, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU2(QIRProgramBuilder& b) { +std::pair singleControlledU2(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cu2(0.234, 0.567, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU2(QIRProgramBuilder& b) { +std::pair multipleControlledU2(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcu2(0.234, 0.567, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void u(QIRProgramBuilder& b) { +std::pair u(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.u(0.1, 0.2, 0.3, q[0]); + return measureAndReturn(b, {q[0]}); } -void singleControlledU(QIRProgramBuilder& b) { +std::pair singleControlledU(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.cu(0.1, 0.2, 0.3, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void multipleControlledU(QIRProgramBuilder& b) { +std::pair multipleControlledU(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.mcu(0.1, 0.2, 0.3, {q[0], q[1]}, q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void swap(QIRProgramBuilder& b) { +std::pair swap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.swap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledSwap(QIRProgramBuilder& b) { +std::pair singleControlledSwap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cswap(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledSwap(QIRProgramBuilder& b) { +std::pair multipleControlledSwap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcswap({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void iswap(QIRProgramBuilder& b) { +std::pair iswap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.iswap(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledIswap(QIRProgramBuilder& b) { +std::pair singleControlledIswap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.ciswap(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledIswap(QIRProgramBuilder& b) { +std::pair multipleControlledIswap(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mciswap({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void dcx(QIRProgramBuilder& b) { +std::pair dcx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.dcx(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledDcx(QIRProgramBuilder& b) { +std::pair singleControlledDcx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cdcx(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledDcx(QIRProgramBuilder& b) { +std::pair multipleControlledDcx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcdcx({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void ecr(QIRProgramBuilder& b) { +std::pair ecr(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ecr(q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledEcr(QIRProgramBuilder& b) { +std::pair singleControlledEcr(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cecr(q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledEcr(QIRProgramBuilder& b) { +std::pair multipleControlledEcr(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcecr({q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rxx(QIRProgramBuilder& b) { +std::pair rxx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rxx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRxx(QIRProgramBuilder& b) { +std::pair singleControlledRxx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crxx(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRxx(QIRProgramBuilder& b) { +std::pair multipleControlledRxx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrxx(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void tripleControlledRxx(QIRProgramBuilder& b) { +std::pair tripleControlledRxx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(5); b.mcrxx(0.123, {q[0], q[1], q[2]}, q[3], q[4]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3], q[4]}); } -void ryy(QIRProgramBuilder& b) { +std::pair ryy(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.ryy(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRyy(QIRProgramBuilder& b) { +std::pair singleControlledRyy(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cryy(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRyy(QIRProgramBuilder& b) { +std::pair multipleControlledRyy(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcryy(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rzx(QIRProgramBuilder& b) { +std::pair rzx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rzx(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzx(QIRProgramBuilder& b) { +std::pair singleControlledRzx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crzx(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzx(QIRProgramBuilder& b) { +std::pair multipleControlledRzx(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrzx(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void rzz(QIRProgramBuilder& b) { +std::pair rzz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.rzz(0.123, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledRzz(QIRProgramBuilder& b) { +std::pair singleControlledRzz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.crzz(0.123, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledRzz(QIRProgramBuilder& b) { +std::pair multipleControlledRzz(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcrzz(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void xxPlusYY(QIRProgramBuilder& b) { +std::pair xxPlusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.xx_plus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxPlusYY(QIRProgramBuilder& b) { +std::pair singleControlledXxPlusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cxx_plus_yy(0.123, 0.456, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxPlusYY(QIRProgramBuilder& b) { +std::pair multipleControlledXxPlusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcxx_plus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void xxMinusYY(QIRProgramBuilder& b) { +std::pair xxMinusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.xx_minus_yy(0.123, 0.456, q[0], q[1]); + return measureAndReturn(b, {q[0], q[1]}); } -void singleControlledXxMinusYY(QIRProgramBuilder& b) { +std::pair singleControlledXxMinusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(3); b.cxx_minus_yy(0.123, 0.456, q[0], q[1], q[2]); + return measureAndReturn(b, {q[0], q[1], q[2]}); } -void multipleControlledXxMinusYY(QIRProgramBuilder& b) { +std::pair multipleControlledXxMinusYY(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcxx_minus_yy(0.123, 0.456, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } -void simpleIf(QIRProgramBuilder& b) { +std::pair simpleIf(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); auto cond = b.measure(q[0], 0); b.scfIf(cond, [&] { b.x(q[0]); }); + return measureAndReturn(b, {q[0]}); } -void ifElse(QIRProgramBuilder& b) { +std::pair ifElse(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(1); b.h(q[0]); auto cond = b.measure(q[0], 0); b.scfIf(cond, [&] { b.x(q[0]); }, [&] { b.z(q[0]); }); + return measureAndReturn(b, {q[0]}); } -void ifTwoQubits(QIRProgramBuilder& b) { +std::pair ifTwoQubits(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(2); b.h(q[0]); auto cond = b.measure(q[0], 0); @@ -637,9 +885,10 @@ void ifTwoQubits(QIRProgramBuilder& b) { b.x(q[0]); b.x(q[1]); }); + return measureAndReturn(b, {q[0], q[1]}); } -void nestedIfOpForLoop(QIRProgramBuilder& b) { +std::pair nestedIfOpForLoop(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto q0 = b.allocQubit(); b.h(q0); @@ -652,9 +901,10 @@ void nestedIfOpForLoop(QIRProgramBuilder& b) { b.h(q1); }); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], q0}); } -void simpleWhileReset(QIRProgramBuilder& b) { +std::pair simpleWhileReset(QIRProgramBuilder& b) { auto q = b.allocQubit(); b.h(q); b.scfWhile( @@ -663,26 +913,29 @@ void simpleWhileReset(QIRProgramBuilder& b) { return measureResult; }, [&] { b.h(q); }); + return measureAndReturn(b, {q}); } -void simpleDoWhileReset(QIRProgramBuilder& b) { +std::pair simpleDoWhileReset(QIRProgramBuilder& b) { auto q = b.allocQubit(); b.scfWhile([&] { b.h(q); auto measureResult = b.measure(q, 0); return measureResult; }); + return measureAndReturn(b, {q}); } -void simpleForLoop(QIRProgramBuilder& b) { +std::pair simpleForLoop(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(2); b.scfFor(0, 2, 1, [&](Value iv) { auto q = b.load(reg.value, iv); b.h(q); }); + return measureAndReturn(b, {reg[0], reg[1]}); }; -void nestedForLoopIfOp(QIRProgramBuilder& b) { +std::pair nestedForLoopIfOp(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(2); auto qCond = b.allocQubit(); b.scfFor(0, 2, 1, [&](Value iv) { @@ -693,9 +946,10 @@ void nestedForLoopIfOp(QIRProgramBuilder& b) { b.h(q); }); }); + return measureAndReturn(b, {reg[0], reg[1], qCond}); } -void nestedForLoopWhileOp(QIRProgramBuilder& b) { +std::pair nestedForLoopWhileOp(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(2); b.scfFor(0, 2, 1, [&](Value iv) { auto q = b.load(reg.value, iv); @@ -710,9 +964,11 @@ void nestedForLoopWhileOp(QIRProgramBuilder& b) { }, [&] { b.h(q); }); }); + return measureAndReturn(b, {reg[0], reg[1]}); } -void nestedForLoopCtrlOpWithSeparateQubit(QIRProgramBuilder& b) { +std::pair +nestedForLoopCtrlOpWithSeparateQubit(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(3); auto control = b.allocQubit(); b.h(control); @@ -721,9 +977,11 @@ void nestedForLoopCtrlOpWithSeparateQubit(QIRProgramBuilder& b) { b.h(q0); b.cx(control, q0); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], control}); } -void nestedForLoopCtrlOpWithExtractedQubit(QIRProgramBuilder& b) { +std::pair +nestedForLoopCtrlOpWithExtractedQubit(QIRProgramBuilder& b) { auto reg = b.allocQubitRegister(4); b.h(reg[0]); b.scfFor(1, 4, 1, [&](Value iv) { @@ -731,12 +989,14 @@ void nestedForLoopCtrlOpWithExtractedQubit(QIRProgramBuilder& b) { b.h(q0); b.cx(reg[0], q0); }); + return measureAndReturn(b, {reg[0], reg[1], reg[2], reg[3]}); } -void ctrlTwo(QIRProgramBuilder& b) { +std::pair ctrlTwo(QIRProgramBuilder& b) { auto q = b.allocQubitRegister(4); b.mcx({q[0], q[1]}, q[2]); b.mcrxx(0.123, {q[0], q[1]}, q[2], q[3]); + return measureAndReturn(b, {q[0], q[1], q[2], q[3]}); } } // namespace mlir::qir diff --git a/mlir/unittests/programs/qir_programs.h b/mlir/unittests/programs/qir_programs.h index afa3daaef6..de0d66d333 100644 --- a/mlir/unittests/programs/qir_programs.h +++ b/mlir/unittests/programs/qir_programs.h @@ -10,468 +10,481 @@ #pragma once +#include +#include +#include + +#include + namespace mlir::qir { class QIRProgramBuilder; /// Creates an empty QIR program. -void emptyQIR(QIRProgramBuilder& builder); +std::pair emptyQIR(QIRProgramBuilder& builder); // --- Qubit Management ----------------------------------------------------- // /// Allocates a single qubit. -void allocQubit(QIRProgramBuilder& b); +std::pair allocQubit(QIRProgramBuilder& b); + +/// Allocates a qubit register of size `1`. +std::pair alloc1QubitRegister(QIRProgramBuilder& b); /// Allocates a qubit register of size `2`. -void allocQubitRegister(QIRProgramBuilder& b); +std::pair allocQubitRegister(QIRProgramBuilder& b); /// Allocates two qubit registers of size `2` and `3`. -void allocMultipleQubitRegisters(QIRProgramBuilder& b); +std::pair allocMultipleQubitRegisters(QIRProgramBuilder& b); /// Allocates two qubit registers of size `2` and `3` and applies operations. -void allocMultipleQubitRegistersWithOps(QIRProgramBuilder& b); +std::pair allocMultipleQubitRegistersWithOps(QIRProgramBuilder& b); /// Allocates a large qubit register. -void allocLargeRegister(QIRProgramBuilder& b); +std::pair allocLargeRegister(QIRProgramBuilder& b); /// Allocates two inline qubits. -void staticQubits(QIRProgramBuilder& b); +std::pair staticQubits(QIRProgramBuilder& b); /// Allocates two static qubits and applies operations. -void staticQubitsWithOps(QIRProgramBuilder& b); +std::pair staticQubitsWithOps(QIRProgramBuilder& b); /// Allocates two static qubits and applies parametric gates. -void staticQubitsWithParametricOps(QIRProgramBuilder& b); +std::pair staticQubitsWithParametricOps(QIRProgramBuilder& b); /// Allocates two static qubits and applies a two-target gate. -void staticQubitsWithTwoTargetOps(QIRProgramBuilder& b); +std::pair staticQubitsWithTwoTargetOps(QIRProgramBuilder& b); /// Allocates two static qubits and applies a controlled gate. -void staticQubitsWithCtrl(QIRProgramBuilder& b); +std::pair staticQubitsWithCtrl(QIRProgramBuilder& b); /// Allocates a static qubit and applies the inverse of a T gate (Tdg). -void staticQubitsWithInv(QIRProgramBuilder& b); +std::pair staticQubitsWithInv(QIRProgramBuilder& b); /// Allocates duplicate static qubits and applies operations on both. -void staticQubitsWithDuplicates(QIRProgramBuilder& b); +std::pair staticQubitsWithDuplicates(QIRProgramBuilder& b); /// Same as `staticQubitsWithDuplicates`, but with canonical static qubit /// retrievals. -void staticQubitsCanonical(QIRProgramBuilder& b); +std::pair staticQubitsCanonical(QIRProgramBuilder& b); // --- Invalid / mixed addressing (unit tests) -------------------------------- /// @pre `builder.initialize()`. Fatal mixed addressing: static then dynamic /// alloc. -void mixedStaticThenDynamicQubit(QIRProgramBuilder& b); +std::pair mixedStaticThenDynamicQubit(QIRProgramBuilder& b); /// @pre `builder.initialize()`. Fatal mixed addressing: dynamic register then /// static. -void mixedDynamicRegisterThenStaticQubit(QIRProgramBuilder& b); +std::pair +mixedDynamicRegisterThenStaticQubit(QIRProgramBuilder& b); // --- MeasureOp ------------------------------------------------------------ // /// Measures a single qubit into a single classical bit. -void singleMeasurementToSingleBit(QIRProgramBuilder& b); +std::pair singleMeasurementToSingleBit(QIRProgramBuilder& b); /// Repeatedly measures a single qubit into the same classical bit. -void repeatedMeasurementToSameBit(QIRProgramBuilder& b); +std::pair repeatedMeasurementToSameBit(QIRProgramBuilder& b); /// Repeatedly measures a single qubit into different classical bits. -void repeatedMeasurementToDifferentBits(QIRProgramBuilder& b); +std::pair repeatedMeasurementToDifferentBits(QIRProgramBuilder& b); /// Measures multiple qubits into multiple classical bits. -void multipleClassicalRegistersAndMeasurements(QIRProgramBuilder& b); +std::pair +multipleClassicalRegistersAndMeasurements(QIRProgramBuilder& b); /// Measures a single qubit into a single classical bit, without explicitly /// allocating a quantum or classical register. -void measurementWithoutRegisters(QIRProgramBuilder& b); +std::pair measurementWithoutRegisters(QIRProgramBuilder& b); // --- ResetOp -------------------------------------------------------------- // /// Resets a single qubit without any operations being applied. -void resetQubitWithoutOp(QIRProgramBuilder& b); +std::pair resetQubitWithoutOp(QIRProgramBuilder& b); /// Resets multiple qubits without any operations being applied. -void resetMultipleQubitsWithoutOp(QIRProgramBuilder& b); +std::pair resetMultipleQubitsWithoutOp(QIRProgramBuilder& b); /// Repeatedly resets a single qubit without any operations being applied. -void repeatedResetWithoutOp(QIRProgramBuilder& b); +std::pair repeatedResetWithoutOp(QIRProgramBuilder& b); /// Resets a single qubit after a single operation. -void resetQubitAfterSingleOp(QIRProgramBuilder& b); +std::pair resetQubitAfterSingleOp(QIRProgramBuilder& b); /// Resets multiple qubits after a single operation. -void resetMultipleQubitsAfterSingleOp(QIRProgramBuilder& b); +std::pair resetMultipleQubitsAfterSingleOp(QIRProgramBuilder& b); /// Repeatedly resets a single qubit after a single operation. -void repeatedResetAfterSingleOp(QIRProgramBuilder& b); +std::pair repeatedResetAfterSingleOp(QIRProgramBuilder& b); // --- GPhaseOp ------------------------------------------------------------- // /// Creates a circuit with just a global phase. -void globalPhase(QIRProgramBuilder& b); +std::pair globalPhase(QIRProgramBuilder& b); // --- IdOp ----------------------------------------------------------------- // /// Creates a circuit with just an identity gate. -void identity(QIRProgramBuilder& b); +std::pair identity(QIRProgramBuilder& b); /// Creates a controlled identity gate with a single control qubit. -void singleControlledIdentity(QIRProgramBuilder& b); +std::pair singleControlledIdentity(QIRProgramBuilder& b); /// Creates a multi-controlled identity gate with multiple control qubits. -void multipleControlledIdentity(QIRProgramBuilder& b); +std::pair multipleControlledIdentity(QIRProgramBuilder& b); // --- XOp ------------------------------------------------------------------ // /// Creates a circuit with just an X gate. -void x(QIRProgramBuilder& b); +std::pair x(QIRProgramBuilder& b); /// Creates a circuit with a single controlled X gate. -void singleControlledX(QIRProgramBuilder& b); +std::pair singleControlledX(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled X gate. -void multipleControlledX(QIRProgramBuilder& b); +std::pair multipleControlledX(QIRProgramBuilder& b); // --- YOp ------------------------------------------------------------------ // /// Creates a circuit with just a Y gate. -void y(QIRProgramBuilder& b); +std::pair y(QIRProgramBuilder& b); /// Creates a circuit with a single controlled Y gate. -void singleControlledY(QIRProgramBuilder& b); +std::pair singleControlledY(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled Y gate. -void multipleControlledY(QIRProgramBuilder& b); +std::pair multipleControlledY(QIRProgramBuilder& b); // --- ZOp ------------------------------------------------------------------ // /// Creates a circuit with just a Z gate. -void z(QIRProgramBuilder& b); +std::pair z(QIRProgramBuilder& b); /// Creates a circuit with a single controlled Z gate. -void singleControlledZ(QIRProgramBuilder& b); +std::pair singleControlledZ(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled Z gate. -void multipleControlledZ(QIRProgramBuilder& b); +std::pair multipleControlledZ(QIRProgramBuilder& b); // --- HOp ------------------------------------------------------------------ // /// Creates a circuit with just an H gate. -void h(QIRProgramBuilder& b); +std::pair h(QIRProgramBuilder& b); /// Creates a circuit with a single controlled H gate. -void singleControlledH(QIRProgramBuilder& b); +std::pair singleControlledH(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled H gate. -void multipleControlledH(QIRProgramBuilder& b); +std::pair multipleControlledH(QIRProgramBuilder& b); /// Creates a circuit with just an H gate and no qubit register. -void hWithoutRegister(QIRProgramBuilder& b); +std::pair hWithoutRegister(QIRProgramBuilder& b); // --- SOp ------------------------------------------------------------------ // /// Creates a circuit with just an S gate. -void s(QIRProgramBuilder& b); +std::pair s(QIRProgramBuilder& b); /// Creates a circuit with a single controlled S gate. -void singleControlledS(QIRProgramBuilder& b); +std::pair singleControlledS(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled S gate. -void multipleControlledS(QIRProgramBuilder& b); +std::pair multipleControlledS(QIRProgramBuilder& b); // --- SdgOp ---------------------------------------------------------------- // /// Creates a circuit with just an Sdg gate. -void sdg(QIRProgramBuilder& b); +std::pair sdg(QIRProgramBuilder& b); /// Creates a circuit with a single controlled Sdg gate. -void singleControlledSdg(QIRProgramBuilder& b); +std::pair singleControlledSdg(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled Sdg gate. -void multipleControlledSdg(QIRProgramBuilder& b); +std::pair multipleControlledSdg(QIRProgramBuilder& b); // --- TOp ------------------------------------------------------------------ // /// Creates a circuit with just a T gate. -void t_(QIRProgramBuilder& b); // NOLINT(*-identifier-naming) +std::pair t_(QIRProgramBuilder& b); // NOLINT(*-identifier-naming) /// Creates a circuit with a single controlled T gate. -void singleControlledT(QIRProgramBuilder& b); +std::pair singleControlledT(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled T gate. -void multipleControlledT(QIRProgramBuilder& b); +std::pair multipleControlledT(QIRProgramBuilder& b); // --- TdgOp ---------------------------------------------------------------- // /// Creates a circuit with just a Tdg gate. -void tdg(QIRProgramBuilder& b); +std::pair tdg(QIRProgramBuilder& b); /// Creates a circuit with a single controlled Tdg gate. -void singleControlledTdg(QIRProgramBuilder& b); +std::pair singleControlledTdg(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled Tdg gate. -void multipleControlledTdg(QIRProgramBuilder& b); +std::pair multipleControlledTdg(QIRProgramBuilder& b); // --- SXOp ----------------------------------------------------------------- // /// Creates a circuit with just an SX gate. -void sx(QIRProgramBuilder& b); +std::pair sx(QIRProgramBuilder& b); /// Creates a circuit with a single controlled SX gate. -void singleControlledSx(QIRProgramBuilder& b); +std::pair singleControlledSx(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled SX gate. -void multipleControlledSx(QIRProgramBuilder& b); +std::pair multipleControlledSx(QIRProgramBuilder& b); // --- SXdgOp --------------------------------------------------------------- // /// Creates a circuit with just an SXdg gate. -void sxdg(QIRProgramBuilder& b); +std::pair sxdg(QIRProgramBuilder& b); /// Creates a circuit with a single controlled SXdg gate. -void singleControlledSxdg(QIRProgramBuilder& b); +std::pair singleControlledSxdg(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled SXdg gate. -void multipleControlledSxdg(QIRProgramBuilder& b); +std::pair multipleControlledSxdg(QIRProgramBuilder& b); // --- RXOp ----------------------------------------------------------------- // /// Creates a circuit with just an RX gate. -void rx(QIRProgramBuilder& b); +std::pair rx(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RX gate. -void singleControlledRx(QIRProgramBuilder& b); +std::pair singleControlledRx(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RX gate. -void multipleControlledRx(QIRProgramBuilder& b); +std::pair multipleControlledRx(QIRProgramBuilder& b); // --- RYOp ----------------------------------------------------------------- // /// Creates a circuit with just an RY gate. -void ry(QIRProgramBuilder& b); +std::pair ry(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RY gate. -void singleControlledRy(QIRProgramBuilder& b); +std::pair singleControlledRy(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RY gate. -void multipleControlledRy(QIRProgramBuilder& b); +std::pair multipleControlledRy(QIRProgramBuilder& b); // --- RZOp ----------------------------------------------------------------- // /// Creates a circuit with just an RZ gate. -void rz(QIRProgramBuilder& b); +std::pair rz(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RZ gate. -void singleControlledRz(QIRProgramBuilder& b); +std::pair singleControlledRz(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RZ gate. -void multipleControlledRz(QIRProgramBuilder& b); +std::pair multipleControlledRz(QIRProgramBuilder& b); // --- POp ------------------------------------------------------------------ // /// Creates a circuit with just a P gate. -void p(QIRProgramBuilder& b); +std::pair p(QIRProgramBuilder& b); /// Creates a circuit with a single controlled P gate. -void singleControlledP(QIRProgramBuilder& b); +std::pair singleControlledP(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled P gate. -void multipleControlledP(QIRProgramBuilder& b); +std::pair multipleControlledP(QIRProgramBuilder& b); // --- ROp ------------------------------------------------------------------ // /// Creates a circuit with just an R gate. -void r(QIRProgramBuilder& b); +std::pair r(QIRProgramBuilder& b); /// Creates a circuit with a single controlled R gate. -void singleControlledR(QIRProgramBuilder& b); +std::pair singleControlledR(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled R gate. -void multipleControlledR(QIRProgramBuilder& b); +std::pair multipleControlledR(QIRProgramBuilder& b); // --- U2Op ----------------------------------------------------------------- // /// Creates a circuit with just a U2 gate. -void u2(QIRProgramBuilder& b); +std::pair u2(QIRProgramBuilder& b); /// Creates a circuit with a single controlled U2 gate. -void singleControlledU2(QIRProgramBuilder& b); +std::pair singleControlledU2(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled U2 gate. -void multipleControlledU2(QIRProgramBuilder& b); +std::pair multipleControlledU2(QIRProgramBuilder& b); // --- UOp ------------------------------------------------------------------ // /// Creates a circuit with just a U gate. -void u(QIRProgramBuilder& b); +std::pair u(QIRProgramBuilder& b); /// Creates a circuit with a single controlled U gate. -void singleControlledU(QIRProgramBuilder& b); +std::pair singleControlledU(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled U gate. -void multipleControlledU(QIRProgramBuilder& b); +std::pair multipleControlledU(QIRProgramBuilder& b); // --- SWAPOp --------------------------------------------------------------- // /// Creates a circuit with just a SWAP gate. -void swap(QIRProgramBuilder& b); +std::pair swap(QIRProgramBuilder& b); /// Creates a circuit with a single controlled SWAP gate. -void singleControlledSwap(QIRProgramBuilder& b); +std::pair singleControlledSwap(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled SWAP gate. -void multipleControlledSwap(QIRProgramBuilder& b); +std::pair multipleControlledSwap(QIRProgramBuilder& b); // --- iSWAPOp -------------------------------------------------------------- // /// Creates a circuit with just an iSWAP gate. -void iswap(QIRProgramBuilder& b); +std::pair iswap(QIRProgramBuilder& b); /// Creates a circuit with a single controlled iSWAP gate. -void singleControlledIswap(QIRProgramBuilder& b); +std::pair singleControlledIswap(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled iSWAP gate. -void multipleControlledIswap(QIRProgramBuilder& b); +std::pair multipleControlledIswap(QIRProgramBuilder& b); // --- DCXOp ---------------------------------------------------------------- // /// Creates a circuit with just a DCX gate. -void dcx(QIRProgramBuilder& b); +std::pair dcx(QIRProgramBuilder& b); /// Creates a circuit with a single controlled DCX gate. -void singleControlledDcx(QIRProgramBuilder& b); +std::pair singleControlledDcx(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled DCX gate. -void multipleControlledDcx(QIRProgramBuilder& b); +std::pair multipleControlledDcx(QIRProgramBuilder& b); // --- ECROp ---------------------------------------------------------------- // /// Creates a circuit with just an ECR gate. -void ecr(QIRProgramBuilder& b); +std::pair ecr(QIRProgramBuilder& b); /// Creates a circuit with a single controlled ECR gate. -void singleControlledEcr(QIRProgramBuilder& b); +std::pair singleControlledEcr(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled ECR gate. -void multipleControlledEcr(QIRProgramBuilder& b); +std::pair multipleControlledEcr(QIRProgramBuilder& b); // --- RXXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RXX gate. -void rxx(QIRProgramBuilder& b); +std::pair rxx(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RXX gate. -void singleControlledRxx(QIRProgramBuilder& b); +std::pair singleControlledRxx(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RXX gate. -void multipleControlledRxx(QIRProgramBuilder& b); +std::pair multipleControlledRxx(QIRProgramBuilder& b); /// Creates a circuit with a triple-controlled RXX gate. -void tripleControlledRxx(QIRProgramBuilder& b); +std::pair tripleControlledRxx(QIRProgramBuilder& b); // --- RYYOp ---------------------------------------------------------------- // /// Creates a circuit with just an RYY gate. -void ryy(QIRProgramBuilder& b); +std::pair ryy(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RYY gate. -void singleControlledRyy(QIRProgramBuilder& b); +std::pair singleControlledRyy(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RYY gate. -void multipleControlledRyy(QIRProgramBuilder& b); +std::pair multipleControlledRyy(QIRProgramBuilder& b); // --- RZXOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZX gate. -void rzx(QIRProgramBuilder& b); +std::pair rzx(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RZX gate. -void singleControlledRzx(QIRProgramBuilder& b); +std::pair singleControlledRzx(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RZX gate. -void multipleControlledRzx(QIRProgramBuilder& b); +std::pair multipleControlledRzx(QIRProgramBuilder& b); // --- RZZOp ---------------------------------------------------------------- // /// Creates a circuit with just an RZZ gate. -void rzz(QIRProgramBuilder& b); +std::pair rzz(QIRProgramBuilder& b); /// Creates a circuit with a single controlled RZZ gate. -void singleControlledRzz(QIRProgramBuilder& b); +std::pair singleControlledRzz(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled RZZ gate. -void multipleControlledRzz(QIRProgramBuilder& b); +std::pair multipleControlledRzz(QIRProgramBuilder& b); // --- XXPlusYYOp ----------------------------------------------------------- // /// Creates a circuit with just an XXPlusYY gate. -void xxPlusYY(QIRProgramBuilder& b); +std::pair xxPlusYY(QIRProgramBuilder& b); /// Creates a circuit with a single controlled XXPlusYY gate. -void singleControlledXxPlusYY(QIRProgramBuilder& b); +std::pair singleControlledXxPlusYY(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled XXPlusYY gate. -void multipleControlledXxPlusYY(QIRProgramBuilder& b); +std::pair multipleControlledXxPlusYY(QIRProgramBuilder& b); // --- XXMinusYYOp ---------------------------------------------------------- // /// Creates a circuit with just an XXMinusYY gate. -void xxMinusYY(QIRProgramBuilder& b); +std::pair xxMinusYY(QIRProgramBuilder& b); /// Creates a circuit with a single controlled XXMinusYY gate. -void singleControlledXxMinusYY(QIRProgramBuilder& b); +std::pair singleControlledXxMinusYY(QIRProgramBuilder& b); /// Creates a circuit with a multi-controlled XXMinusYY gate. -void multipleControlledXxMinusYY(QIRProgramBuilder& b); +std::pair multipleControlledXxMinusYY(QIRProgramBuilder& b); // --- IfOp ----------------------------------------------------------------- // /// Creates a circuit with a simple if operation with one qubit. -void simpleIf(QIRProgramBuilder& b); +std::pair simpleIf(QIRProgramBuilder& b); /// Creates a circuit with an if operation with an else branch. -void ifElse(QIRProgramBuilder& b); +std::pair ifElse(QIRProgramBuilder& b); /// Creates a circuit with an if operation with two qubits. -void ifTwoQubits(QIRProgramBuilder& b); +std::pair ifTwoQubits(QIRProgramBuilder& b); /// Creates a circuit with an if operation with a nested for operation with /// a register. -void nestedIfOpForLoop(QIRProgramBuilder& b); +std::pair nestedIfOpForLoop(QIRProgramBuilder& b); // --- WhileOp -------------------------------------------------------------- // /// Creates a circuit with a while operation using a while loop. -void simpleWhileReset(QIRProgramBuilder& b); +std::pair simpleWhileReset(QIRProgramBuilder& b); /// Creates a circuit with a while operation using a do-while loop. -void simpleDoWhileReset(QIRProgramBuilder& b); +std::pair simpleDoWhileReset(QIRProgramBuilder& b); // --- ForOp ---------------------------------------------------------------- // /// Creates a circuit with a simple for operation with a register. -void simpleForLoop(QIRProgramBuilder& b); +std::pair simpleForLoop(QIRProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested if operation. -void nestedForLoopIfOp(QIRProgramBuilder& b); +std::pair nestedForLoopIfOp(QIRProgramBuilder& b); /// Creates a circuit with a for operation with a register and a nested while /// operation. -void nestedForLoopWhileOp(QIRProgramBuilder& b); +std::pair nestedForLoopWhileOp(QIRProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is separately allocated from the /// register. -void nestedForLoopCtrlOpWithSeparateQubit(QIRProgramBuilder& b); +std::pair +nestedForLoopCtrlOpWithSeparateQubit(QIRProgramBuilder& b); /// Creates a circuit with a for operation with a register and a qubit and a /// nested ctrl operation where the qubit is extracted from the register. -void nestedForLoopCtrlOpWithExtractedQubit(QIRProgramBuilder& b); +std::pair +nestedForLoopCtrlOpWithExtractedQubit(QIRProgramBuilder& b); // --- CtrlOp --------------------------------------------------------------- // /// Creates a circuit with a control modifier applied to two gates. -void ctrlTwo(QIRProgramBuilder& b); +std::pair ctrlTwo(QIRProgramBuilder& b); } // namespace mlir::qir diff --git a/mlir/unittests/programs/quantum_computation_programs.cpp b/mlir/unittests/programs/quantum_computation_programs.cpp index f0b9b305cd..133ba5e736 100644 --- a/mlir/unittests/programs/quantum_computation_programs.cpp +++ b/mlir/unittests/programs/quantum_computation_programs.cpp @@ -22,19 +22,27 @@ namespace qc { -void allocQubit(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); } +void allocQubit(QuantumComputation& comp) { + auto qr = comp.addQubitRegister(1, "q"); + comp.measureAll(true, false); +} void allocQubitRegister(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); + comp.measureAll(true, false); } void allocMultipleQubitRegisters(QuantumComputation& comp) { comp.addQubitRegister(2, "reg0"); comp.addQubitRegister(3, "reg1"); + comp.measureAll(true, false); } void allocLargeRegister(QuantumComputation& comp) { comp.addQubitRegister(100, "q"); + comp.addClassicalRegister(2, "meas"); + comp.measure(0, 0); + comp.measure(99, 1); } void singleMeasurementToSingleBit(QuantumComputation& comp) { @@ -72,6 +80,7 @@ void resetQubitAfterSingleOp(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.h(0); comp.reset(0); + comp.measureAll(true, false); } void resetMultipleQubitsAfterSingleOp(QuantumComputation& comp) { @@ -80,6 +89,7 @@ void resetMultipleQubitsAfterSingleOp(QuantumComputation& comp) { comp.reset(0); comp.h(1); comp.reset(1); + comp.measureAll(true, false); } void repeatedResetAfterSingleOp(QuantumComputation& comp) { @@ -88,6 +98,7 @@ void repeatedResetAfterSingleOp(QuantumComputation& comp) { comp.reset(0); comp.reset(0); comp.reset(0); + comp.measureAll(true, false); } void globalPhase(QuantumComputation& comp) { comp.gphase(0.123); } @@ -95,451 +106,542 @@ void globalPhase(QuantumComputation& comp) { comp.gphase(0.123); } void identity(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.i(0); + comp.measureAll(true, false); } void singleControlledIdentity(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ci(1, 0); + comp.measureAll(true, false); } void multipleControlledIdentity(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mci({2, 1}, 0); + comp.addClassicalRegister(1, "meas"); + comp.measure(0, 0); } void x(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.x(0); + comp.measureAll(true, false); } void singleControlledX(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cx(0, 1); + comp.measureAll(true, false); } void multipleControlledX(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcx({0, 1}, 2); + comp.measureAll(true, false); } void y(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.y(0); + comp.measureAll(true, false); } void singleControlledY(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cy(0, 1); + comp.measureAll(true, false); } void multipleControlledY(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcy({0, 1}, 2); + comp.measureAll(true, false); } void z(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.z(0); + comp.measureAll(true, false); } void singleControlledZ(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cz(0, 1); + comp.measureAll(true, false); } void multipleControlledZ(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcz({0, 1}, 2); + comp.measureAll(true, false); } void h(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.h(0); + comp.measureAll(true, false); } void singleControlledH(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ch(0, 1); + comp.measureAll(true, false); } void multipleControlledH(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mch({0, 1}, 2); + comp.measureAll(true, false); } void s(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.s(0); + comp.measureAll(true, false); } void singleControlledS(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cs(0, 1); + comp.measureAll(true, false); } void multipleControlledS(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcs({0, 1}, 2); + comp.measureAll(true, false); } void sdg(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.sdg(0); + comp.measureAll(true, false); } void singleControlledSdg(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.csdg(0, 1); + comp.measureAll(true, false); } void multipleControlledSdg(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcsdg({0, 1}, 2); + comp.measureAll(true, false); } void t_(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.t(0); + comp.measureAll(true, false); } void singleControlledT(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ct(0, 1); + comp.measureAll(true, false); } void multipleControlledT(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mct({0, 1}, 2); + comp.measureAll(true, false); } void tdg(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.tdg(0); + comp.measureAll(true, false); } void singleControlledTdg(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ctdg(0, 1); + comp.measureAll(true, false); } void multipleControlledTdg(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mctdg({0, 1}, 2); + comp.measureAll(true, false); } void sx(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.sx(0); + comp.measureAll(true, false); } void singleControlledSx(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.csx(0, 1); + comp.measureAll(true, false); } void multipleControlledSx(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcsx({0, 1}, 2); + comp.measureAll(true, false); } void sxdg(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.sxdg(0); + comp.measureAll(true, false); } void singleControlledSxdg(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.csxdg(0, 1); + comp.measureAll(true, false); } void multipleControlledSxdg(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcsxdg({0, 1}, 2); + comp.measureAll(true, false); } void rx(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.rx(0.123, 0); + comp.measureAll(true, false); } void singleControlledRx(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.crx(0.123, 0, 1); + comp.measureAll(true, false); } void multipleControlledRx(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcrx(0.123, {0, 1}, 2); + comp.measureAll(true, false); } void ry(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.ry(0.456, 0); + comp.measureAll(true, false); } void singleControlledRy(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cry(0.456, 0, 1); + comp.measureAll(true, false); } void multipleControlledRy(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcry(0.456, {0, 1}, 2); + comp.measureAll(true, false); } void rz(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.rz(0.789, 0); + comp.measureAll(true, false); } void singleControlledRz(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.crz(0.789, 0, 1); + comp.measureAll(true, false); } void multipleControlledRz(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcrz(0.789, {0, 1}, 2); + comp.measureAll(true, false); } void p(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.p(0.123, 0); + comp.measureAll(true, false); } void singleControlledP(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cp(0.123, 0, 1); + comp.measureAll(true, false); } void multipleControlledP(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcp(0.123, {0, 1}, 2); + comp.measureAll(true, false); } void r(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.r(0.123, 0.456, 0); + comp.measureAll(true, false); } void singleControlledR(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cr(0.123, 0.456, 0, 1); + comp.measureAll(true, false); } void multipleControlledR(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcr(0.123, 0.456, {0, 1}, 2); + comp.measureAll(true, false); } void u2(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.u2(0.234, 0.567, 0); + comp.measureAll(true, false); } void singleControlledU2(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cu2(0.234, 0.567, 0, 1); + comp.measureAll(true, false); } void multipleControlledU2(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcu2(0.234, 0.567, {0, 1}, 2); + comp.measureAll(true, false); } void u(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.u(0.1, 0.2, 0.3, 0); + comp.measureAll(true, false); } void singleControlledU(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.cu(0.1, 0.2, 0.3, 0, 1); + comp.measureAll(true, false); } void multipleControlledU(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.mcu(0.1, 0.2, 0.3, {0, 1}, 2); + comp.measureAll(true, false); } void swap(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.swap(0, 1); + comp.measureAll(true, false); } void singleControlledSwap(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cswap(0, 1, 2); + comp.measureAll(true, false); } void multipleControlledSwap(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcswap({0, 1}, 2, 3); + comp.measureAll(true, false); } void iswap(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.iswap(0, 1); + comp.measureAll(true, false); } void singleControlledIswap(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.ciswap(0, 1, 2); + comp.measureAll(true, false); } void multipleControlledIswap(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mciswap({0, 1}, 2, 3); + comp.measureAll(true, false); } void inverseIswap(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.iswapdg(0, 1); + comp.measureAll(true, false); } void inverseMultipleControlledIswap(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mciswapdg({0, 1}, 2, 3); + comp.measureAll(true, false); } void dcx(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.dcx(0, 1); + comp.measureAll(true, false); } void singleControlledDcx(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cdcx(0, 1, 2); + comp.measureAll(true, false); } void multipleControlledDcx(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcdcx({0, 1}, 2, 3); + comp.measureAll(true, false); } void ecr(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ecr(0, 1); + comp.measureAll(true, false); } void singleControlledEcr(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cecr(0, 1, 2); + comp.measureAll(true, false); } void multipleControlledEcr(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcecr({0, 1}, 2, 3); + comp.measureAll(true, false); } void rxx(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.rxx(0.123, 0, 1); + comp.measureAll(true, false); } void singleControlledRxx(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.crxx(0.123, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledRxx(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcrxx(0.123, {0, 1}, 2, 3); + comp.measureAll(true, false); } void tripleControlledRxx(QuantumComputation& comp) { comp.addQubitRegister(5, "q"); comp.mcrxx(0.123, {0, 1, 2}, 3, 4); + comp.measureAll(true, false); } void ryy(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.ryy(0.123, 0, 1); + comp.measureAll(true, false); } void singleControlledRyy(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cryy(0.123, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledRyy(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcryy(0.123, {0, 1}, 2, 3); + comp.measureAll(true, false); } void rzx(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.rzx(0.123, 0, 1); + comp.measureAll(true, false); } void singleControlledRzx(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.crzx(0.123, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledRzx(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcrzx(0.123, {0, 1}, 2, 3); + comp.measureAll(true, false); } void rzz(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.rzz(0.123, 0, 1); + comp.measureAll(true, false); } void singleControlledRzz(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.crzz(0.123, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledRzz(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcrzz(0.123, {0, 1}, 2, 3); + comp.measureAll(true, false); } void xxPlusYY(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.xx_plus_yy(0.123, 0.456, 0, 1); + comp.measureAll(true, false); } void singleControlledXxPlusYY(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cxx_plus_yy(0.123, 0.456, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledXxPlusYY(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcxx_plus_yy(0.123, 0.456, {0, 1}, 2, 3); + comp.measureAll(true, false); } void xxMinusYY(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.xx_minus_yy(0.123, 0.456, 0, 1); + comp.measureAll(true, false); } void singleControlledXxMinusYY(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.cxx_minus_yy(0.123, 0.456, 0, 1, 2); + comp.measureAll(true, false); } void multipleControlledXxMinusYY(QuantumComputation& comp) { comp.addQubitRegister(4, "q"); comp.mcxx_minus_yy(0.123, 0.456, {0, 1}, 2, 3); + comp.measureAll(true, false); } void barrier(QuantumComputation& comp) { comp.addQubitRegister(1, "q"); comp.barrier(0); + comp.measureAll(true, false); } void barrierTwoQubits(QuantumComputation& comp) { comp.addQubitRegister(2, "q"); comp.barrier({0, 1}); + comp.measureAll(true, false); } void barrierMultipleQubits(QuantumComputation& comp) { comp.addQubitRegister(3, "q"); comp.barrier({0, 1, 2}); + comp.measureAll(true, false); } void ctrlTwo(QuantumComputation& comp) { @@ -551,6 +653,7 @@ void ctrlTwo(QuantumComputation& comp) { compound.addControl(0); compound.addControl(1); comp.emplace_back(std::move(compound)); + comp.measureAll(true, false); } void ctrlTwoMixed(QuantumComputation& comp) { @@ -562,6 +665,7 @@ void ctrlTwoMixed(QuantumComputation& comp) { compound.addControl(0); compound.addControl(1); comp.emplace_back(std::move(compound)); + comp.measureAll(true, false); } void simpleIf(QuantumComputation& comp) { @@ -570,6 +674,7 @@ void simpleIf(QuantumComputation& comp) { comp.h(q[0]); comp.measure(q[0], c[0]); comp.if_(X, q[0], c[0]); + comp.measureAll(true, false); } void ifTwoQubits(QuantumComputation& comp) { @@ -583,6 +688,7 @@ void ifTwoQubits(QuantumComputation& comp) { IfElseOperation ifElse( std::make_unique(std::move(compound)), nullptr, c[0]); comp.emplace_back(std::move(ifElse)); + comp.measureAll(true, false); } void ifElse(QuantumComputation& comp) { @@ -592,6 +698,7 @@ void ifElse(QuantumComputation& comp) { comp.measure(q[0], c[0]); comp.ifElse(std::make_unique(q[0], X), std::make_unique(q[0], Z), c[0]); + comp.measureAll(true, false); } } // namespace qc diff --git a/mlir/unittests/programs/quantum_computation_programs.h b/mlir/unittests/programs/quantum_computation_programs.h index f6dab6e1c2..b4555e4dfb 100644 --- a/mlir/unittests/programs/quantum_computation_programs.h +++ b/mlir/unittests/programs/quantum_computation_programs.h @@ -10,6 +10,11 @@ #pragma once +#include +#include + +#include + namespace qc { class QuantumComputation; diff --git a/src/ir/QuantumComputation.cpp b/src/ir/QuantumComputation.cpp index e0b63f17b0..7b018582fd 100644 --- a/src/ir/QuantumComputation.cpp +++ b/src/ir/QuantumComputation.cpp @@ -1541,7 +1541,7 @@ void QuantumComputation::measure(const Targets& qubits, emplace_back(qubits, bits); } -void QuantumComputation::measureAll(const bool addBits) { +void QuantumComputation::measureAll(const bool addBits, const bool addBarrier) { if (addBits) { addClassicalRegister(getNqubits(), "meas"); } @@ -1553,7 +1553,9 @@ void QuantumComputation::measureAll(const bool addBits) { throw std::runtime_error(ss.str()); } - barrier(); + if (addBarrier) { + barrier(); + } Qubit start = 0U; if (addBits) { start = static_cast(classicalRegisters.at("meas").getStartIndex()); diff --git a/test/algorithms/cmake_test_discovery_365918a72a.json b/test/algorithms/cmake_test_discovery_365918a72a.json new file mode 100644 index 0000000000..e43f93d3eb --- /dev/null +++ b/test/algorithms/cmake_test_discovery_365918a72a.json @@ -0,0 +1,1754 @@ +{ + "tests": 278, + "name": "AllTests", + "testsuites": [ + { + "name": "StatePreparation", + "tests": 2, + "testsuite": [ + { + "name": "StatePreparationAmplitudesNotNormalized", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 87 + }, + { + "name": "StatePreparationsAmplitudesNotPowerOf2", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 95 + } + ] + }, + { + "name": "BernsteinVazirani", + "tests": 2, + "testsuite": [ + { + "name": "LargeCircuit", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 90 + }, + { + "name": "DynamicCircuit", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 105 + } + ] + }, + { + "name": "WState\/WState", + "tests": 19, + "testsuite": [ + { + "name": "FunctionTest\/1_qubits", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/8_qubits", + "value_param": "8", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/22_qubits", + "value_param": "22", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/29_qubits", + "value_param": "29", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/36_qubits", + "value_param": "36", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/43_qubits", + "value_param": "43", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/50_qubits", + "value_param": "50", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/57_qubits", + "value_param": "57", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/64_qubits", + "value_param": "64", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/71_qubits", + "value_param": "71", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/78_qubits", + "value_param": "78", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/85_qubits", + "value_param": "85", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/92_qubits", + "value_param": "92", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/99_qubits", + "value_param": "99", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/106_qubits", + "value_param": "106", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/113_qubits", + "value_param": "113", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/120_qubits", + "value_param": "120", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/127_qubits", + "value_param": "127", + "file": "\/workspaces\/core\/test\/algorithms\/test_wstate.cpp", + "line": 51 + } + ] + }, + { + "name": "StatePreparation\/StatePreparation", + "tests": 6, + "testsuite": [ + { + "name": "StatePreparationCircuitSimulation\/0", + "value_param": "{ (0.707107,0), (-0.707107,0) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + }, + { + "name": "StatePreparationCircuitSimulation\/1", + "value_param": "{ (0.707107,0), (0,-0.707107) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + }, + { + "name": "StatePreparationCircuitSimulation\/2", + "value_param": "{ (0,0), (0.707107,0), (-0.707107,0), (0,0) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + }, + { + "name": "StatePreparationCircuitSimulation\/3", + "value_param": "{ (0.27735,0), (-0.27735,0), (0.27735,-0.27735), (0,0.83205) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + }, + { + "name": "StatePreparationCircuitSimulation\/4", + "value_param": "{ (0.25,0), (0.25,0), (0.25,0), (0.25,0), (0.25,0), (0.25,0), (0.25,0), (0.75,0) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + }, + { + "name": "StatePreparationCircuitSimulation\/5", + "value_param": "{ (0.25,0), (0,0.25), (0.25,0), (0,0.25), (0,0.25), (0.25,0), (0.25,0), (0.75,0) }", + "file": "\/workspaces\/core\/test\/algorithms\/test_statepreparation.cpp", + "line": 72 + } + ] + }, + { + "name": "RandomClifford\/RandomClifford", + "tests": 16, + "testsuite": [ + { + "name": "simulate\/1_qubits", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/2_qubits", + "value_param": "2", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/4_qubits", + "value_param": "4", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/5_qubits", + "value_param": "5", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/7_qubits", + "value_param": "7", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "simulate\/8_qubits", + "value_param": "8", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 46 + }, + { + "name": "buildFunctionality\/1_qubits", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/2_qubits", + "value_param": "2", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/4_qubits", + "value_param": "4", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/5_qubits", + "value_param": "5", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/7_qubits", + "value_param": "7", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + }, + { + "name": "buildFunctionality\/8_qubits", + "value_param": "8", + "file": "\/workspaces\/core\/test\/algorithms\/test_random_clifford.cpp", + "line": 60 + } + ] + }, + { + "name": "QPE\/QPE", + "tests": 28, + "testsuite": [ + { + "name": "QPETest\/100_pi_1", + "value_param": "(1, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/50_pi_2", + "value_param": "(0.5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/25_pi_3", + "value_param": "(0.25, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/37_pi_3", + "value_param": "(0.375, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/37_pi_4", + "value_param": "(0.375, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/9_pi_5", + "value_param": "(0.09375, 5)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "QPETest\/9_pi_6", + "value_param": "(0.09375, 6)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 137 + }, + { + "name": "IQPETest\/100_pi_1", + "value_param": "(1, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/50_pi_2", + "value_param": "(0.5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/25_pi_3", + "value_param": "(0.25, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/37_pi_3", + "value_param": "(0.375, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/37_pi_4", + "value_param": "(0.375, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/9_pi_5", + "value_param": "(0.09375, 5)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "IQPETest\/9_pi_6", + "value_param": "(0.09375, 6)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 173 + }, + { + "name": "DynamicEquivalenceSimulation\/100_pi_1", + "value_param": "(1, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/50_pi_2", + "value_param": "(0.5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/25_pi_3", + "value_param": "(0.25, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/37_pi_3", + "value_param": "(0.375, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/37_pi_4", + "value_param": "(0.375, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/9_pi_5", + "value_param": "(0.09375, 5)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceSimulation\/9_pi_6", + "value_param": "(0.09375, 6)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 218 + }, + { + "name": "DynamicEquivalenceFunctionality\/100_pi_1", + "value_param": "(1, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/50_pi_2", + "value_param": "(0.5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/25_pi_3", + "value_param": "(0.25, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/37_pi_3", + "value_param": "(0.375, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/37_pi_4", + "value_param": "(0.375, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/9_pi_5", + "value_param": "(0.09375, 5)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + }, + { + "name": "DynamicEquivalenceFunctionality\/9_pi_6", + "value_param": "(0.09375, 6)", + "file": "\/workspaces\/core\/test\/algorithms\/test_qpe.cpp", + "line": 251 + } + ] + }, + { + "name": "QFT\/QFT", + "tests": 30, + "testsuite": [ + { + "name": "Functionality\/0_qubits", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "Functionality\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "Functionality\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "Functionality\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "Functionality\/12_qubits", + "value_param": "12", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "Functionality\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 83 + }, + { + "name": "FunctionalityRecursive\/0_qubits", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "FunctionalityRecursive\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "FunctionalityRecursive\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "FunctionalityRecursive\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "FunctionalityRecursive\/12_qubits", + "value_param": "12", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "FunctionalityRecursive\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 126 + }, + { + "name": "Simulation\/0_qubits", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "Simulation\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "Simulation\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "Simulation\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "Simulation\/12_qubits", + "value_param": "12", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "Simulation\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 169 + }, + { + "name": "FunctionalityRecursiveEquality\/0_qubits", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "FunctionalityRecursiveEquality\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "FunctionalityRecursiveEquality\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "FunctionalityRecursiveEquality\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "FunctionalityRecursiveEquality\/12_qubits", + "value_param": "12", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "FunctionalityRecursiveEquality\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 206 + }, + { + "name": "SimulationSampling\/0_qubits", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + }, + { + "name": "SimulationSampling\/3_qubits", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + }, + { + "name": "SimulationSampling\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + }, + { + "name": "SimulationSampling\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + }, + { + "name": "SimulationSampling\/12_qubits", + "value_param": "12", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + }, + { + "name": "SimulationSampling\/15_qubits", + "value_param": "15", + "file": "\/workspaces\/core\/test\/algorithms\/test_qft.cpp", + "line": 226 + } + ] + }, + { + "name": "Grover\/Grover", + "tests": 75, + "testsuite": [ + { + "name": "Functionality\/3_qubits_0", + "value_param": "(2, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/3_qubits_1", + "value_param": "(2, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/3_qubits_2", + "value_param": "(2, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/3_qubits_3", + "value_param": "(2, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/3_qubits_4", + "value_param": "(2, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/6_qubits_0", + "value_param": "(5, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/6_qubits_1", + "value_param": "(5, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/6_qubits_2", + "value_param": "(5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/6_qubits_3", + "value_param": "(5, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/6_qubits_4", + "value_param": "(5, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/9_qubits_0", + "value_param": "(8, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/9_qubits_1", + "value_param": "(8, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/9_qubits_2", + "value_param": "(8, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/9_qubits_3", + "value_param": "(8, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/9_qubits_4", + "value_param": "(8, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/12_qubits_0", + "value_param": "(11, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/12_qubits_1", + "value_param": "(11, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/12_qubits_2", + "value_param": "(11, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/12_qubits_3", + "value_param": "(11, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/12_qubits_4", + "value_param": "(11, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/15_qubits_0", + "value_param": "(14, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/15_qubits_1", + "value_param": "(14, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/15_qubits_2", + "value_param": "(14, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/15_qubits_3", + "value_param": "(14, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "Functionality\/15_qubits_4", + "value_param": "(14, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 89 + }, + { + "name": "FunctionalityRecursive\/3_qubits_0", + "value_param": "(2, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/3_qubits_1", + "value_param": "(2, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/3_qubits_2", + "value_param": "(2, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/3_qubits_3", + "value_param": "(2, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/3_qubits_4", + "value_param": "(2, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/6_qubits_0", + "value_param": "(5, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/6_qubits_1", + "value_param": "(5, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/6_qubits_2", + "value_param": "(5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/6_qubits_3", + "value_param": "(5, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/6_qubits_4", + "value_param": "(5, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/9_qubits_0", + "value_param": "(8, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/9_qubits_1", + "value_param": "(8, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/9_qubits_2", + "value_param": "(8, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/9_qubits_3", + "value_param": "(8, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/9_qubits_4", + "value_param": "(8, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/12_qubits_0", + "value_param": "(11, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/12_qubits_1", + "value_param": "(11, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/12_qubits_2", + "value_param": "(11, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/12_qubits_3", + "value_param": "(11, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/12_qubits_4", + "value_param": "(11, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/15_qubits_0", + "value_param": "(14, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/15_qubits_1", + "value_param": "(14, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/15_qubits_2", + "value_param": "(14, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/15_qubits_3", + "value_param": "(14, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "FunctionalityRecursive\/15_qubits_4", + "value_param": "(14, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 128 + }, + { + "name": "Simulation\/3_qubits_0", + "value_param": "(2, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/3_qubits_1", + "value_param": "(2, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/3_qubits_2", + "value_param": "(2, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/3_qubits_3", + "value_param": "(2, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/3_qubits_4", + "value_param": "(2, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/6_qubits_0", + "value_param": "(5, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/6_qubits_1", + "value_param": "(5, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/6_qubits_2", + "value_param": "(5, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/6_qubits_3", + "value_param": "(5, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/6_qubits_4", + "value_param": "(5, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/9_qubits_0", + "value_param": "(8, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/9_qubits_1", + "value_param": "(8, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/9_qubits_2", + "value_param": "(8, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/9_qubits_3", + "value_param": "(8, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/9_qubits_4", + "value_param": "(8, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/12_qubits_0", + "value_param": "(11, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/12_qubits_1", + "value_param": "(11, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/12_qubits_2", + "value_param": "(11, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/12_qubits_3", + "value_param": "(11, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/12_qubits_4", + "value_param": "(11, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/15_qubits_0", + "value_param": "(14, 0)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/15_qubits_1", + "value_param": "(14, 1)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/15_qubits_2", + "value_param": "(14, 2)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/15_qubits_3", + "value_param": "(14, 3)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + }, + { + "name": "Simulation\/15_qubits_4", + "value_param": "(14, 4)", + "file": "\/workspaces\/core\/test\/algorithms\/test_grover.cpp", + "line": 182 + } + ] + }, + { + "name": "Entanglement\/Entanglement", + "tests": 26, + "testsuite": [ + { + "name": "FunctionTest\/2_qubits", + "value_param": "2", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/16_qubits", + "value_param": "16", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/23_qubits", + "value_param": "23", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/30_qubits", + "value_param": "30", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/37_qubits", + "value_param": "37", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/44_qubits", + "value_param": "44", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/51_qubits", + "value_param": "51", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/58_qubits", + "value_param": "58", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/65_qubits", + "value_param": "65", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/72_qubits", + "value_param": "72", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/79_qubits", + "value_param": "79", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "FunctionTest\/86_qubits", + "value_param": "86", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 51 + }, + { + "name": "GHZRoutineFunctionTest\/2_qubits", + "value_param": "2", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/9_qubits", + "value_param": "9", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/16_qubits", + "value_param": "16", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/23_qubits", + "value_param": "23", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/30_qubits", + "value_param": "30", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/37_qubits", + "value_param": "37", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/44_qubits", + "value_param": "44", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/51_qubits", + "value_param": "51", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/58_qubits", + "value_param": "58", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/65_qubits", + "value_param": "65", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/72_qubits", + "value_param": "72", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/79_qubits", + "value_param": "79", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + }, + { + "name": "GHZRoutineFunctionTest\/86_qubits", + "value_param": "86", + "file": "\/workspaces\/core\/test\/algorithms\/test_entanglement.cpp", + "line": 60 + } + ] + }, + { + "name": "BernsteinVazirani\/BernsteinVazirani", + "tests": 30, + "testsuite": [ + { + "name": "FunctionTest\/bv_0", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_3", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_63", + "value_param": "63", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_170", + "value_param": "170", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_819", + "value_param": "819", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_4032", + "value_param": "4032", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_33153", + "value_param": "33153", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_87381", + "value_param": "87381", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_16777215", + "value_param": "16777215", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTest\/bv_1234567891011", + "value_param": "1234567891011", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 52 + }, + { + "name": "FunctionTestDynamic\/bv_0", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_3", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_63", + "value_param": "63", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_170", + "value_param": "170", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_819", + "value_param": "819", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_4032", + "value_param": "4032", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_33153", + "value_param": "33153", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_87381", + "value_param": "87381", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_16777215", + "value_param": "16777215", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "FunctionTestDynamic\/bv_1234567891011", + "value_param": "1234567891011", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 71 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_0", + "value_param": "0", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_3", + "value_param": "3", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_63", + "value_param": "63", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_170", + "value_param": "170", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_819", + "value_param": "819", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_4032", + "value_param": "4032", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_33153", + "value_param": "33153", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_87381", + "value_param": "87381", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_16777215", + "value_param": "16777215", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + }, + { + "name": "DynamicEquivalenceSimulation\/bv_1234567891011", + "value_param": "1234567891011", + "file": "\/workspaces\/core\/test\/algorithms\/test_bernsteinvazirani.cpp", + "line": 120 + } + ] + }, + { + "name": "Eval\/DynamicCircuitEvalExactQPE", + "tests": 13, + "testsuite": [ + { + "name": "UnitaryTransformation\/1_qubit", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/11_qubits", + "value_param": "11", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/16_qubits", + "value_param": "16", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/21_qubits", + "value_param": "21", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/26_qubits", + "value_param": "26", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/31_qubits", + "value_param": "31", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/36_qubits", + "value_param": "36", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/41_qubits", + "value_param": "41", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/46_qubits", + "value_param": "46", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/51_qubits", + "value_param": "51", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/56_qubits", + "value_param": "56", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + }, + { + "name": "UnitaryTransformation\/61_qubits", + "value_param": "61", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 122 + } + ] + }, + { + "name": "Eval\/DynamicCircuitEvalInexactQPE", + "tests": 5, + "testsuite": [ + { + "name": "UnitaryTransformation\/1_qubit", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 295 + }, + { + "name": "UnitaryTransformation\/4_qubits", + "value_param": "4", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 295 + }, + { + "name": "UnitaryTransformation\/7_qubits", + "value_param": "7", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 295 + }, + { + "name": "UnitaryTransformation\/10_qubits", + "value_param": "10", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 295 + }, + { + "name": "UnitaryTransformation\/13_qubits", + "value_param": "13", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 295 + } + ] + }, + { + "name": "Eval\/DynamicCircuitEvalBV", + "tests": 13, + "testsuite": [ + { + "name": "UnitaryTransformation\/1_qubit", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/11_qubits", + "value_param": "11", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/16_qubits", + "value_param": "16", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/21_qubits", + "value_param": "21", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/26_qubits", + "value_param": "26", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/31_qubits", + "value_param": "31", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/36_qubits", + "value_param": "36", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/41_qubits", + "value_param": "41", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/46_qubits", + "value_param": "46", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/51_qubits", + "value_param": "51", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/56_qubits", + "value_param": "56", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + }, + { + "name": "UnitaryTransformation\/61_qubits", + "value_param": "61", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 412 + } + ] + }, + { + "name": "Eval\/DynamicCircuitEvalQFT", + "tests": 13, + "testsuite": [ + { + "name": "UnitaryTransformation\/1_qubit", + "value_param": "1", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/6_qubits", + "value_param": "6", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/11_qubits", + "value_param": "11", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/16_qubits", + "value_param": "16", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/21_qubits", + "value_param": "21", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/26_qubits", + "value_param": "26", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/31_qubits", + "value_param": "31", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/36_qubits", + "value_param": "36", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/41_qubits", + "value_param": "41", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/46_qubits", + "value_param": "46", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/51_qubits", + "value_param": "51", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/56_qubits", + "value_param": "56", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + }, + { + "name": "UnitaryTransformation\/61_qubits", + "value_param": "61", + "file": "\/workspaces\/core\/test\/algorithms\/eval_dynamic_circuits.cpp", + "line": 525 + } + ] + } + ] +} diff --git a/test/circuit_optimizer/cmake_test_discovery_02ef7f1542.json b/test/circuit_optimizer/cmake_test_discovery_02ef7f1542.json new file mode 100644 index 0000000000..57f91f3191 --- /dev/null +++ b/test/circuit_optimizer/cmake_test_discovery_02ef7f1542.json @@ -0,0 +1,646 @@ +{ + "tests": 110, + "name": "AllTests", + "testsuites": [ + { + "name": "SwapReconstruction", + "tests": 3, + "testsuite": [ + { + "name": "fuseCxToSwap", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_swap_reconstruction.cpp", + "line": 20 + }, + { + "name": "replaceCxToSwapAtEnd", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_swap_reconstruction.cpp", + "line": 34 + }, + { + "name": "replaceCxToSwap", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_swap_reconstruction.cpp", + "line": 55 + } + ] + }, + { + "name": "SingleQubitGateFusion", + "tests": 7, + "testsuite": [ + { + "name": "CollapseCompoundOperationToStandard", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 21 + }, + { + "name": "eliminateCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 35 + }, + { + "name": "eliminateInverseInCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 49 + }, + { + "name": "unknownInverseInCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 63 + }, + { + "name": "repeatedCancellationInSingleQubitGateFusion", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 76 + }, + { + "name": "emptyCompoundGatesRemovedInSingleQubitGateFusion", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 92 + }, + { + "name": "SingleQubitGateCount", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_single_qubit_gate_fusion.cpp", + "line": 107 + } + ] + }, + { + "name": "ReplaceMCXwithMCZ", + "tests": 4, + "testsuite": [ + { + "name": "replaceCXwithCZ", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_replace_mcx_with_mcz.cpp", + "line": 23 + }, + { + "name": "replaceCCXwithCCZ", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_replace_mcx_with_mcz.cpp", + "line": 38 + }, + { + "name": "replaceCXwithCZinCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_replace_mcx_with_mcz.cpp", + "line": 56 + }, + { + "name": "testToffoliSequenceSimplification", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_replace_mcx_with_mcz.cpp", + "line": 79 + } + ] + }, + { + "name": "RemoveOperation", + "tests": 5, + "testsuite": [ + { + "name": "removeIdentities", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_operation.cpp", + "line": 22 + }, + { + "name": "removeSingleQubitGates", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_operation.cpp", + "line": 38 + }, + { + "name": "removeMultiQubitGates", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_operation.cpp", + "line": 53 + }, + { + "name": "removeMoves", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_operation.cpp", + "line": 68 + }, + { + "name": "removeGateInCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_operation.cpp", + "line": 82 + } + ] + }, + { + "name": "RemoveFinalMeasurements", + "tests": 7, + "testsuite": [ + { + "name": "removeFinalMeasurements", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 25 + }, + { + "name": "removeFinalMeasurementsTwoQubitMeasurement", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 51 + }, + { + "name": "removeFinalMeasurementsCompound", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 76 + }, + { + "name": "removeFinalMeasurementsCompoundDegraded", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 104 + }, + { + "name": "removeFinalMeasurementsCompoundEmpty", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 129 + }, + { + "name": "removeFinalMeasurementsWithOperationsInFront", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 148 + }, + { + "name": "removeFinalMeasurementsWithBarrier", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_final_measurements.cpp", + "line": 162 + } + ] + }, + { + "name": "RemoveDiagonalGateBeforeMeasure", + "tests": 7, + "testsuite": [ + { + "name": "removeDiagonalSingleQubitBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 21 + }, + { + "name": "removeDiagonalCompoundOpBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 35 + }, + { + "name": "removeDiagonalTwoQubitGateBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 51 + }, + { + "name": "leaveGateBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 65 + }, + { + "name": "removeComplexGateBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 79 + }, + { + "name": "removeSimpleCompoundOpBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 100 + }, + { + "name": "removePartOfCompoundOpBeforeMeasure", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_remove_diagonal_gates_before_measure.cpp", + "line": 115 + } + ] + }, + { + "name": "FlattenOperations", + "tests": 3, + "testsuite": [ + { + "name": "FlattenRandomClifford", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_flatten_operations.cpp", + "line": 27 + }, + { + "name": "FlattenRecursive", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_flatten_operations.cpp", + "line": 41 + }, + { + "name": "FlattenCustomOnly", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_flatten_operations.cpp", + "line": 72 + } + ] + }, + { + "name": "EliminateResets", + "tests": 5, + "testsuite": [ + { + "name": "basicTest", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_eliminate_resets.cpp", + "line": 26 + }, + { + "name": "testIf", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_eliminate_resets.cpp", + "line": 84 + }, + { + "name": "testIfElse", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_eliminate_resets.cpp", + "line": 134 + }, + { + "name": "testMultipleTargetReset", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_eliminate_resets.cpp", + "line": 191 + }, + { + "name": "testCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_eliminate_resets.cpp", + "line": 234 + } + ] + }, + { + "name": "ElidePermutations", + "tests": 9, + "testsuite": [ + { + "name": "emptyCircuit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 22 + }, + { + "name": "simpleSwap", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 28 + }, + { + "name": "simpleInitialLayout", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 46 + }, + { + "name": "applyPermutationCompound", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 66 + }, + { + "name": "compoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 85 + }, + { + "name": "compoundOperation2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 111 + }, + { + "name": "compoundOperation3", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 133 + }, + { + "name": "compoundOperation4", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 152 + }, + { + "name": "nonUnitaryOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_elide_permutations.cpp", + "line": 175 + } + ] + }, + { + "name": "DeferMeasurements", + "tests": 10, + "testsuite": [ + { + "name": "basicTestIf", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 26 + }, + { + "name": "basicTestIfElse", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 88 + }, + { + "name": "measurementBetweenMeasurementAndIfElse", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 164 + }, + { + "name": "twoIfElse", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 236 + }, + { + "name": "correctOrder", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 321 + }, + { + "name": "twoIfElseCorrectOrder", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 393 + }, + { + "name": "errorOnImplicitReset", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 477 + }, + { + "name": "errorOnMultiQubitRegister", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 500 + }, + { + "name": "preserveOutputPermutationWithoutMeasurements", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 529 + }, + { + "name": "isDynamicOnRepeatedMeasurements", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_defer_measurements.cpp", + "line": 545 + } + ] + }, + { + "name": "DecomposeSwap", + "tests": 4, + "testsuite": [ + { + "name": "decomposeSWAPsUndirectedArchitecture", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_decompose_swap.cpp", + "line": 22 + }, + { + "name": "decomposeSWAPsDirectedArchitecture", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_decompose_swap.cpp", + "line": 50 + }, + { + "name": "decomposeSWAPsCompound", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_decompose_swap.cpp", + "line": 105 + }, + { + "name": "decomposeSWAPsCompoundDirected", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_decompose_swap.cpp", + "line": 127 + } + ] + }, + { + "name": "CliffordBlocks", + "tests": 16, + "testsuite": [ + { + "name": "emptyCircuit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 20 + }, + { + "name": "singleGate", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 26 + }, + { + "name": "largerGatethenBlock", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 36 + }, + { + "name": "CliffordBlockDepth", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 53 + }, + { + "name": "CliffordBlockWidth", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 72 + }, + { + "name": "keepOrder", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 89 + }, + { + "name": "twoCliffordBlocks", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 112 + }, + { + "name": "nonCliffordSingleQubit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 136 + }, + { + "name": "SingleNonClifford3Qubit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 152 + }, + { + "name": "TwoCliffordBlocks3Qubit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 178 + }, + { + "name": "shiftedNonClifford", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 208 + }, + { + "name": "nonCliffordBeginning", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 237 + }, + { + "name": "threeQubitnonClifford", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 259 + }, + { + "name": "handleCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 288 + }, + { + "name": "handleCompoundOperation2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 312 + }, + { + "name": "barrierNotinBlock", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_clifford_blocks.cpp", + "line": 335 + } + ] + }, + { + "name": "CollectBlocks", + "tests": 15, + "testsuite": [ + { + "name": "emptyCircuit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 19 + }, + { + "name": "singleGate", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 25 + }, + { + "name": "collectMultipleSingleQubitGates", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 35 + }, + { + "name": "mergeBlocks", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 49 + }, + { + "name": "mergeBlocks2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 62 + }, + { + "name": "addToMultiQubitBlock", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 77 + }, + { + "name": "gateTooBig", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 89 + }, + { + "name": "gateTooBig2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 102 + }, + { + "name": "gateTooBig3", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 115 + }, + { + "name": "endingBlocks", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 128 + }, + { + "name": "endingBlocks2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 141 + }, + { + "name": "interruptBlock", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 154 + }, + { + "name": "unprocessableAtBegin", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 167 + }, + { + "name": "handleCompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 179 + }, + { + "name": "handleCompoundOperation2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_collect_blocks.cpp", + "line": 193 + } + ] + }, + { + "name": "CancelCNOTs", + "tests": 5, + "testsuite": [ + { + "name": "CNOTCancellation1", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_cancel_cnots.cpp", + "line": 18 + }, + { + "name": "CNOTCancellation2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_cancel_cnots.cpp", + "line": 27 + }, + { + "name": "CNOTCancellation3", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_cancel_cnots.cpp", + "line": 36 + }, + { + "name": "CNOTCancellation4", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_cancel_cnots.cpp", + "line": 54 + }, + { + "name": "CNOTCancellation5", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_cancel_cnots.cpp", + "line": 72 + } + ] + }, + { + "name": "BackpropagateOutputPermutation", + "tests": 10, + "testsuite": [ + { + "name": "FullySpecified", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 17 + }, + { + "name": "PartiallySpecifiedQubitAvailable", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 30 + }, + { + "name": "FullySpecifiedWithSWAP", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 43 + }, + { + "name": "PartiallySpecifiedWithSWAP", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 58 + }, + { + "name": "PartiallySpecifiedWithSWAP2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 72 + }, + { + "name": "PartiallySpecifiedWithSWAP3", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 86 + }, + { + "name": "CompoundOperation", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 99 + }, + { + "name": "PartiallySpecifiedNotAMissingQubit", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 118 + }, + { + "name": "PartiallySpecifiedNotAMissingQubit2", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 134 + }, + { + "name": "PartiallySpecifiedNotAMissingQubit3", + "file": "\/workspaces\/core\/test\/circuit_optimizer\/test_backpropagate_output_permutation.cpp", + "line": 150 + } + ] + } + ] +} diff --git a/test/dd/cmake_test_discovery_ec2b1aa6e1.json b/test/dd/cmake_test_discovery_ec2b1aa6e1.json new file mode 100644 index 0000000000..7eddfc77c7 --- /dev/null +++ b/test/dd/cmake_test_discovery_ec2b1aa6e1.json @@ -0,0 +1,1622 @@ +{ + "tests": 292, + "name": "AllTests", + "testsuites": [ + { + "name": "StateGenerationTest", + "tests": 23, + "testsuite": [ + { + "name": "MakeZero", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 54 + }, + { + "name": "MakeBasis", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 76 + }, + { + "name": "MakeBasisDifficult", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 101 + }, + { + "name": "MakeGHZ", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 129 + }, + { + "name": "MakeGHZZeroQubits", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 153 + }, + { + "name": "MakeW", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 166 + }, + { + "name": "MakeWZeroQubits", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 194 + }, + { + "name": "FromVectorZero", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 207 + }, + { + "name": "FromVectorScalar", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 222 + }, + { + "name": "FromVector", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 239 + }, + { + "name": "MakeZeroInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 270 + }, + { + "name": "MakeBasisInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 280 + }, + { + "name": "MakeGHZInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 294 + }, + { + "name": "MakeWInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 304 + }, + { + "name": "FromVectorInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 319 + }, + { + "name": "GenerateExponential", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 335 + }, + { + "name": "GenerateExponentialWithSeed", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 362 + }, + { + "name": "GenerateRandomOneQubit", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 389 + }, + { + "name": "GenerateRandomRoundRobin", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 414 + }, + { + "name": "GenerateRandomRoundRobinWithSeed", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 446 + }, + { + "name": "GenerateRandomRandom", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 479 + }, + { + "name": "GenerateRandomRandomWithSeed", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 511 + }, + { + "name": "GenerateRandomInvalidArguments", + "file": "\/workspaces\/core\/test\/dd\/test_state_generation.cpp", + "line": 544 + } + ] + }, + { + "name": "DDPackageTest", + "tests": 96, + "testsuite": [ + { + "name": "TrivialTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 51 + }, + { + "name": "BellState", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 71 + }, + { + "name": "QFTState", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 138 + }, + { + "name": "CorruptedBellState", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 265 + }, + { + "name": "InvalidStandardOperation", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 286 + }, + { + "name": "PrintNoneGateType", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 305 + }, + { + "name": "NegativeControl", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 311 + }, + { + "name": "IdentityTrace", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 320 + }, + { + "name": "CNotKronTrace", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 327 + }, + { + "name": "PartialIdentityTrace", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 335 + }, + { + "name": "PartialSWapMatTrace", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 342 + }, + { + "name": "PartialTraceKeepInnerQubits", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 355 + }, + { + "name": "TraceComplexity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 380 + }, + { + "name": "KeepBottomQubitsPartialTraceComplexity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 398 + }, + { + "name": "PartialTraceComplexity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 427 + }, + { + "name": "StateGenerationManipulation", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 459 + }, + { + "name": "VectorSerializationTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 475 + }, + { + "name": "BellMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 495 + }, + { + "name": "MatrixSerializationTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 577 + }, + { + "name": "SerializationErrors", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 597 + }, + { + "name": "Ancillaries", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 648 + }, + { + "name": "GarbageVector", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 684 + }, + { + "name": "GarbageMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 718 + }, + { + "name": "ReduceGarbageVector", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 755 + }, + { + "name": "ReduceGarbageVectorTGate", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 777 + }, + { + "name": "ReduceGarbageMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 798 + }, + { + "name": "ReduceGarbageMatrix2", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 839 + }, + { + "name": "ReduceGarbageMatrixNoGarbage", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 872 + }, + { + "name": "ReduceGarbageMatrixTGate", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 891 + }, + { + "name": "InvalidMakeBasisStateAndGate", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 917 + }, + { + "name": "PackageReset", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 923 + }, + { + "name": "ResetClearsRoots", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 945 + }, + { + "name": "DuplicatetrackDoesNotLeaveStaleRoot", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 966 + }, + { + "name": "Inverse", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 996 + }, + { + "name": "trackTwiceThenuntrackTwice", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1015 + }, + { + "name": "UniqueTableAllocation", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1044 + }, + { + "name": "SpecialCaseTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1067 + }, + { + "name": "KroneckerProduct", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1101 + }, + { + "name": "KroneckerProductVectors", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1119 + }, + { + "name": "KroneckerIdentityHandling", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1128 + }, + { + "name": "NearZeroNormalize", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1150 + }, + { + "name": "DestructiveMeasurementAll", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1207 + }, + { + "name": "DestructiveMeasurementOne", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1232 + }, + { + "name": "ExportPolarPhaseFormatted", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1253 + }, + { + "name": "BasicNumericInstabilityTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1322 + }, + { + "name": "BasicNumericStabilityTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1376 + }, + { + "name": "NormalizationNumericStabilityTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1405 + }, + { + "name": "FidelityOfMeasurementOutcomes", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1421 + }, + { + "name": "CloseToIdentity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1439 + }, + { + "name": "CloseToIdentityWithGarbageAtTheBeginning", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1472 + }, + { + "name": "CloseToIdentityWithGarbageAtTheEnd", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1497 + }, + { + "name": "CloseToIdentityWithGarbageInTheMiddle", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1526 + }, + { + "name": "calCulpDistance", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1555 + }, + { + "name": "stateFromVectorBell", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1564 + }, + { + "name": "stateFromVectorEmpty", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1586 + }, + { + "name": "stateFromVectorNoPowerOfTwo", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1592 + }, + { + "name": "stateFromScalar", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1598 + }, + { + "name": "expectationValueGlobalOperators", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1606 + }, + { + "name": "expectationValueLocalOperators", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1636 + }, + { + "name": "expectationValueExceptions", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1656 + }, + { + "name": "DDFromSingleQubitMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1666 + }, + { + "name": "DDFromTwoQubitMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1677 + }, + { + "name": "DDFromTwoQubitAsymmetricalMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1689 + }, + { + "name": "DDFromThreeQubitMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1703 + }, + { + "name": "DDFromEmptyMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1719 + }, + { + "name": "DDFromNonPowerOfTwoMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1727 + }, + { + "name": "DDFromNonSquareMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1735 + }, + { + "name": "DDFromSingleElementMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1743 + }, + { + "name": "TwoQubitControlledGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1757 + }, + { + "name": "TwoQubitControlledGateDDConstructionNegativeControls", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1784 + }, + { + "name": "SWAPGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1821 + }, + { + "name": "PeresGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1844 + }, + { + "name": "iSWAPGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1875 + }, + { + "name": "DCXGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1930 + }, + { + "name": "RZZGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1951 + }, + { + "name": "RYYGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 1993 + }, + { + "name": "RXXGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2040 + }, + { + "name": "RZXGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2083 + }, + { + "name": "ECRGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2124 + }, + { + "name": "XXMinusYYGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2151 + }, + { + "name": "XXPlusYYGateDDConstruction", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2217 + }, + { + "name": "InnerProductTopNodeConjugation", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2281 + }, + { + "name": "DDNodeLeakRegressionTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2306 + }, + { + "name": "CTPerformanceRegressionTest", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2323 + }, + { + "name": "DataStructureStatistics", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2342 + }, + { + "name": "DDStatistics", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2359 + }, + { + "name": "ReduceAncillaRegression", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2383 + }, + { + "name": "VectorConjugate", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2398 + }, + { + "name": "ReduceAncillaIdentity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2427 + }, + { + "name": "ReduceAncillaIdentityBeforeFirstNode", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2439 + }, + { + "name": "ReduceAncillaIdentityAfterLastNode", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2453 + }, + { + "name": "ReduceAncillaIdentityBetweenTwoNodes", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2466 + }, + { + "name": "ReduceGarbageIdentity", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2483 + }, + { + "name": "ReduceGarbageIdentityBeforeFirstNode", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2500 + }, + { + "name": "ReduceGarbageIdentityAfterLastNode", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2520 + }, + { + "name": "ReduceGarbageIdentityBetweenTwoNodes", + "file": "\/workspaces\/core\/test\/dd\/test_package.cpp", + "line": 2540 + } + ] + }, + { + "name": "VectorFunctionality", + "tests": 15, + "testsuite": [ + { + "name": "GetValueByPathTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 29 + }, + { + "name": "GetValueByIndexTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 34 + }, + { + "name": "GetValueByIndexEndianness", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 39 + }, + { + "name": "GetVectorTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 50 + }, + { + "name": "GetVectorRoundtrip", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 55 + }, + { + "name": "GetVectorTolerance", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 64 + }, + { + "name": "GetSparseVectorTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 76 + }, + { + "name": "GetSparseVectorConsistency", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 83 + }, + { + "name": "GetSparseVectorTolerance", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 95 + }, + { + "name": "PrintVectorTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 110 + }, + { + "name": "PrintVector", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 121 + }, + { + "name": "AddToVectorTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 133 + }, + { + "name": "AddToVector", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 139 + }, + { + "name": "SizeTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 150 + }, + { + "name": "SizeBellState", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 155 + } + ] + }, + { + "name": "MatrixFunctionality", + "tests": 13, + "testsuite": [ + { + "name": "GetValueByPathTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 166 + }, + { + "name": "GetValueByIndexTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 171 + }, + { + "name": "GetValueByIndexEndianness", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 176 + }, + { + "name": "GetMatrixTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 198 + }, + { + "name": "GetMatrixRoundtrip", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 203 + }, + { + "name": "GetMatrixTolerance", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 225 + }, + { + "name": "GetSparseMatrixTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 254 + }, + { + "name": "GetSparseMatrixConsistency", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 261 + }, + { + "name": "GetSparseMatrixTolerance", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 281 + }, + { + "name": "PrintMatrixTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 308 + }, + { + "name": "PrintMatrix", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 319 + }, + { + "name": "SizeTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 339 + }, + { + "name": "SizeBellState", + "file": "\/workspaces\/core\/test\/dd\/test_edge_functionality.cpp", + "line": 344 + } + ] + }, + { + "name": "DDFunctionality", + "tests": 12, + "testsuite": [ + { + "name": "BuildCircuit", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 245 + }, + { + "name": "NonUnitary", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 342 + }, + { + "name": "CircuitEquivalence", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 369 + }, + { + "name": "ChangePermutation", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 399 + }, + { + "name": "FuseTwoSingleQubitGates", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 424 + }, + { + "name": "FuseThreeSingleQubitGates", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 455 + }, + { + "name": "FuseNoSingleQubitGates", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 489 + }, + { + "name": "FuseSingleQubitGatesAcrossOtherGates", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 523 + }, + { + "name": "IfElseOperationConditions", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 556 + }, + { + "name": "IfElseOperationElseBranch", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 584 + }, + { + "name": "VectorKroneckerWithTerminal", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 601 + }, + { + "name": "DynamicCircuitSimulationWithSWAP", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 620 + } + ] + }, + { + "name": "CNTest", + "tests": 18, + "testsuite": [ + { + "name": "ComplexNumberCreation", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 42 + }, + { + "name": "NearZeroLookup", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 77 + }, + { + "name": "SortedBuckets", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 82 + }, + { + "name": "GarbageCollectSomeInBucket", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 114 + }, + { + "name": "LookupInNeighbouringBuckets", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 148 + }, + { + "name": "NumberPrintingToString", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 248 + }, + { + "name": "ComplexTableAllocation", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 427 + }, + { + "name": "DoubleHitInFindOrInsert", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 459 + }, + { + "name": "DoubleHitAcrossBuckets", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 478 + }, + { + "name": "exactlyZeroComparison", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 505 + }, + { + "name": "exactlyOneComparison", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 512 + }, + { + "name": "ExportConditionalFormat1", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 519 + }, + { + "name": "ExportConditionalFormat2", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 523 + }, + { + "name": "ExportConditionalFormat3", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 527 + }, + { + "name": "ExportConditionalFormat4", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 531 + }, + { + "name": "ExportConditionalFormat5", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 535 + }, + { + "name": "ExportConditionalFormat6", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 541 + }, + { + "name": "ExportConditionalFormat7", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 545 + } + ] + }, + { + "name": "DDComplexTest", + "tests": 5, + "testsuite": [ + { + "name": "LowestFractions", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 236 + }, + { + "name": "NumberPrintingFormattedFractions", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 265 + }, + { + "name": "NumberPrintingFormattedFractionsSqrt", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 325 + }, + { + "name": "NumberPrintingFormattedFractionsPi", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 371 + }, + { + "name": "NumberPrintingFormattedFloating", + "file": "\/workspaces\/core\/test\/dd\/test_complex.cpp", + "line": 417 + } + ] + }, + { + "name": "ApproximationTest", + "tests": 8, + "testsuite": [ + { + "name": "OneQubitKeepAllBudgetZero", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 45 + }, + { + "name": "OneQubitKeepAllBudgetTooSmall", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 78 + }, + { + "name": "OneQubitRemoveTerminalEdge", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 111 + }, + { + "name": "TwoQubitRemoveNode", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 144 + }, + { + "name": "TwoQubitCorrectlyRebuilt", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 190 + }, + { + "name": "ThreeQubitRemoveNodeWithChildren", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 241 + }, + { + "name": "ThreeQubitRemoveUnconnected", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 287 + }, + { + "name": "NodesVisited", + "file": "\/workspaces\/core\/test\/dd\/test_approximations.cpp", + "line": 334 + } + ] + }, + { + "name": "Parameters\/DDFunctionality", + "tests": 102, + "testsuite": [ + { + "name": "StandardOpBuildInverseBuild\/gphase", + "value_param": "gphase", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/i", + "value_param": "i", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/h", + "value_param": "h", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/x", + "value_param": "x", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/y", + "value_param": "y", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/z", + "value_param": "z", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/s", + "value_param": "s", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/sdg", + "value_param": "sdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/t", + "value_param": "t", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/tdg", + "value_param": "tdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/sx", + "value_param": "sx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/sxdg", + "value_param": "sxdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/v", + "value_param": "v", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/vdg", + "value_param": "vdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/u", + "value_param": "u", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/u2", + "value_param": "u2", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/p", + "value_param": "p", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/r", + "value_param": "r", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/rx", + "value_param": "rx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/ry", + "value_param": "ry", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/rz", + "value_param": "rz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/peres", + "value_param": "peres", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/peresdg", + "value_param": "peresdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/swap", + "value_param": "swap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/iswap", + "value_param": "iswap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/iswapdg", + "value_param": "iswapdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/dcx", + "value_param": "dcx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/ecr", + "value_param": "ecr", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/rxx", + "value_param": "rxx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/ryy", + "value_param": "ryy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/rzz", + "value_param": "rzz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/rzx", + "value_param": "rzx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/xx_minus_yy", + "value_param": "xx_minus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "StandardOpBuildInverseBuild\/xx_plus_yy", + "value_param": "xx_plus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 73 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/gphase", + "value_param": "gphase", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/i", + "value_param": "i", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/h", + "value_param": "h", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/x", + "value_param": "x", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/y", + "value_param": "y", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/z", + "value_param": "z", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/s", + "value_param": "s", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/sdg", + "value_param": "sdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/t", + "value_param": "t", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/tdg", + "value_param": "tdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/sx", + "value_param": "sx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/sxdg", + "value_param": "sxdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/v", + "value_param": "v", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/vdg", + "value_param": "vdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/u", + "value_param": "u", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/u2", + "value_param": "u2", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/p", + "value_param": "p", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/r", + "value_param": "r", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/rx", + "value_param": "rx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/ry", + "value_param": "ry", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/rz", + "value_param": "rz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/peres", + "value_param": "peres", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/peresdg", + "value_param": "peresdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/swap", + "value_param": "swap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/iswap", + "value_param": "iswap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/iswapdg", + "value_param": "iswapdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/dcx", + "value_param": "dcx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/ecr", + "value_param": "ecr", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/rxx", + "value_param": "rxx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/ryy", + "value_param": "ryy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/rzz", + "value_param": "rzz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/rzx", + "value_param": "rzx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/xx_minus_yy", + "value_param": "xx_minus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardOpBuildInverseBuild\/xx_plus_yy", + "value_param": "xx_plus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 129 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/gphase", + "value_param": "gphase", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/i", + "value_param": "i", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/h", + "value_param": "h", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/x", + "value_param": "x", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/y", + "value_param": "y", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/z", + "value_param": "z", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/s", + "value_param": "s", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/sdg", + "value_param": "sdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/t", + "value_param": "t", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/tdg", + "value_param": "tdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/sx", + "value_param": "sx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/sxdg", + "value_param": "sxdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/v", + "value_param": "v", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/vdg", + "value_param": "vdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/u", + "value_param": "u", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/u2", + "value_param": "u2", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/p", + "value_param": "p", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/r", + "value_param": "r", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/rx", + "value_param": "rx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/ry", + "value_param": "ry", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/rz", + "value_param": "rz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/peres", + "value_param": "peres", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/peresdg", + "value_param": "peresdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/swap", + "value_param": "swap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/iswap", + "value_param": "iswap", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/iswapdg", + "value_param": "iswapdg", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/dcx", + "value_param": "dcx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/ecr", + "value_param": "ecr", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/rxx", + "value_param": "rxx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/ryy", + "value_param": "ryy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/rzz", + "value_param": "rzz", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/rzx", + "value_param": "rzx", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/xx_minus_yy", + "value_param": "xx_minus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + }, + { + "name": "ControlledStandardNegOpBuildInverseBuild\/xx_plus_yy", + "value_param": "xx_plus_yy", + "file": "\/workspaces\/core\/test\/dd\/test_dd_functionality.cpp", + "line": 186 + } + ] + } + ] +} diff --git a/test/fomac/cmake_test_discovery_d92b282818.json b/test/fomac/cmake_test_discovery_d92b282818.json new file mode 100644 index 0000000000..ddb07275fa --- /dev/null +++ b/test/fomac/cmake_test_discovery_d92b282818.json @@ -0,0 +1,919 @@ +{ + "tests": 149, + "name": "AllTests", + "testsuites": [ + { + "name": "FoMaCTest", + "tests": 6, + "testsuite": [ + { + "name": "StatusToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 111 + }, + { + "name": "SitePropertyToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 128 + }, + { + "name": "OperationPropertyToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 151 + }, + { + "name": "DevicePropertyToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 175 + }, + { + "name": "SessionPropertyToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 207 + }, + { + "name": "ThrowIfError", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 211 + } + ] + }, + { + "name": "DDSimulatorDeviceTest", + "tests": 2, + "testsuite": [ + { + "name": "SubmitJobReturnsValidJob", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 538 + }, + { + "name": "SubmitJobPreservesNumShots", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 559 + } + ] + }, + { + "name": "JobTest", + "tests": 7, + "testsuite": [ + { + "name": "IdIsUnique", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 580 + }, + { + "name": "StatusProgresses", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 593 + }, + { + "name": "GetCountsReturnsValidHistogram", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 601 + }, + { + "name": "MultipleGetCountsCalls", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 621 + }, + { + "name": "GetShotsReturnsValidShots", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 630 + }, + { + "name": "CancelJob", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 654 + }, + { + "name": "CancelCompletedJobThrows", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 680 + } + ] + }, + { + "name": "SimulatorJobTest", + "tests": 4, + "testsuite": [ + { + "name": "getDenseStateVectorReturnsValidState", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 690 + }, + { + "name": "getDenseProbabilitiesReturnsValidProbabilities", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 704 + }, + { + "name": "getSparseStateVectorReturnsValidState", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 718 + }, + { + "name": "getSparseProbabilitiesReturnsValidProbabilities", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 735 + } + ] + }, + { + "name": "AuthenticationTest", + "tests": 10, + "testsuite": [ + { + "name": "SessionParameterToString", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 751 + }, + { + "name": "SessionConstructionWithToken", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 766 + }, + { + "name": "SessionConstructionWithAuthUrl", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 783 + }, + { + "name": "SessionConstructionWithAuthFile", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 845 + }, + { + "name": "SessionConstructionWithUsernamePassword", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 871 + }, + { + "name": "SessionConstructionWithProjectId", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 889 + }, + { + "name": "SessionConstructionWithMultipleParameters", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 895 + }, + { + "name": "SessionConstructionWithCustomParameters", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 904 + }, + { + "name": "SessionGetDevicesReturnsList", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 966 + }, + { + "name": "SessionMultipleInstances", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 979 + } + ] + }, + { + "name": "DeviceTest\/DeviceTest", + "tests": 45, + "testsuite": [ + { + "name": "Name\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 237 + }, + { + "name": "Name\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 237 + }, + { + "name": "Name\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 237 + }, + { + "name": "Version\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 241 + }, + { + "name": "Version\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 241 + }, + { + "name": "Version\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 241 + }, + { + "name": "Status\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 245 + }, + { + "name": "Status\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 245 + }, + { + "name": "Status\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 245 + }, + { + "name": "LibraryVersion\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 249 + }, + { + "name": "LibraryVersion\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 249 + }, + { + "name": "LibraryVersion\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 249 + }, + { + "name": "QubitsNum\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 253 + }, + { + "name": "QubitsNum\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 253 + }, + { + "name": "QubitsNum\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 253 + }, + { + "name": "Sites\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 257 + }, + { + "name": "Sites\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 257 + }, + { + "name": "Sites\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 257 + }, + { + "name": "CouplingMap\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 261 + }, + { + "name": "CouplingMap\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 261 + }, + { + "name": "CouplingMap\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 261 + }, + { + "name": "NeedsCalibration\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 265 + }, + { + "name": "NeedsCalibration\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 265 + }, + { + "name": "NeedsCalibration\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 265 + }, + { + "name": "LengthUnit\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 269 + }, + { + "name": "LengthUnit\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 269 + }, + { + "name": "LengthUnit\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 269 + }, + { + "name": "LengthScaleFactor\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 273 + }, + { + "name": "LengthScaleFactor\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 273 + }, + { + "name": "LengthScaleFactor\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 273 + }, + { + "name": "DurationUnit\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 277 + }, + { + "name": "DurationUnit\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 277 + }, + { + "name": "DurationUnit\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 277 + }, + { + "name": "DurationScaleFactor\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 281 + }, + { + "name": "DurationScaleFactor\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 281 + }, + { + "name": "DurationScaleFactor\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 281 + }, + { + "name": "MinAtomDistance\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 285 + }, + { + "name": "MinAtomDistance\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 285 + }, + { + "name": "MinAtomDistance\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 285 + }, + { + "name": "SupportedProgramFormats\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 289 + }, + { + "name": "SupportedProgramFormats\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 289 + }, + { + "name": "SupportedProgramFormats\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 289 + }, + { + "name": "RegularSitesAndZones\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 521 + }, + { + "name": "RegularSitesAndZones\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 521 + }, + { + "name": "RegularSitesAndZones\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 521 + } + ] + }, + { + "name": "SiteTest\/SiteTest", + "tests": 39, + "testsuite": [ + { + "name": "Index\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 293 + }, + { + "name": "Index\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 293 + }, + { + "name": "Index\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 293 + }, + { + "name": "T1\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 299 + }, + { + "name": "T1\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 299 + }, + { + "name": "T1\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 299 + }, + { + "name": "T2\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 305 + }, + { + "name": "T2\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 305 + }, + { + "name": "T2\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 305 + }, + { + "name": "Name\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 311 + }, + { + "name": "Name\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 311 + }, + { + "name": "Name\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 311 + }, + { + "name": "XCoordinate\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 317 + }, + { + "name": "XCoordinate\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 317 + }, + { + "name": "XCoordinate\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 317 + }, + { + "name": "YCoordinate\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 323 + }, + { + "name": "YCoordinate\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 323 + }, + { + "name": "YCoordinate\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 323 + }, + { + "name": "ZCoordinate\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 329 + }, + { + "name": "ZCoordinate\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 329 + }, + { + "name": "ZCoordinate\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 329 + }, + { + "name": "IsZone\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 335 + }, + { + "name": "IsZone\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 335 + }, + { + "name": "IsZone\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 335 + }, + { + "name": "XExtent\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 341 + }, + { + "name": "XExtent\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 341 + }, + { + "name": "XExtent\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 341 + }, + { + "name": "YExtent\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 347 + }, + { + "name": "YExtent\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 347 + }, + { + "name": "YExtent\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 347 + }, + { + "name": "ZExtent\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 353 + }, + { + "name": "ZExtent\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 353 + }, + { + "name": "ZExtent\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 353 + }, + { + "name": "ModuleIndex\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 359 + }, + { + "name": "ModuleIndex\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 359 + }, + { + "name": "ModuleIndex\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 359 + }, + { + "name": "SubmoduleIndex\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 365 + }, + { + "name": "SubmoduleIndex\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 365 + }, + { + "name": "SubmoduleIndex\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 365 + } + ] + }, + { + "name": "OperationTest\/OperationTest", + "tests": 36, + "testsuite": [ + { + "name": "Name\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 371 + }, + { + "name": "Name\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 371 + }, + { + "name": "Name\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 371 + }, + { + "name": "QubitsNum\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 377 + }, + { + "name": "QubitsNum\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 377 + }, + { + "name": "QubitsNum\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 377 + }, + { + "name": "ParametersNum\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 383 + }, + { + "name": "ParametersNum\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 383 + }, + { + "name": "ParametersNum\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 383 + }, + { + "name": "Duration\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 389 + }, + { + "name": "Duration\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 389 + }, + { + "name": "Duration\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 389 + }, + { + "name": "Fidelity\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 425 + }, + { + "name": "Fidelity\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 425 + }, + { + "name": "Fidelity\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 425 + }, + { + "name": "InteractionRadius\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 461 + }, + { + "name": "InteractionRadius\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 461 + }, + { + "name": "InteractionRadius\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 461 + }, + { + "name": "BlockingRadius\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 467 + }, + { + "name": "BlockingRadius\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 467 + }, + { + "name": "BlockingRadius\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 467 + }, + { + "name": "IdlingFidelity\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 473 + }, + { + "name": "IdlingFidelity\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 473 + }, + { + "name": "IdlingFidelity\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 473 + }, + { + "name": "IsZoned\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 479 + }, + { + "name": "IsZoned\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 479 + }, + { + "name": "IsZoned\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 479 + }, + { + "name": "Sites\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 485 + }, + { + "name": "Sites\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 485 + }, + { + "name": "Sites\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 485 + }, + { + "name": "SitePairs\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 491 + }, + { + "name": "SitePairs\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 491 + }, + { + "name": "SitePairs\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 491 + }, + { + "name": "MeanShuttlingSpeed\/MQT_NA_Default_QDMI_Device", + "value_param": "0x625fbfe62310", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 515 + }, + { + "name": "MeanShuttlingSpeed\/MQT_SC_Default_QDMI_Device", + "value_param": "0x625fbfe67d10", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 515 + }, + { + "name": "MeanShuttlingSpeed\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "0x625fbfe73520", + "file": "\/workspaces\/core\/test\/fomac\/test_fomac.cpp", + "line": 515 + } + ] + } + ] +} diff --git a/test/na/cmake_test_discovery_250b2f6e91.json b/test/na/cmake_test_discovery_250b2f6e91.json new file mode 100644 index 0000000000..f303f78e7f --- /dev/null +++ b/test/na/cmake_test_discovery_250b2f6e91.json @@ -0,0 +1,138 @@ +{ + "tests": 24, + "name": "AllTests", + "testsuites": [ + { + "name": "NAComputation", + "tests": 10, + "testsuite": [ + { + "name": "Atom", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 32 + }, + { + "name": "Zone", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 40 + }, + { + "name": "ZonesExtent", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 47 + }, + { + "name": "Location", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 55 + }, + { + "name": "LocalRXOp", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 66 + }, + { + "name": "LocalRZOp", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 72 + }, + { + "name": "General", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 78 + }, + { + "name": "EmptyPrint", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 126 + }, + { + "name": "GetPositionOfAtomAfterOperation", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 249 + }, + { + "name": "NonMovingAtomsViolateRowOrderConstraint", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 260 + } + ] + }, + { + "name": "NAComputationValidateAODConstraints", + "tests": 14, + "testsuite": [ + { + "name": "AtomAlreadyLoaded", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 157 + }, + { + "name": "AtomNotLoaded", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 165 + }, + { + "name": "DuplicateAtomsInShuttle", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 169 + }, + { + "name": "DuplicateEndPoints", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 176 + }, + { + "name": "ColumnPreserving1", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 183 + }, + { + "name": "RowPreserving1", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 190 + }, + { + "name": "ColumnPreserving2", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 197 + }, + { + "name": "RowPreserving2", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 204 + }, + { + "name": "ColumnPreserving3", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 212 + }, + { + "name": "RowPreserving3", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 219 + }, + { + "name": "DuplicateAtomsInRz", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 226 + }, + { + "name": "DuplicateAtoms", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 230 + }, + { + "name": "RowPreserving4", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 235 + }, + { + "name": "StoreStoredAtom", + "file": "\/workspaces\/core\/test\/na\/test_nacomputation.cpp", + "line": 242 + } + ] + } + ] +} diff --git a/test/na/fomac/cmake_test_discovery_d3ec408c45.json b/test/na/fomac/cmake_test_discovery_d3ec408c45.json new file mode 100644 index 0000000000..3b5c38512b --- /dev/null +++ b/test/na/fomac/cmake_test_discovery_d3ec408c45.json @@ -0,0 +1,22 @@ +{ + "tests": 2, + "name": "AllTests", + "testsuites": [ + { + "name": "TestNAFoMaC", + "tests": 2, + "testsuite": [ + { + "name": "TrapsJSONRoundTrip", + "file": "\/workspaces\/core\/test\/na\/fomac\/test_fomac.cpp", + "line": 35 + }, + { + "name": "FullJSONRoundTrip", + "file": "\/workspaces\/core\/test\/na\/fomac\/test_fomac.cpp", + "line": 51 + } + ] + } + ] +} diff --git a/test/qdmi/devices/dd/cmake_test_discovery_e4d6740af8.json b/test/qdmi/devices/dd/cmake_test_discovery_e4d6740af8.json new file mode 100644 index 0000000000..9b7f6fe272 --- /dev/null +++ b/test/qdmi/devices/dd/cmake_test_discovery_e4d6740af8.json @@ -0,0 +1,264 @@ +{ + "tests": 36, + "name": "AllTests", + "testsuites": [ + { + "name": "DeviceStatus", + "tests": 2, + "testsuite": [ + { + "name": "TransitionsBusyThenIdleAfterJob", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_status_test.cpp", + "line": 35 + }, + { + "name": "MultipleConcurrentJobsKeepBusyUntilLastFinishes", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_status_test.cpp", + "line": 69 + } + ] + }, + { + "name": "Concurrency", + "tests": 3, + "testsuite": [ + { + "name": "ConcurrentStatevectorReads", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/concurrency_test.cpp", + "line": 27 + }, + { + "name": "ConcurrentHistogramReads", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/concurrency_test.cpp", + "line": 58 + }, + { + "name": "ConcurrentCheckDuringRun", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/concurrency_test.cpp", + "line": 97 + } + ] + }, + { + "name": "ErrorHandling", + "tests": 6, + "testsuite": [ + { + "name": "NullptrArguments", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 31 + }, + { + "name": "GetResultsBeforeDone", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 74 + }, + { + "name": "MaxEnums", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 94 + }, + { + "name": "CustomEnums", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 139 + }, + { + "name": "BadState", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 263 + }, + { + "name": "MalformedProgramFailsForBothModes", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/error_handling_test.cpp", + "line": 291 + } + ] + }, + { + "name": "ResultsProbabilities", + "tests": 2, + "testsuite": [ + { + "name": "DenseSumToOneAndBufferTooSmall", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_probabilities_test.cpp", + "line": 24 + }, + { + "name": "SparseSumToOneAndBufferTooSmall", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_probabilities_test.cpp", + "line": 52 + } + ] + }, + { + "name": "ResultsStatevector", + "tests": 3, + "testsuite": [ + { + "name": "DenseNormalizedAndBufferTooSmall", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_statevector_test.cpp", + "line": 25 + }, + { + "name": "SparseNormalizedAndBufferTooSmall", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_statevector_test.cpp", + "line": 53 + }, + { + "name": "HistogramRequestsInvalidWithShotsZero", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_statevector_test.cpp", + "line": 90 + } + ] + }, + { + "name": "ResultsSampling", + "tests": 3, + "testsuite": [ + { + "name": "HistogramKeysAndValuesSumToShots", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_sampling_test.cpp", + "line": 24 + }, + { + "name": "BufferTooSmallErrors", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_sampling_test.cpp", + "line": 43 + }, + { + "name": "StateAndProbRequestsAreInvalidWhenShotsPositive", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/results_sampling_test.cpp", + "line": 72 + } + ] + }, + { + "name": "JobLifecycle", + "tests": 6, + "testsuite": [ + { + "name": "SubmitAndWaitSampling", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 24 + }, + { + "name": "SubmitAndWaitStatevector", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 34 + }, + { + "name": "WaitInvalidBeforeSubmitAndIdempotentAfterDone", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 44 + }, + { + "name": "WaitTimeoutPath", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 59 + }, + { + "name": "CancelFromCreatedAndFromRunningAndFromDone", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 75 + }, + { + "name": "FreeWhileRunningWaitsForCompletion", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_lifecycle_test.cpp", + "line": 108 + } + ] + }, + { + "name": "JobParameters", + "tests": 2, + "testsuite": [ + { + "name": "SetAndQueryBasics", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_parameters_test.cpp", + "line": 25 + }, + { + "name": "ProgramFormatSupport", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/job_parameters_test.cpp", + "line": 88 + } + ] + }, + { + "name": "SessionLifecycle", + "tests": 2, + "testsuite": [ + { + "name": "AllocAndInit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/session_lifecycle_test.cpp", + "line": 23 + }, + { + "name": "InitBadStateAndInvalidArg", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/session_lifecycle_test.cpp", + "line": 28 + } + ] + }, + { + "name": "SessionParameters", + "tests": 1, + "testsuite": [ + { + "name": "SetParameterBehaviors", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/session_lifecycle_test.cpp", + "line": 41 + } + ] + }, + { + "name": "DeviceProperties", + "tests": 4, + "testsuite": [ + { + "name": "BasicStringsAndSizes", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 27 + }, + { + "name": "UnitsAndScales", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 68 + }, + { + "name": "SitesAndOperationsLists", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 113 + }, + { + "name": "QubitsNumAvailable", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 123 + } + ] + }, + { + "name": "SiteProperties", + "tests": 1, + "testsuite": [ + { + "name": "IndexAvailable", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 133 + } + ] + }, + { + "name": "OperationProperties", + "tests": 1, + "testsuite": [ + { + "name": "BasicQueries", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/dd\/device_properties_test.cpp", + "line": 151 + } + ] + } + ] +} diff --git a/test/qdmi/devices/na/cmake_test_discovery_c9108a12c6.json b/test/qdmi/devices/na/cmake_test_discovery_c9108a12c6.json new file mode 100644 index 0000000000..873239bdcf --- /dev/null +++ b/test/qdmi/devices/na/cmake_test_discovery_c9108a12c6.json @@ -0,0 +1,291 @@ +{ + "tests": 51, + "name": "AllTests", + "testsuites": [ + { + "name": "NaQDMISpecificationTest", + "tests": 23, + "testsuite": [ + { + "name": "SessionAlloc", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 148 + }, + { + "name": "SessionInit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 153 + }, + { + "name": "SessionSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 159 + }, + { + "name": "JobCreate", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 177 + }, + { + "name": "JobSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 194 + }, + { + "name": "JobQueryProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 211 + }, + { + "name": "JobSubmit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 241 + }, + { + "name": "JobCancel", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 250 + }, + { + "name": "JobCheck", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 260 + }, + { + "name": "JobWait", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 271 + }, + { + "name": "JobGetResults", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 282 + }, + { + "name": "QueryDeviceProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 297 + }, + { + "name": "QuerySiteProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 317 + }, + { + "name": "QueryOperationProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 334 + }, + { + "name": "QueryDeviceName", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 350 + }, + { + "name": "QueryDeviceVersion", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 365 + }, + { + "name": "QueryDeviceLibraryVersion", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 380 + }, + { + "name": "QueryDeviceLengthUnit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 396 + }, + { + "name": "QueryDeviceDurationUnit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 417 + }, + { + "name": "QueryDeviceMinAtomDistance", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 438 + }, + { + "name": "QuerySiteIndex", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 446 + }, + { + "name": "QueryOperationName", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 457 + }, + { + "name": "QueryDeviceQubitNum", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 474 + } + ] + }, + { + "name": "NaQDMIJobSpecificationTest", + "tests": 8, + "testsuite": [ + { + "name": "JobSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 200 + }, + { + "name": "JobQueryProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 217 + }, + { + "name": "QueryJobId", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 226 + }, + { + "name": "JobSubmit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 245 + }, + { + "name": "JobCancel", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 254 + }, + { + "name": "JobCheck", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 265 + }, + { + "name": "JobWait", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 276 + }, + { + "name": "JobGetResults", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 288 + } + ] + }, + { + "name": "NADeviceTest", + "tests": 2, + "testsuite": [ + { + "name": "QuerySiteData", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 510 + }, + { + "name": "QueryOperationData", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_device.cpp", + "line": 589 + } + ] + }, + { + "name": "NaExecutableTest", + "tests": 13, + "testsuite": [ + { + "name": "Version", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 31 + }, + { + "name": "MissingSubcommand", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 59 + }, + { + "name": "UnknownSubcommand", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 81 + }, + { + "name": "SchemaUnknownOption", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 103 + }, + { + "name": "SchemaMissingFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 125 + }, + { + "name": "ValidateInvalidJson", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 147 + }, + { + "name": "GenerateMissingFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 162 + }, + { + "name": "Usage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 184 + }, + { + "name": "SchemaUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 208 + }, + { + "name": "ValidateUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 232 + }, + { + "name": "GenerateUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 256 + }, + { + "name": "RoundTrip", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 280 + }, + { + "name": "RoundTripFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_app.cpp", + "line": 323 + } + ] + }, + { + "name": "NaGeneratorTest", + "tests": 5, + "testsuite": [ + { + "name": "WriteJSONSchema", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_generator.cpp", + "line": 43 + }, + { + "name": "DurationUnitNanosecond", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_generator.cpp", + "line": 55 + }, + { + "name": "DurationUnitInvalid", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_generator.cpp", + "line": 68 + }, + { + "name": "LengthUnitNanometer", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_generator.cpp", + "line": 78 + }, + { + "name": "LengthUnitInvalid", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/na\/test_generator.cpp", + "line": 91 + } + ] + } + ] +} diff --git a/test/qdmi/devices/sc/cmake_test_discovery_b685f933aa.json b/test/qdmi/devices/sc/cmake_test_discovery_b685f933aa.json new file mode 100644 index 0000000000..e0148fb5ea --- /dev/null +++ b/test/qdmi/devices/sc/cmake_test_discovery_b685f933aa.json @@ -0,0 +1,230 @@ +{ + "tests": 40, + "name": "AllTests", + "testsuites": [ + { + "name": "ScQDMISpecificationTest", + "tests": 18, + "testsuite": [ + { + "name": "SessionAlloc", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 93 + }, + { + "name": "SessionInit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 98 + }, + { + "name": "SessionSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 104 + }, + { + "name": "JobCreate", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 123 + }, + { + "name": "JobSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 141 + }, + { + "name": "JobQueryProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 158 + }, + { + "name": "JobSubmit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 188 + }, + { + "name": "JobCancel", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 197 + }, + { + "name": "JobCheck", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 207 + }, + { + "name": "JobWait", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 218 + }, + { + "name": "JobGetResults", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 229 + }, + { + "name": "QueryDeviceProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 244 + }, + { + "name": "QuerySiteProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 264 + }, + { + "name": "QueryDeviceName", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 281 + }, + { + "name": "QueryDeviceVersion", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 296 + }, + { + "name": "QueryDeviceLibraryVersion", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 311 + }, + { + "name": "QuerySiteIndex", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 327 + }, + { + "name": "QueryDeviceQubitNum", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 338 + } + ] + }, + { + "name": "ScQDMIJobSpecificationTest", + "tests": 8, + "testsuite": [ + { + "name": "JobSetParameter", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 147 + }, + { + "name": "JobQueryProperty", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 164 + }, + { + "name": "QueryJobId", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 173 + }, + { + "name": "JobSubmit", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 192 + }, + { + "name": "JobCancel", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 201 + }, + { + "name": "JobCheck", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 212 + }, + { + "name": "JobWait", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 223 + }, + { + "name": "JobGetResults", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_device.cpp", + "line": 235 + } + ] + }, + { + "name": "ScExecutableTest", + "tests": 13, + "testsuite": [ + { + "name": "Version", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 31 + }, + { + "name": "MissingSubcommand", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 59 + }, + { + "name": "UnknownSubcommand", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 81 + }, + { + "name": "SchemaUnknownOption", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 103 + }, + { + "name": "SchemaMissingFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 125 + }, + { + "name": "ValidateInvalidJson", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 147 + }, + { + "name": "GenerateMissingFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 162 + }, + { + "name": "Usage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 184 + }, + { + "name": "SchemaUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 208 + }, + { + "name": "ValidateUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 232 + }, + { + "name": "GenerateUsage", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 256 + }, + { + "name": "RoundTrip", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 280 + }, + { + "name": "RoundTripFile", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_app.cpp", + "line": 323 + } + ] + }, + { + "name": "ScGeneratorTest", + "tests": 1, + "testsuite": [ + { + "name": "WriteJSONSchema", + "file": "\/workspaces\/core\/test\/qdmi\/devices\/sc\/test_generator.cpp", + "line": 41 + } + ] + } + ] +} diff --git a/test/qdmi/driver/cmake_test_discovery_19da466dc8.json b/test/qdmi/driver/cmake_test_discovery_19da466dc8.json new file mode 100644 index 0000000000..6a6f038f57 --- /dev/null +++ b/test/qdmi/driver/cmake_test_discovery_19da466dc8.json @@ -0,0 +1,574 @@ +{ + "tests": 92, + "name": "AllTests", + "testsuites": [ + { + "name": "DeviceSessionConfigTest", + "tests": 7, + "testsuite": [ + { + "name": "AddDynamicDeviceLibraryWithBaseUrl", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 522 + }, + { + "name": "AddDynamicDeviceLibraryWithCustomParameters", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 532 + }, + { + "name": "AddDynamicDeviceLibraryWithAuthToken", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 556 + }, + { + "name": "AddDynamicDeviceLibraryWithAuthFile", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 567 + }, + { + "name": "AddDynamicDeviceLibraryWithUsernamePassword", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 579 + }, + { + "name": "AddDynamicDeviceLibraryWithAllParameters", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 591 + }, + { + "name": "IdempotentLoadingWithDifferentConfigs", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 621 + } + ] + }, + { + "name": "DynamicDeviceLibraryTest", + "tests": 1, + "testsuite": [ + { + "name": "addDynamicDeviceLibraryReturnsDevice", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 654 + } + ] + }, + { + "name": "DefaultDevices\/DriverTest", + "tests": 63, + "testsuite": [ + { + "name": "SessionSetParameter\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 127 + }, + { + "name": "SessionSetParameter\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 127 + }, + { + "name": "SessionSetParameter\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 127 + }, + { + "name": "JobCreate\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 146 + }, + { + "name": "JobCreate\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 146 + }, + { + "name": "JobCreate\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 146 + }, + { + "name": "JobSetParameter\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 154 + }, + { + "name": "JobSetParameter\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 154 + }, + { + "name": "JobSetParameter\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 154 + }, + { + "name": "JobQueryProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 175 + }, + { + "name": "JobQueryProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 175 + }, + { + "name": "JobQueryProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 175 + }, + { + "name": "JobSubmit\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 215 + }, + { + "name": "JobSubmit\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 215 + }, + { + "name": "JobSubmit\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 215 + }, + { + "name": "JobCancel\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 224 + }, + { + "name": "JobCancel\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 224 + }, + { + "name": "JobCancel\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 224 + }, + { + "name": "JobCheck\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 234 + }, + { + "name": "JobCheck\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 234 + }, + { + "name": "JobCheck\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 234 + }, + { + "name": "JobWait\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 244 + }, + { + "name": "JobWait\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 244 + }, + { + "name": "JobWait\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 244 + }, + { + "name": "JobGetResults\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 254 + }, + { + "name": "JobGetResults\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 254 + }, + { + "name": "JobGetResults\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 254 + }, + { + "name": "QueryDeviceProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 267 + }, + { + "name": "QueryDeviceProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 267 + }, + { + "name": "QueryDeviceProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 267 + }, + { + "name": "QuerySiteProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 276 + }, + { + "name": "QuerySiteProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 276 + }, + { + "name": "QuerySiteProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 276 + }, + { + "name": "QueryOperationProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 285 + }, + { + "name": "QueryOperationProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 285 + }, + { + "name": "QueryOperationProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 285 + }, + { + "name": "QueryDeviceVersion\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 296 + }, + { + "name": "QueryDeviceVersion\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 296 + }, + { + "name": "QueryDeviceVersion\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 296 + }, + { + "name": "QueryDeviceLibraryVersion\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 311 + }, + { + "name": "QueryDeviceLibraryVersion\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 311 + }, + { + "name": "QueryDeviceLibraryVersion\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 311 + }, + { + "name": "QueryNumQubits\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 326 + }, + { + "name": "QueryNumQubits\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 326 + }, + { + "name": "QueryNumQubits\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 326 + }, + { + "name": "QuerySites\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 336 + }, + { + "name": "QuerySites\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 336 + }, + { + "name": "QuerySites\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 336 + }, + { + "name": "QueryOperations\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 380 + }, + { + "name": "QueryOperations\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 380 + }, + { + "name": "QueryOperations\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 380 + }, + { + "name": "SessionAlloc\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 455 + }, + { + "name": "SessionAlloc\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 455 + }, + { + "name": "SessionAlloc\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 455 + }, + { + "name": "SessionInit\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 459 + }, + { + "name": "SessionInit\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 459 + }, + { + "name": "SessionInit\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 459 + }, + { + "name": "QuerySessionProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 466 + }, + { + "name": "QuerySessionProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 466 + }, + { + "name": "QuerySessionProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 466 + }, + { + "name": "QueryNeedsCalibration\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 493 + }, + { + "name": "QueryNeedsCalibration\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 493 + }, + { + "name": "QueryNeedsCalibration\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 493 + } + ] + }, + { + "name": "DefaultDevices\/DriverJobTest", + "tests": 21, + "testsuite": [ + { + "name": "JobSetParameter\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 159 + }, + { + "name": "JobSetParameter\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 159 + }, + { + "name": "JobSetParameter\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 159 + }, + { + "name": "JobQueryProperty\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 181 + }, + { + "name": "JobQueryProperty\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 181 + }, + { + "name": "JobQueryProperty\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 181 + }, + { + "name": "JobSubmit\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 219 + }, + { + "name": "JobSubmit\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 219 + }, + { + "name": "JobSubmit\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 219 + }, + { + "name": "JobCancel\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 228 + }, + { + "name": "JobCancel\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 228 + }, + { + "name": "JobCancel\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 228 + }, + { + "name": "JobCheck\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 238 + }, + { + "name": "JobCheck\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 238 + }, + { + "name": "JobCheck\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 238 + }, + { + "name": "JobWait\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 248 + }, + { + "name": "JobWait\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 248 + }, + { + "name": "JobWait\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 248 + }, + { + "name": "JobGetResults\/MQT_NA_Default_QDMI_Device", + "value_param": "\"MQT NA Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 260 + }, + { + "name": "JobGetResults\/MQT_Core_DDSIM_QDMI_Device", + "value_param": "\"MQT Core DDSIM QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 260 + }, + { + "name": "JobGetResults\/MQT_SC_Default_QDMI_Device", + "value_param": "\"MQT SC Default QDMI Device\"", + "file": "\/workspaces\/core\/test\/qdmi\/driver\/test_driver.cpp", + "line": 260 + } + ] + } + ] +} diff --git a/test/qir/runner/cmake_test_discovery_f490d2a913.json b/test/qir/runner/cmake_test_discovery_f490d2a913.json new file mode 100644 index 0000000000..1cc65c36e8 --- /dev/null +++ b/test/qir/runner/cmake_test_discovery_f490d2a913.json @@ -0,0 +1,30 @@ +{ + "tests": 3, + "name": "AllTests", + "testsuites": [ + { + "name": "QIRRunnerTest\/QIRRunnerTest", + "tests": 3, + "testsuite": [ + { + "name": "QIRFile\/BellPairDynamic", + "value_param": "\"\/workspaces\/core\/test\/qir\/BellPairDynamic.ll\"", + "file": "\/workspaces\/core\/test\/qir\/runner\/test_qir_runner.cpp", + "line": 37 + }, + { + "name": "QIRFile\/BellPairStatic", + "value_param": "\"\/workspaces\/core\/test\/qir\/BellPairStatic.ll\"", + "file": "\/workspaces\/core\/test\/qir\/runner\/test_qir_runner.cpp", + "line": 37 + }, + { + "name": "QIRFile\/GHZ4Dynamic", + "value_param": "\"\/workspaces\/core\/test\/qir\/GHZ4Dynamic.ll\"", + "file": "\/workspaces\/core\/test\/qir\/runner\/test_qir_runner.cpp", + "line": 37 + } + ] + } + ] +} diff --git a/test/qir/runtime/cmake_test_discovery_a54bc9ca40.json b/test/qir/runtime/cmake_test_discovery_a54bc9ca40.json new file mode 100644 index 0000000000..b22ad9692f --- /dev/null +++ b/test/qir/runtime/cmake_test_discovery_a54bc9ca40.json @@ -0,0 +1,296 @@ +{ + "tests": 55, + "name": "AllTests", + "testsuites": [ + { + "name": "QIRRuntimeTest", + "tests": 52, + "testsuite": [ + { + "name": "XGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 45 + }, + { + "name": "YGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 51 + }, + { + "name": "ZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 57 + }, + { + "name": "HGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 63 + }, + { + "name": "SGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 69 + }, + { + "name": "SdgGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 75 + }, + { + "name": "SXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 81 + }, + { + "name": "SXdgGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 87 + }, + { + "name": "SqrtXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 93 + }, + { + "name": "SqrtXdgGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 99 + }, + { + "name": "TGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 105 + }, + { + "name": "TdgGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 111 + }, + { + "name": "RGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 117 + }, + { + "name": "PRXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 123 + }, + { + "name": "RXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 129 + }, + { + "name": "RYGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 135 + }, + { + "name": "RZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 141 + }, + { + "name": "PGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 147 + }, + { + "name": "RXXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 153 + }, + { + "name": "RYYGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 160 + }, + { + "name": "RZZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 167 + }, + { + "name": "RZXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 174 + }, + { + "name": "UGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 181 + }, + { + "name": "U3Gate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 187 + }, + { + "name": "U2Gate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 193 + }, + { + "name": "U1Gate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 199 + }, + { + "name": "CU1Gate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 205 + }, + { + "name": "CU3Gate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 212 + }, + { + "name": "CNotGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 219 + }, + { + "name": "CXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 226 + }, + { + "name": "CYGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 233 + }, + { + "name": "CZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 240 + }, + { + "name": "CHGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 247 + }, + { + "name": "SwapGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 254 + }, + { + "name": "CSwapGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 269 + }, + { + "name": "CRZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 277 + }, + { + "name": "CRYGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 284 + }, + { + "name": "CRXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 291 + }, + { + "name": "CPGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 298 + }, + { + "name": "CCXGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 305 + }, + { + "name": "CCYGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 313 + }, + { + "name": "CCZGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 321 + }, + { + "name": "MGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 329 + }, + { + "name": "MeasureGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 335 + }, + { + "name": "MzGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 341 + }, + { + "name": "ResetGate", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 348 + }, + { + "name": "BellPairStatic", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 354 + }, + { + "name": "BellPairDynamic", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 372 + }, + { + "name": "BellPairStaticReverse", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 392 + }, + { + "name": "BellPairDynamicReverse", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 410 + }, + { + "name": "GHZ4Static", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 430 + }, + { + "name": "GHZ4Dynamic", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 459 + } + ] + }, + { + "name": "QIRExecutablesTest\/QIRFilesTest", + "tests": 3, + "testsuite": [ + { + "name": "Executables\/mqt_core_qir_bell_pair_dynamic_ll", + "value_param": "\"\/workspaces\/core\/build\/release\/test\/qir\/runtime\/mqt-core-qir-bell-pair-dynamic-ll\"", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 528 + }, + { + "name": "Executables\/mqt_core_qir_bell_pair_static_ll", + "value_param": "\"\/workspaces\/core\/build\/release\/test\/qir\/runtime\/mqt-core-qir-bell-pair-static-ll\"", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 528 + }, + { + "name": "Executables\/mqt_core_qir_g_h_z4_dynamic_ll", + "value_param": "\"\/workspaces\/core\/build\/release\/test\/qir\/runtime\/mqt-core-qir-g-h-z4-dynamic-ll\"", + "file": "\/workspaces\/core\/test\/qir\/runtime\/test_qir_runtime.cpp", + "line": 528 + } + ] + } + ] +} diff --git a/test/zx/cmake_test_discovery_de31622abe.json b/test/zx/cmake_test_discovery_de31622abe.json new file mode 100644 index 0000000000..7e6f7b271f --- /dev/null +++ b/test/zx/cmake_test_discovery_de31622abe.json @@ -0,0 +1,566 @@ +{ + "tests": 106, + "name": "AllTests", + "testsuites": [ + { + "name": "ZXFunctionalityTest", + "tests": 45, + "testsuite": [ + { + "name": "parseQasm", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 64 + }, + { + "name": "complexCircuit", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 116 + }, + { + "name": "nestedCompoundGate", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 155 + }, + { + "name": "Phase", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 174 + }, + { + "name": "Compound", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 189 + }, + { + "name": "CRZ", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 207 + }, + { + "name": "CCZ", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 221 + }, + { + "name": "MCX", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 234 + }, + { + "name": "MCX0", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 245 + }, + { + "name": "MCX1", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 256 + }, + { + "name": "MCZ", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 268 + }, + { + "name": "MCZ0", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 279 + }, + { + "name": "MCZ1", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 290 + }, + { + "name": "MCZ2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 301 + }, + { + "name": "MCRZ", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 314 + }, + { + "name": "MCRZ0", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 326 + }, + { + "name": "MCRZ1", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 337 + }, + { + "name": "UnsupportedControl", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 348 + }, + { + "name": "UnsupportedControl2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 358 + }, + { + "name": "UnsupportedControl3", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 368 + }, + { + "name": "UnsupportedTwoTargetControl", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 378 + }, + { + "name": "InitialLayout", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 388 + }, + { + "name": "FromSymbolic", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 404 + }, + { + "name": "RZ", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 417 + }, + { + "name": "ISWAP", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 427 + }, + { + "name": "XXplusYY", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 443 + }, + { + "name": "XXminusYY", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 469 + }, + { + "name": "SWAP", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 495 + }, + { + "name": "CSWAP", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 507 + }, + { + "name": "MCSWAP", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 519 + }, + { + "name": "MCRzz", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 531 + }, + { + "name": "MCRxx", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 542 + }, + { + "name": "MCRzx", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 553 + }, + { + "name": "MCRx0", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 564 + }, + { + "name": "MCRx1", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 573 + }, + { + "name": "MCRx2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 582 + }, + { + "name": "MCRx3", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 591 + }, + { + "name": "MCPhase", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 600 + }, + { + "name": "MCS", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 610 + }, + { + "name": "MCSdg", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 620 + }, + { + "name": "MCT", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 630 + }, + { + "name": "MCTdg", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 640 + }, + { + "name": "MCPhase2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 650 + }, + { + "name": "MCS2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 660 + }, + { + "name": "MCT2", + "file": "\/workspaces\/core\/test\/zx\/test_zx_functionality.cpp", + "line": 670 + } + ] + }, + { + "name": "ZXDiagramTest", + "tests": 11, + "testsuite": [ + { + "name": "createDiagram", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 61 + }, + { + "name": "deletions", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 105 + }, + { + "name": "graphLike", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 116 + }, + { + "name": "adjoint", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 151 + }, + { + "name": "approximate", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 186 + }, + { + "name": "ancilla", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 201 + }, + { + "name": "RemoveScalarSubDiagram", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 233 + }, + { + "name": "AdjMat", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 248 + }, + { + "name": "ConnectedSet", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 266 + }, + { + "name": "EdgeTypePrinting", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 281 + }, + { + "name": "VertexTypePrinting", + "file": "\/workspaces\/core\/test\/zx\/test_zx.cpp", + "line": 304 + } + ] + }, + { + "name": "SimplifyTest", + "tests": 19, + "testsuite": [ + { + "name": "idSimp", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 63 + }, + { + "name": "idSimp2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 76 + }, + { + "name": "spiderFusion", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 91 + }, + { + "name": "spiderFusion2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 110 + }, + { + "name": "spiderFusionParallelEdges", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 133 + }, + { + "name": "localComp", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 148 + }, + { + "name": "pivotPauli", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 194 + }, + { + "name": "interiorClifford", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 242 + }, + { + "name": "interiorClifford2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 257 + }, + { + "name": "nonPauliPivot", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 287 + }, + { + "name": "pauliPivot2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 315 + }, + { + "name": "gadgetSimp", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 335 + }, + { + "name": "gadgetSimp2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 367 + }, + { + "name": "fullReduce2", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 392 + }, + { + "name": "fullReduceApprox", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 423 + }, + { + "name": "fullReduceNotApprox", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 454 + }, + { + "name": "idSymbolic", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 485 + }, + { + "name": "equivalenceSymbolic", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 504 + }, + { + "name": "OnlyDeletedVertices", + "file": "\/workspaces\/core\/test\/zx\/test_simplify.cpp", + "line": 594 + } + ] + }, + { + "name": "RationalTest", + "tests": 16, + "testsuite": [ + { + "name": "normalize", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 24 + }, + { + "name": "fromDouble", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 29 + }, + { + "name": "fromDouble2", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 34 + }, + { + "name": "fromDouble3", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 39 + }, + { + "name": "fromDouble4", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 44 + }, + { + "name": "fromDouble5", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 49 + }, + { + "name": "fromDouble6", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 54 + }, + { + "name": "add", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 59 + }, + { + "name": "add2", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 67 + }, + { + "name": "sub", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 75 + }, + { + "name": "sub2", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 83 + }, + { + "name": "mul", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 91 + }, + { + "name": "mul2", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 99 + }, + { + "name": "div", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 107 + }, + { + "name": "approximateDivPi", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 115 + }, + { + "name": "approximate", + "file": "\/workspaces\/core\/test\/zx\/test_rational.cpp", + "line": 120 + } + ] + }, + { + "name": "ExpressionTest", + "tests": 15, + "testsuite": [ + { + "name": "basicOps1", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 36 + }, + { + "name": "basicOps2", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 56 + }, + { + "name": "mult", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 84 + }, + { + "name": "div", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 104 + }, + { + "name": "Commutativity", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 118 + }, + { + "name": "Associativity", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 127 + }, + { + "name": "Distributive", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 136 + }, + { + "name": "Variable", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 148 + }, + { + "name": "SumNegation", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 155 + }, + { + "name": "SumMult", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 164 + }, + { + "name": "CliffordRounding", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 169 + }, + { + "name": "Clifford", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 182 + }, + { + "name": "Convertability", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 200 + }, + { + "name": "Instantiation", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 207 + }, + { + "name": "Arithmetic", + "file": "\/workspaces\/core\/test\/zx\/test_expression.cpp", + "line": 220 + } + ] + } + ] +}