def run_sweep(self, program: cirq.AbstractCircuit, params: cirq.Sweepable, repetitions: int = 1) -> Sequence[cirq.Result]: """This will evaluate results on the circuit for every set of parameters in `params`. Args: program: Circuit to evaluate for each set of parameters in `params`. params: `cirq.Sweepable` of parameters which this function passes to `cirq.protocols.resolve_parameters` for evaluating the circuit. repetitions: Number of times to run each iteration through the `params`. For a given set of parameters, the `cirq.Result` will include a measurement for each repetition. Returns: A list of `cirq.Result` s. """ resolvers = [r for r in cirq.to_resolvers(params)] return self.executor( quantum_computer=self._quantum_computer, circuit=program.unfreeze(copy=False), resolvers=resolvers, repetitions=repetitions, transformer=self.transformer, )
def t3( circuit: cirq.AbstractCircuit, context: Optional[cirq.TransformerContext] = None ) -> cirq.Circuit: assert context is not None context.logger.log("First INFO Log", "of T3 Start") circuit = t1(circuit, context=context) context.logger.log("Second INFO Log", "of T3 Middle") circuit = t2(circuit, context=context) context.logger.log("Third INFO Log", "of T3 End") return circuit.unfreeze()
def place_circuit( self, circuit: cirq.AbstractCircuit, problem_topology: NamedTopology, shared_rt_info: 'cg.SharedRuntimeInfo', rs: np.random.RandomState, ) -> Tuple[cirq.FrozenCircuit, Dict[Any, cirq.Qid]]: """Place a circuit according to the hardcoded placements. Args: circuit: The circuit. problem_topology: The topologies (i.e. connectivity) of the circuit, use to look up the placement in `self.mapping`. shared_rt_info: A `cg.SharedRuntimeInfo` object; ignored for hardcoded placement. rs: A `RandomState`; ignored for hardcoded placement. Returns: A tuple of a new frozen circuit with the qubits placed and a mapping from input qubits or nodes to output qubits. Raises: CouldNotPlaceError: if the given problem_topology is not present in the hardcoded mapping. """ try: nt_mapping = self._mapping[problem_topology] except KeyError as e: raise CouldNotPlaceError(str(e)) circuit_mapping = { self.topo_node_to_qubit_func(nt_node): gridq for nt_node, gridq in nt_mapping.items() } circuit = circuit.unfreeze().transform_qubits(circuit_mapping).freeze() return circuit, circuit_mapping
def mock_tranformer_func( circuit: cirq.AbstractCircuit, *, context: Optional[cirq.TransformerContext] = None ) -> cirq.Circuit: my_mock(circuit, context) return circuit.unfreeze()
def __call__( self, circuit: cirq.AbstractCircuit, *, context: Optional[cirq.TransformerContext] = None ) -> cirq.Circuit: self.mock(circuit, context) return circuit.unfreeze()