From a56063f8f465c5dda657ae3ed84663588fb3126d Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Wed, 29 Nov 2023 16:34:16 +0000 Subject: [PATCH] Fixed passing options to fake backend --- qiskit_ibm_runtime/base_primitive.py | 2 -- qiskit_ibm_runtime/qiskit_runtime_service.py | 9 +++------ test/unit/test_run_simulation.py | 5 +++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/qiskit_ibm_runtime/base_primitive.py b/qiskit_ibm_runtime/base_primitive.py index dafb3e7c6..5e2214099 100644 --- a/qiskit_ibm_runtime/base_primitive.py +++ b/qiskit_ibm_runtime/base_primitive.py @@ -178,8 +178,6 @@ def _run_primitive(self, primitive_inputs: Dict, user_kwargs: Dict) -> RuntimeJo if run_simulator: runtime_options["backend"] = self._backend # fix this - for cloud, is str, # for fake is Backend - print("runtime options = ", runtime_options) - print("inputs ", primitive_inputs) return self._service.run( program_id=self._program_id(), diff --git a/qiskit_ibm_runtime/qiskit_runtime_service.py b/qiskit_ibm_runtime/qiskit_runtime_service.py index 78375584b..601d327b6 100644 --- a/qiskit_ibm_runtime/qiskit_runtime_service.py +++ b/qiskit_ibm_runtime/qiskit_runtime_service.py @@ -883,7 +883,6 @@ def run( RuntimeProgramNotFound: If the program cannot be found. IBMRuntimeError: An error occurred running the program. """ - print("inputs = ", inputs) qrt_options: RuntimeOptions = options if options is None: @@ -892,10 +891,8 @@ def run( qrt_options = RuntimeOptions(**options) qrt_options.validate(channel=self.channel) - # transpilation_options = inputs["transpilation_settings"] - # print("transpilation_options = ", transpilation_options) + sim_options = inputs["run_options"] - # print("simulator options = ", sim_options) is_fake_backend = False is_aer_backend = False @@ -925,8 +922,9 @@ def run( primitive_job = my_program._run( circuits=inputs["circuits"], parameter_values=inputs["parameters"], - run_options=sim_options, observables=observables, + **sim_options, + ) fake_runtime_job = FakeRuntimeJob( primitive_job=primitive_job, @@ -943,7 +941,6 @@ def run( for opt in inputs["run_options"]: if hasattr(AerSimulator._default_options(), opt): aer_backend_options[opt] = inputs["run_options"][opt] - print("aer_config", aer_backend_options) my_program = prog( backend_options=aer_backend_options, diff --git a/test/unit/test_run_simulation.py b/test/unit/test_run_simulation.py index 2b993a512..ffa524c0c 100644 --- a/test/unit/test_run_simulation.py +++ b/test/unit/test_run_simulation.py @@ -26,7 +26,8 @@ class TestRunSimulation(IBMTestCase): def test_basic_flow(self): """Test basic flow on simulator.""" - service = QiskitRuntimeService(channel="ibm_quantum") + #service = QiskitRuntimeService(channel="ibm_quantum") + service = FakeRuntimeService() shots = 1000 for backend in ["manila", AerSimulator()]: circuit = ReferenceCircuits.bell() @@ -37,4 +38,4 @@ def test_basic_flow(self): self.assertAlmostEqual(result.quasi_dists[0][3], 0.5, delta=0.2) # currently not working correctly for FakeBackend - # self.assertEqual(result.metadata[0]["shots"], shots) + self.assertEqual(result.metadata[0]["shots"], shots)