def __init__(self, qc_name, simulator=True): """Backend for running simulations on the Rigetti QVM or a QCS device :param qc_name: The name of the particular QuantumComputer to use. See the pyQuil docs for more details. :param simulator: Whether to simulate the architecture or try to connect to a physical device""" self._qc = get_qc(qc_name, as_qvm=simulator) coupling = [[n, ni] for n, neigh_dict in self._qc.qubit_topology().adjacency() for ni, _ in neigh_dict.items()] self._architecture = Architecture(coupling)
def __init__(self, backend_name: str, monitor: bool = True): """A backend for running circuits on remote IBMQ devices. :param backend_name: name of ibmq device. e.g. `ibmqx4`, `ibmq_16_melbourne`. :type backend_name: str :param monitor: Use IBM job monitor, defaults to True :type monitor: bool, optional :raises ValueError: If no IBMQ account has been set up. """ if len(IBMQ.stored_accounts()) == 0: raise ValueError( 'No IBMQ credentials found on disk. Store some first.') IBMQ.load_accounts() self._backend = IBMQ.get_backend(backend_name) coupling = self._backend.configuration().coupling_map self.architecture = Architecture(coupling) self._monitor = monitor
def xmon_to_arc(xmon: XmonDevice) -> Architecture: """Generates a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` object for a Cirq :py:class:`XmonDevice` . :param xmon: The device to convert :return: The corresponding :math:`\\mathrm{t|ket}\\rangle` :py:class:`Architecture` """ nodes = len(xmon.qubits) indexed_qubits = _sort_row_col(xmon.qubits) pairs = [] for qb in indexed_qubits: neighbours = xmon.neighbors_of(qb) #filter only higher index neighbours to avoid double counting edges forward_neighbours = filter( lambda x: indexed_qubits.index(x) > indexed_qubits.index(qb), neighbours) for x in forward_neighbours: pairs.append((indexed_qubits.index(qb), indexed_qubits.index(x))) return Architecture(pairs, nodes)
def process_circ(self, circ): num_qubits = circ.n_qubits if num_qubits == 1 or self.coupling_map == "all-to-all": coupling_map = None else: coupling_map = self.coupling_map # pre-routing optimise Transform.OptimisePhaseGadgets().apply(circ) circlay = list(range(num_qubits)) if coupling_map: directed_arc = Architecture(coupling_map) # route_ibm fnction that takes directed Arc, returns dag with cnots etc. circ, circlay = route(circ,directed_arc) circ.apply_boundary_map(circlay[0]) # post route optimise Transform.OptimisePostRouting().apply(circ) circ.remove_blank_wires() return circ, circlay