wy_qcos.transpiler.cmss.mapping.init_mapping package

Submodules

wy_qcos.transpiler.cmss.mapping.init_mapping.sabre_mapping module

wy_qcos.transpiler.cmss.mapping.init_mapping.sabre_mapping.sabre_initial_mapping(gates_list, coupling_graph)

Get the initial mapping.

参数:
  • gates_list (list[GateOperation]) -- a list of gates.

  • coupling_graph (Graph) -- coupling graph of the quantum machine.

返回:

the initial mapping.

返回类型:

list[int]

wy_qcos.transpiler.cmss.mapping.init_mapping.sc_initial_mapping module

wy_qcos.transpiler.cmss.mapping.init_mapping.sc_initial_mapping.get_initial_mapping(dependency_graph, coupling_graph, method='naive')

Get the initial mapping, providing 4 methods.

  • naive: directly mapping logical qubits to physical qubits in order.

  • simulated_annealing: heuristic mapping, based on simulated annealing, ref: "Quantum Circuit Transformation Based on Simulated Annealing and Heuristic Search."

  • subgraph_isomorphism: Based on subgraph isomorphism, achieves precise allocation of qubits (this method may not always yield a solution).

  • topgraph: Combines the above two methods. For the top part of the circuit topology graph, subgraph isomorphism is used. ref "Qubit Mapping Based on Subgraph Isomorphism and Filtered Depth-Limited Search.".

参数:
  • dependency_graph (DG) -- dependency graph of the circuit

  • coupling_graph (Graph) -- adjacency graph of the quantum machine

  • method (str, optional) -- mapping method. Defaults to 'naive'.

返回:

represents a mapping in which indices and values stand for

logical and physical qubits.

返回类型:

list[int]

wy_qcos.transpiler.cmss.mapping.init_mapping.simulated_annealing module

class wy_qcos.transpiler.cmss.mapping.init_mapping.simulated_annealing.SimulatedAnnealingMapping(level='light')

基类:object

cal_cost_matrix(cost_m, current_sol, phy_distance, qubits_logic)

Estimate the cost of inserting swaps under the current mapping.

参数:
  • cost_m (np.ndarray) -- cost of matrix.

  • current_sol (list) -- current mapping.

  • phy_distance (dict) -- dict of shortest path length.

  • qubits_logic (tuple) -- logic qubits.

返回:

cost of swaps in current mapping.

返回类型:

float

cal_cost_matrix_incremental(cost_m, current_sol, phy_distance, qubits_logic, q_swap=None, cost_cur=None)

Incrementally calculate cost after swapping two logical qubits.

参数:
  • cost_m (np.ndarray) -- cost matrix (weights of logical qubit pairs)

  • current_sol (list) -- current mapping

  • phy_distance (dict) -- physical qubits shortest paths

  • qubits_logic (tuple) -- logic qubits

  • q_swap (tuple, optional) -- (q_log1, q_log2) swapped in this step

  • cost_cur (float, optional) -- previous total cost

返回:

new total cost

返回类型:

float

init_cost_matrix(dependency_graph, coupling_graph, add_weight=False)

Initialize cost matrix.

参数:
  • dependency_graph (DG) -- dependency graph of the circuit.

  • coupling_graph (Graph) -- adjacency graph of the quantum machine.

  • add_weight (bool, optional) -- ignore two-qubit gates acting consecutively on the same two qubits. Defaults to False.

返回:

cost matrix and qubits set.

返回类型:

tuple(np.ndarray, set)

run(dependency_graph, coupling_graph, start_mapping=None)

Heuristic qubit mapping based on simulated annealing.

参数:
  • dependency_graph (DG) -- dependency graph of the circuit.

  • coupling_graph (Graph) -- adjacency graph of the hardware.

  • start_mapping (list, optional) -- partial mapping. Defaults to None.

返回:

represents a mapping in which indices and values stand

for logical and physical qubits.

返回类型:

list[int]

wy_qcos.transpiler.cmss.mapping.init_mapping.subgraph_isomorphism module

wy_qcos.transpiler.cmss.mapping.init_mapping.subgraph_isomorphism.subgraph_isomorphism_mapping(dependency_graph, coupling_graph)

Qubit precise allocation based on subgraph isomorphism.

参数:
  • dependency_graph (DG) -- Quantum circuit topology

  • coupling_graph (Graph) -- Hardware Topology

返回:

mapping from logical qubits to physical qubits

返回类型:

list

wy_qcos.transpiler.cmss.mapping.init_mapping.subgraph_isomorphism.topgraph_mapping(dependency_graph, coupling_graph)

Find the largest subcircuit that is isomorphic to the hardware topology.

And assign the remaining unallocated logical qubits sequentially.

参数:
  • dependency_graph (DG) -- dependency graph of the whole circuit.

  • coupling_graph (nx.Graph) -- adjacency graph of the hardware.

返回:

return the mapping from logical qubits to physical qubits.

返回类型:

list

Use binary search to find the largest subcircuit that is isomorphic.

参数:
  • cx_list (list) -- list of all cnot gates

  • coupling_graph (nx.Graph) -- adjacency graph of the hardware.

  • left (int) -- left boundary of the search range

  • right (int) -- right boundary of the search range

返回:

the count of cx gates in the cx_list that can

isomorphic to the hardware, and the mapping from physical to logical.

返回类型:

tuple(int, list)

wy_qcos.transpiler.cmss.mapping.init_mapping.subgraph_isomorphism.nx_to_rx(nx_graph)

Convert nx.Graph to rx.PyGraph.

参数:

nx_graph (Graph)

返回类型:

PyGraph

Module contents