Skip to content

Commit

Permalink
Fixed passing options to fake backend
Browse files Browse the repository at this point in the history
  • Loading branch information
merav-aharoni committed Nov 29, 2023
1 parent 9e0d7ff commit a56063f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions qiskit_ibm_runtime/base_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 3 additions & 6 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions test/unit/test_run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)

0 comments on commit a56063f

Please sign in to comment.