Quantum compiler efficiency evaluation method based on metamorphic test
By using a metamorphic test-based method, an executable random circuit that meets physical constraints is generated and compiled. A gate-level dependency graph is constructed for isomorphism determination, which solves the problem of difficult cross-chip topology comparison in the efficiency evaluation of quantum compilers and achieves efficient efficiency evaluation and location of efficiency bottlenecks.
Patent Information
- Application Number
- CN202511896746.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technologies for evaluating the efficiency of quantum compilers suffer from problems such as reliance on external optimal solutions, difficulty in distinguishing between the initial mapping and routing stages, difficulty in cross-chip topology comparison, insufficient coverage, and difficulty in operating efficiently in large-scale circuits.
A metamorphic test-based approach is adopted. By generating executable random circuits that meet physical constraints and compiling them, a gate-level dependency graph is constructed for isomorphism determination. An evaluation report is generated by combining the optimal fragment compilation and scheduling, and the number of swapped gates and the total number of two-bit gates are evaluated.
It enables comparability evaluation across different chip topologies and compilers, can distinguish and locate efficiency issues in the initial mapping and routing stages, has good coverage and scalability, and is suitable for version regression testing and cross-platform evaluation.
Smart Images

Figure CN121745328A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of quantum computing and software testing, and particularly relates to a quantum compiler efficiency evaluation method based on transmutation testing. BACKGROUND
[0002] A quantum compiler is used to convert a high-level quantum program (such as a circuit described in a language such as QASM) into an executable circuit that meets the physical constraints of a target quantum chip. A typical process includes: initial mapping (allocating logical qubits to physical bits), layout and routing adjustment (inserting swap gates to meet the adjacency constraints on the coupling graph), and necessary scheduling and equivalence transformation. In the current noise intermediate-scale quantum (NISQ) stage, the coupling graph of the chip is sparse, and the fault tolerance rate of the two-bit gate is low. The insertion of the swap gate will significantly increase the circuit depth and the total number of two-bit gates, thereby deteriorating the actual execution effect. Therefore, evaluating the "efficiency" (such as the number of swap gates, the total number of two-bit gates, gate depth, and other indicators) of the compiler under different topologies and scales has become a basic requirement in engineering and research.
[0003] The prior art mainly has the following limitations in compiler efficiency evaluation and testing:
[0004] 1. Coarse-grained evaluation based on static indicators. The common practice is to count the total number of two-bit gates, the number of swap gates, gate depth, and other proxy indicators after compilation. This method is simple to implement, but it is difficult to determine whether the newly added structure is a non-essential change, and it cannot distinguish whether the efficiency problem is caused by the initial mapping or the routing stage. The comparability of these indicators between different chip topologies is also weak, and is easily affected by hardware connectivity and directionality.
[0005] 2. Comparative evaluation relying on "external optimal solution". Some studies attempt to use exact solution or exhaustive search to give the optimal compilation result of a small-scale circuit on a given coupling graph, which is used as a "gold standard" for comparison. However, the computational overhead of exact solution grows exponentially with the number of bits and gates, making it only suitable for very small scales and difficult to cover actual scenarios. Moreover, it is too costly to generalize the optimal solution to larger scales or different topologies, and it lacks engineering usability.
[0006] 3. Multi-compiler differential testing. By calling multiple compilers or routing strategies on the same input, the output indicators or structural differences are compared to identify abnormalities. This method does not rely on an optimal solution, but it has the problem that "majority agreement does not mean optimality". The equivalence transformation within different compilers may cause structural differences while maintaining functional equivalence, making it difficult to locate efficiency bottlenecks. In addition, it is difficult to attribute to a specific stage (initial mapping or routing).
[0007] 4. Regression testing based on "gold sample / baseline files". A fixed version of QASM or circuit netlist is used as the baseline; subsequent versions with different outputs are considered regressions. This method is extremely sensitive to formatting or harmless rewriting, easily resulting in numerous "false positives." It is also insensitive to efficiency changes, making it difficult to reflect true performance degradation and improvement.
[0008] 5. Formal equivalence verification and simulation evaluation. Formal verification can guarantee functional equivalence to a certain extent, but it is costly for large-scale circuits; simulation evaluation based on noise models or hardware backends is closer to the physical effect, but it is limited by model accuracy and operating cost, and it is difficult to use frequently in R&D iterations.
[0009] In addition to the methodological issues mentioned above, engineering practice also faces the following common challenges: First, chip topologies are diverse (such as hexagonal, square, linear, etc.) and may have directionality or asymmetry, making cross-chip comparisons difficult; Second, compilers often contain random heuristic strategies, and if the random seed is not fixed, the results fluctuate greatly and reproducibility is insufficient; Third, existing benchmarks are mostly general random circuits or a small number of standard operators, which do not cover specific topologies well and make it difficult to systematically trigger and expose efficiency bottlenecks; Fourth, there is a lack of universal criteria that can clearly attribute problems to different stages of "initial mapping" and "routing", resulting in insufficient localization granularity.
[0010] Given the current situation, the industry urgently needs a compiler efficiency evaluation and testing method that better meets engineering requirements. Ideal features include: independence from external optimal solutions or artificial "oracles"; the ability to generate comparable quantitative metrics across different chip topologies and various compilers; the ability to distinguish and locate efficiency issues in the initial mapping and routing phases; good coverage and scalability, enabling efficient operation on large samples; and reproducibility (including explicit randomness control and statistical standards), making it suitable for version regression testing and cross-platform evaluation. These pain points have not yet been fully addressed by existing technologies. Summary of the Invention
[0011] To address the problems existing in the prior art, this invention proposes a quantum compiler efficiency evaluation method based on metamorphic testing, comprising: obtaining the coupling graph Q and the set of allowed quantum gates G of the target quantum chip, and setting the circuit layer depth; performing any one of the following two efficiency evaluation tests on the target quantum chip;
[0012] The first efficiency evaluation test includes: generating an executable random circuit C that satisfies physical constraints based on the coupling graph Q; compiling C to obtain the compiled circuit C′ under the condition of only executing layout and routing and without enabling structural optimization; removing non-operational instructions from C and C′ and constructing a gate-level dependency graph with gates as nodes, data dependencies as directed edges and gate names as node labels; and performing a labeled graph isomorphism determination.
[0013] The second efficiency evaluation test includes: selecting physical bit relationships / subsets based on the coupling graph Q and generating an executable front-end circuit; using the physical bit correspondence at the end of the executable front-end circuit as the segment entry layout to generate random segments; performing optimal compilation and scheduling of the random segments on Q using an exact algorithm to obtain the optimal result C*; mapping C* and connecting the mapped segments into C* to form a middle segment window; generating an executable back-end circuit on Q starting from the physical bit correspondence at the end of the segment; combining the executable front-end circuit, the middle segment window, and the executable back-end circuit to obtain the test circuit C^; compiling C^ to obtain C′′, and comparing C′′ with C* within the segment window using the number of swapped gates as the main indicator and the total number of two-bit gates or weighted depth as auxiliary indicators to obtain the swapped gate difference;
[0014] An evaluation report is generated based on the isomorphism conclusions in the function retention test and / or the exchange gate difference in the optimal fragment benchmarking test.
[0015] The beneficial effects of this invention are:
[0016] This invention requires no external oracle: efficiency issues can be identified through two types of metamorphic relationships: isomorphic preservation and optimal comparison. The benchmarks of this invention are generated hierarchically according to coupling graphs and OpenQASM semantics, and can be extended according to the number of qubits and the system depth. Validation has been performed on multiple chips such as Sydney, Tokyo, and Aspen-4, and on multiple algorithms such as SABRE / QMAP / FiDLS. The experimental examples of this invention provide ranges such as N∈[1,27] and L∈[1,50], and generate a large number of benchmarks for multiple chips for statistical analysis, demonstrating the scalability of the method. Attached Figure Description
[0017] Figure 1 This is a flowchart of the method of the present invention;
[0018] Figure 2 A schematic diagram showing the isomorphic relationship between the coupling diagram of a quantum chip and a random circuit and their coupling diagram;
[0019] Figure 3 A schematic diagram illustrating the process of constructing and comparing the optimal route baseline;
[0020] Figure 4 A comparison chart of isomorphic pass rates of the gate-level dependency graphs before and after compilation;
[0021] Figure 5 A comparison diagram of the swap gate insertion for different compilation strategies of different chips. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] For ease of understanding, the following terminology is used: a swap gate (SWAP) refers to exchanging quantum states between two physical qubits; a two-qubit gate (such as CNOT / CX) is a controlled NOT gate or an equivalent two-qubit operation; a gate-dependent graph refers to a graph with quantum gates as nodes and data dependencies as directed edges; a coupled graph Q refers to the set of physical qubits and the set of edges that allow two qubits to interact.
[0024] An efficiency evaluation method for quantum compilers based on metamorphic testing, such as Figure 1 As shown, the process includes: obtaining the coupling graph Q of the target quantum chip and the set of allowed quantum gates G, and setting the circuit layer depth range [1, L]. The evaluation phase includes at least one of the following two tests: First, based on the coupling graph Q, generate an executable random circuit C that satisfies physical constraints. Under the condition of only executing layout and routing and without enabling structural optimization, compile C to obtain the compiled circuit C′. Remove non-operational instructions from C and C′ and construct a gate-level dependency graph with gates as nodes, data dependencies as directed edges, and gate names as node labels. Perform a labeled graph isomorphism determination. Second, without compiling the entire circuit as a prerequisite, first select physical bit relationships / subsets according to the coupling graph Q to generate an executable front-end circuit, and use the physical bit correspondence at the end of the circuit as the segment entry layout. Use an exact algorithm on Q to perform optimal compilation scheduling for randomly generated small segments to obtain the optimal result C*. Connect the segment to form a middle segment window according to the mapping of C*. Then, use the physical bit correspondence at the end of the segment as the starting point on Q. The executable back-end circuit is generated, and the front-end, middle-end, and back-end are combined to obtain the test circuit C^. Under the same compilation caliber as before (only placement and routing, structural optimization is disabled), C^ is compiled to obtain C′′. Within the fragment window, the number of swap gates is used as the main indicator, and the total number of two-bit gates or weighted depth can be used as auxiliary indicators. C′′ is compared with C* to obtain the swap gate difference. In the output stage, an evaluation report is generated based on the isomorphism conclusion in the function preservation test and the swap gate difference in the optimal fragment benchmark test.
[0025] In this embodiment, the number of circuit layers is used to cover the test set. The larger the number of circuit layers, the greater the overhead of the circuit during routing.
[0026] Compiling the executable random circuit C includes: performing only placement and routing under the constraints of the target chip coupling graph Q and the gate set G; disabling structural optimization, which includes algebraic simplification, gate fusion, instruction rewriting, and rescheduling; generating the compiled circuit C′ based on a preset initial placement strategy and routing algorithm, and outputting the logic-physical mapping, final placement, and information on the swapped gates inserted during compilation. The isomorphic relationship between the quantum chip coupling graph, the random circuit, and their coupling graphs is illustrated in the diagram below. Figure 2 As shown.
[0027] The isomorphism determination uses the VF2 graph matching algorithm. For ease of implementation, the VF2 algorithm is preferably used for the determination of labeled graph isomorphism / subgraph isomorphism, and its process is as follows:
[0028] Feasibility checks include:
[0029] (1) One-to-one consistency with label: The vertex to be matched is not mapped, and the node labels are consistent (the node labels include at least the gate name);
[0030] (2) Adjacency consistency and in / out degree lower bound consistency: The adjacency relationship of matched neighbors in both graphs remains consistent and meets the in / out degree lower bound requirements;
[0031] (3) (Optional) Edge label or multiplicity consistency: When edges have attributes such as category or number, they should be consistent;
[0032] (4) Window compatibility: When inserting and positioning a window, it keeps the external door-level dependencies and execution order of the window unchanged, and makes the physical layout at the end of the segment compatible with the adjacency requirements of the subsequent layers.
[0033] The steps are as follows:
[0034] (1) Initialize the partial mapping set M and the boundary set (frontier), and clear the search stack;
[0035] (2) Select a pair of candidate vertices (pattern graph vertex p and target graph vertex t) from the boundary set.
[0036] (3) Check (p,t) according to the above feasibility conditions;
[0037] (4) If the check passes, add (p→t) to M and update the boundary set incrementally;
[0038] (5) Recursive search: if there are no feasible candidates in the current branch, backtrack to the previous mapping and continue to try;
[0039] (6) If all vertices are matched, output the vertex correspondence M; otherwise, it is determined that there is no match.
[0040] (7) The upper limit of time or number of nodes can be set as an early termination condition to ensure that the project is controllable.
[0041] This implementation is a preferred embodiment, but it can also be implemented using a labeled graph isomorphism / subgraph isomorphism algorithm equivalent to VF2.
[0042] The mapping position of the executable random circuit C includes: the mapping position with the set of active bits of the optimal result C* of the segment as the window, the time position in the front / middle / back section of the circuit, and the position compatible with the end layout of the segment's end state; wherein, the window is several consecutive layers in C, covering the relevant gates on the set of active bits, and when inserting, the gate-level dependencies and execution order outside the window remain unchanged, and the physical layout at the end of the segment is compatible with the adjacency relationship of the subsequent layers of the window.
[0043] The optimal compilation and scheduling of random segments on Q using an exact algorithm includes: establishing a combinatorial optimization model with the primary objective of minimizing the number of swapped gates and the secondary objective of minimizing the total number of two-bit gates or the weighted depth, under the constraints of the coupled graph Q and the gate set G, while maintaining gate-level dependencies and port mutual exclusion; obtaining the global optimal solution of the gate order and SWAP insertion scheme using the bit set of the segment and the window start and end layout as boundary conditions, and outputting the optimal result C*, the corresponding SWAP set and count, the segment end layout, and auxiliary statistics used for evaluation.
[0044] Methods for solving combinatorial optimization models include using any SAT / MaxSAT algorithm, 0–1 integer programming algorithm, dynamic programming algorithm, or branch and bound / Meet-in-the-Middle algorithm.
[0045] For ease of implementation, the combined optimization model is preferably solved using a weighted partial MaxSAT method, as follows:
[0046] Input: Coupled graph Q=(P,E); Double-bit gate sequence {G1,…,G} within the window in topological order. m}; Initial Layout ; Optional termination layout Or, it may impose compatibility constraints on subsequent layers.
[0047] variable:
[0048] (1) Mapping variables [q,p]∈{0,1}: The logical bit q at time step t (a switching layer is set before each gate is executed) is located at physical bit p;
[0049] (2) Swapping variables : Whether time step t is at the coupling edge Perform a SWAP.
[0050] Hard sentence:
[0051] (1) Permutation consistency: , ;
[0052] (2) Endpoint mutual exclusion: ;
[0053] (3) Commutative semantics: when At that time, stayed at The two logical bits in Interchange; its equivalent formula and The mapping of physical bits that are not involved in the swap remains unchanged, as shown in equation [equation missing]. .
[0054] (4) Coupling adjacency: In execution Previously required to meet ;
[0055] (5) Boundary / Compatibility: Fixed initial mapping If a termination layout is given, then the following conditions are met. When compatibility constraints are applied, the subsequent gates of the "lookahead set" satisfy the following condition at t=m: ;
[0056] (6) Dependency order (when windows are parallel): allocate time slots according to topology order and avoid port conflicts.
[0057] Soft Clause and Objective: Under the premise of satisfying the aforementioned hard clause, exchange variables between each time step t and the coupling edge e. Set a soft clause with a weight of 1 The objective is to maximize the number of satisfied soft clauses, which is equivalent to minimizing the number of selected swaps. If necessary, a low-weighted secondary soft clause can be added to suppress swap level or layout oscillations. However, this does not change the priority of the primary objective.
[0058] Solution steps:
[0059] (1) Read the input;
[0060] (2) Generation time expansion and ;
[0061] (3) Encode hard clauses;
[0062] (4) Encode soft clauses;
[0063] (5) Call the weighted partial MaxSAT solver;
[0064] (6) Read the optimal assignment and restore the optimal result C* of the swap sequence and fragment;
[0065] (7) Output SWAP set and count, fragment end layout and auxiliary statistics.
[0066] This preferred embodiment does not exclude the use of 0–1 integer programming, dynamic programming, or branch and bound / Meet-in-the-Middle and other equivalent methods.
[0067] Example 1
[0068] In this embodiment, a quantum compiler efficiency evaluation method based on metamorphic testing is presented. The input data for the quantum compiler includes: an executable random circuit C (satisfying the coupling constraints of Q) and a chip coupling graph file (edge list). The specific steps are as follows:
[0069] 1. Load the coupling graph. Read the edge list to generate an undirected coupling graph, and construct a bidirectional CouplingMap to avoid spurious swaps caused by unidirectional edges.
[0070] 2. Compilation settings. Call the compiler / router under test, enable only layout and routing, and disable optimizations such as algebraic simplification, gate fusion, and rescheduling to obtain the compilation result C′.
[0071] 3. QASM Export and Mapping Records. Export C' using OpenQASM; logical-to-physical bit mappings can be recorded in comments for easy verification.
[0072] 4. Dependency Graph Construction and Cleaning. Construct DAGs for C and C′ respectively, filtering out non-operational instructions such as barrier, measure, and set_layout; convert the DAGs into directed graphs using "gate name" as node labels.
[0073] 5. Isomorphic matching and determination. VF2 or equivalent isomorphic algorithm is used for labeled isomorphic matching: if isomorphic, it is marked as passed; otherwise, it is marked as abnormal, and the number of new swaps, the total number of two-bit gates, and the change in gate depth are counted at the same time.
[0074] 6. Statistical Output. Aggregate the coherence rates by circuit size and output the total number of processes and the number of passes. Note: When the input circuit C is a "physical adapter circuit", the ideal compilation should satisfy |C|=|C′| (or SWAP(C′)=SWAP(C)); if an additional SWAP occurs, the initial mapping is not optimal.
[0075] Example 2
[0076] An efficiency evaluation method for a quantum compiler based on metamorphic testing is proposed. The input data for the quantum compiler are: chip coupling graph Q; fragment size and upper bound parameters; and exact solver configuration.
[0077] To evaluate the relative optimality of the compiler under test during the routing phase, this embodiment employs a combination of "front-end circuit - segment - tail circuit" for testing. A schematic diagram of the optimal routing baseline construction and comparison process is shown below. Figure 3 As shown, it specifically includes:
[0078] 1. Front-end circuit. Based on the coupling diagram of the target chip, a pre-adapted and directly executable random circuit is generated, hereinafter referred to as the "front-end circuit". This circuit operates on all N physical qubits.
[0079] 2. Segment and its optimal route. A small-scale circuit segment not constrained by the coupling graph is randomly generated, with the number of qubits m less than N. Any m physical qubits in the preceding circuit are selected as embedding locations, and the segment is mapped onto these m physical qubits. Then, an exact route solution is performed only on this segment to obtain the optimal compilation result of the segment on the target coupling graph, hereinafter referred to as the "optimal segment". Simultaneously, the end layout of the optimal segment on the aforementioned m physical qubits is recorded.
[0080] 3. Tail-end circuit. A tail-end circuit is generated on all N physical qubits, ensuring that its initial layers are compatible with the physical adjacency relationships at the end of the optimal segment, thus avoiding additional swap gates introduced by boundary inconsistencies. The number of qubits in the front-end and tail-end circuits is the same, while the optimal segment has fewer qubits.
[0081] 4. Construction and compilation of the entire circuit. Connect the three circuit segments sequentially in chronological order to obtain the entire test circuit (in order: front circuit, optimal segment, and rear circuit). Without enabling optimizations that would alter the structure, such as algebraic simplification, gate fusion, or rescheduling, the entire circuit is compiled and routed using the compiler under test.
[0082] 5. Counting and Judgment. In the compilation results, count the number of switched gates inserted after the circuit is compiled and compare it with the optimal number of switched gates when only the optimal segment is precisely routed. When the two are equal, the compiler under test is determined to have reached relative optimality at that segment; when the number of switched gates in the compilation results is larger, the routing at that segment is determined to be relatively non-optimal. The total number of two-bit gates can also be recorded as an auxiliary diagnostic indicator.
[0083] Example 3
[0084] The statistical and evaluation results include: a quantitative comparison and analysis of the efficiency of the quantum compiler in the initial mapping and routing stages based on data generated in Examples 1 and 2, under various chip topologies and compiler settings. This example does not list individual samples; all conclusions are based on aggregated statistics grouped by chip, scale, and strategy. Homogeneity determination uses a labeled gate-level dependency graph approach; fragment swapping gate differences are counted according to the set of active bits in each fragment; boundary markers are not included in the index.
[0085] The experimental setup includes:
[0086] 1. Hardware Topology: Three representative chip topologies were selected, denoted as Sydney, Tokyo, and Aspen-4.
[0087] 2. Compilation strategies: Heuristic method (SABRE), exact solution-based optimization method (QMAP / MaxSAT), subgraph isomorphism-based strategy (FiDLS). These names are for illustrative purposes only and do not limit the scope of protection.
[0088] 3. Benchmark generation: Following the methods of Example 1 and Example 2, test sets are generated in batches for several values of the number of qubits N and the layer depth L, ensuring that there are multiple random circuit samples under each (N,L) configuration.
[0089] 4. Compilation configuration: Enable only layout and routing functions; disable optimizations that change the structure, such as algebraic simplification, gate fusion, and rescheduling; keep other parameters fixed and record them in the log.
[0090] 5. Repetition and randomness: Set a random seed independently for each (N,L) and each strategy and repeat multiple times to obtain stable statistics.
[0091] Evaluation indicators and statistical definitions include:
[0092] 1. Isomorphism Pass Rate. This refers to the proportion of samples in Example 1 that are judged as having "isomorphic gate-level dependency graphs before and after compilation" under a given chip, scale, and compilation configuration, out of the total number of samples in that group. It is calculated by dividing the number of isomorphic samples by the total number of samples. The determination is based on tagged graph isomorphism where "node labels are gate names." Statistics can be compiled separately based on the number of qubits, layer depth, chip type, and compilation strategy.
[0093] 2. Segment Switching Gate Difference. This refers to the difference between the number of switching gates counted in the recompilation result of the entire circuit in Example 2 and the optimal number of switching gates required for precise routing of the optimal segment. It is calculated as "Circuit Switching Gate Count" minus "Optimal Segment Switching Gate Count". When the difference is zero, the segment is considered relatively optimal; when the difference is greater than zero, the segment is considered relatively non-optimal; if a negative value appears, the window alignment and counting caliber should be reviewed.
[0094] 3. Optional auxiliary metrics. Difference in the total number of two-bit gates, difference in gate depth, compilation time, etc.
[0095] like Figure 4 As shown, under the Sydney, Tokyo, and Aspen-4 topologies, the relative optimality indices of the three strategies exhibit stable differences with the number of qubits: the overall trend is as follows: the optimization method has the lowest number of swap gates at most scales, which can be regarded as a reference lower bound close to the optimality; the heuristic algorithm shows a faster increase in the number of swap gates as the number of qubits increases; the subgraph isomorphism-based strategy is more likely to find a layout that fits the topology in the initial mapping stage, and its overall swap gate insertion is lower than that of the heuristic algorithm and close to that of the optimization method. This phenomenon is consistent with the change in isomorphism pass rate: when the isomorphism pass rate is high, the difference in swap gate insertion among the three strategies is small; when the isomorphism pass rate decreases, the increase in swap gate insertion of the heuristic algorithm is more significant.
[0096] like Figure 5 As shown, in the comparison of fragment swapping gate differences, most of the tested compilers achieved relative optimization; however, for certain chip and scale combinations, the difference distribution showed a positive shift, indicating that global compilation introduced additional overhead to locally optimal fragments. Combined with auxiliary indicators, it can be seen that as the difference increases, the total number of two-bit gates and the gate depth also increase to varying degrees, suggesting the need for targeted improvements in the initial mapping strategy and global routing scheduling.
[0097] Statistical definitions and reproduction instructions include:
[0098] 1. Individual samples are not listed separately; all conclusions are derived from summary statistics grouped by chip, scale, and strategy. Original sample records (circuit identification, isomorphism determination, window count, optimal count) and compilation logs are saved in the results table for verification.
[0099] 2. Only layout and routing are enabled during compilation, while other structural optimizations are disabled; random seeds and key parameters are fixed and recorded, and the same seed is reused across strategies to ensure comparability.
[0100] Based on three types of metrics—relative optimality, homogeneous pass rate, and fragment window swapping gate difference—the efficiency performance of the compiler under test during the initial mapping and routing phases can be reliably revealed: when the relative optimality metric is close to 1, the homogeneous pass rate is high, and the fragment window difference is zero, it can be considered that relative optimality has been achieved under the corresponding scale and topology; when the relative optimality metric decreases, the homogeneous pass rate decreases, and the fragment window difference increases, it indicates that there is an efficiency bottleneck that can be improved, and targeted optimizations need to be made in the initial mapping strategy and global routing scheduling.
[0101] The above-described embodiments further illustrate the purpose, technical solution, and advantages of the present invention. It should be understood that the above-described embodiments are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made to the present invention within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for evaluating the efficiency of a quantum compiler based on metamorphosis testing, characterized in that, include: Obtain the coupling graph Q and the set of allowed quantum gates G of the target quantum chip, and set the circuit layer depth; Perform either of the following two efficiency evaluation tests on the target quantum chip; The first efficiency evaluation test includes: generating an executable random circuit C that satisfies physical constraints based on the coupling graph Q; compiling C to obtain the compiled circuit C′ under the condition of only executing layout and routing and without enabling structural optimization; removing non-operational instructions from C and C′ and constructing a gate-level dependency graph with gates as nodes, data dependencies as directed edges and gate names as node labels; and performing a labeled graph isomorphism determination. The second efficiency evaluation test includes: selecting physical bit relationships / subsets based on the coupling graph Q and generating an executable front-end circuit; using the physical bit correspondence at the end of the executable front-end circuit as the segment entry layout to generate random segments; performing optimal compilation and scheduling of the random segments on Q using an exact algorithm to obtain the optimal result C*; mapping C* and connecting the mapped segments into C* to form a middle window; generating an executable back-end circuit on Q starting from the physical bit correspondence at the end of the segment; combining the executable front-end circuit, the middle window, and the executable back-end circuit to obtain the test circuit C^; compiling C^ to obtain C′′, and comparing C′′ with C* within the segment window using the number of swapped gates as the main indicator and the total number of two-bit gates or weighted depth as auxiliary indicators to obtain the swapped gate difference; An evaluation report is generated based on the isomorphism conclusions in the function retention test and / or the exchange gate difference in the optimal fragment benchmarking test.
2. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The layer depth is set to [1, L]; the specific value of L is 50.
3. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, Generating an executable random circuit C that satisfies physical constraints based on a coupled graph Q includes: dividing the coupled graph Q into subgraphs; enumerating the subgraphs and selecting two non-conflicting bit gates at each layer to construct the executable random circuit.
4. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, Compiling the executable random circuit C includes: performing only placement and routing under the constraints of the target chip coupling graph Q and the gate set G; disabling structural optimization, which includes algebraic simplification, gate fusion, instruction rewriting, and rescheduling; generating the compiled circuit C′ based on the preset initial placement strategy and routing algorithm, and outputting the logic-physical mapping, final placement, and information on the exchange gates inserted during the compilation process.
5. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The gate-level dependency graph is obtained by transforming the directed acyclic graph of the circuit before and after compilation, with quantum gates as nodes and data dependencies as directed edges.
6. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The isomorphism determination uses the VF2 graph matching algorithm.
7. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The standard for a random segment is 3 to 5 qubits.
8. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The mapping position of the executable random circuit C includes: the mapping position with the set of active bits of the optimal result C* of the segment as the window, the time position in the front / middle / back section of the circuit, and the position compatible with the end layout of the segment's end state; wherein, the window is several consecutive layers in C, covering the relevant gates on the set of active bits, and when inserting, the gate-level dependencies and execution order outside the window remain unchanged, and the physical layout at the end of the segment is compatible with the adjacency relationship of the subsequent layers of the window.
9. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, The optimal compilation and scheduling of random segments on Q using an exact algorithm includes: establishing a combinatorial optimization model with the primary objective of minimizing the number of swapped gates and the secondary objective of minimizing the total number of two-bit gates or the weighted depth, under the constraints of the coupled graph Q and the gate set G, while maintaining gate-level dependencies and port mutual exclusion; obtaining the global optimal solution of the gate order and SWAP insertion scheme using the aforementioned segment action bit set and window start and end layout as boundary conditions, and outputting the optimal result C*, the corresponding SWAP set and count, the segment end layout, and auxiliary statistics used for evaluation.
10. The method for evaluating the efficiency of a quantum compiler based on a metamorphosis test according to claim 1, characterized in that, Methods for solving combinatorial optimization models include using any SAT / MaxSAT algorithm, 0–1 integer programming algorithm, dynamic programming algorithm, or branch and bound / Meet-in-the-Middle algorithm.
