def test_grovers_default_basis_gates(self): """Test grovers circuits compiling to backend default basis_gates.""" shots = 2000 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) job = execute(circuits, self.SIMULATOR, shots=shots) result = job.result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_grovers_default_basis_gates_with_circuit_run(self): shots = 4000 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) transpiled_circs = transpile(circuits, self.SIMULATOR) job = self.SIMULATOR.run(transpiled_circs, shots=shots, **self.BACKEND_OPTS) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_grovers_minimal_basis_gates(self): """Test grovers circuits compiling to u3,cx""" shots = 4000 circuits = ref_algorithms.grovers_circuit( final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) job = execute( circuits, self.SIMULATOR, shots=shots, basis_gates=['u3', 'cx'], **self.BACKEND_OPTS) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_grovers_default_basis_gates(self): """Test grovers circuits compiling to backend default basis_gates.""" shots = 500 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_algorithms.grovers_counts(shots) opts = self.BACKEND_OPTS_SAMPLING.copy() opts["extended_stabilizer_metropolis_mixing_time"] = 100 job = QasmSimulator().run(qobj, **opts) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.1 * shots)
def test_grovers_minimal_basis_gates(self): """Test grovers circuits compiling to u3,cx""" shots = 2000 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) qobj = compile(circuits, self.SIMULATOR, shots=shots, basis_gates=['u3', 'cx']) result = self.SIMULATOR.run(qobj).result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_grovers_waltz_basis_gates(self): """Test grovers gate circuits compiling to u1,u2,u3,cx""" shots = 2000 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) job = execute(circuits, self.SIMULATOR, shots=shots, basis_gates=['u1', 'u2', 'u3', 'cx']) result = job.result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def _test_grovers(self, **options): shots = 4000 backend = self.backend(**options) circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) targets = ref_algorithms.grovers_counts(shots) circuits = transpile(circuits, backend) job = backend.run(circuits, shots=shots) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_grovers_default_basis_gates(self): """Test grovers circuits compiling to backend default basis_gates.""" shots = 500 circuits = ref_algorithms.grovers_circuit(final_measure=True, allow_sampling=True) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_algorithms.grovers_counts(shots) job = QasmSimulator().run(qobj, backend_options={ "method": "extended_stabilizer", "extended_stabilizer_mixing_time": 100, }) result = job.result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.1 * shots)