diff --git a/qiskit_ibm_runtime/session.py b/qiskit_ibm_runtime/session.py index 60054d61d..ac54809ed 100644 --- a/qiskit_ibm_runtime/session.py +++ b/qiskit_ibm_runtime/session.py @@ -90,7 +90,7 @@ def __init__( max_time: (EXPERIMENTAL setting, can break between releases without warning) Maximum amount of time, a runtime session can be open before being forcibly closed. Can be specified as seconds (int) or a string like "2h 30m 40s". - This value must be in between 300 seconds and the + This value must be less than the `system imposed maximum `_. diff --git a/test/unit/test_ibm_primitives.py b/test/unit/test_ibm_primitives.py index ff2a2c76b..a96f39388 100644 --- a/test/unit/test_ibm_primitives.py +++ b/test/unit/test_ibm_primitives.py @@ -554,7 +554,12 @@ def test_default_error_levels(self): simulator={"noise_model": "foo"}, ) inst = cls(session=session, options=options) - inst.run(self.qx, observables=self.obs) + + if isinstance(inst, Estimator): + inst.run(self.qx, observables=self.obs) + else: + inst.run(self.qx) + if sys.version_info >= (3, 8): inputs = session.run.call_args.kwargs["inputs"] else: @@ -730,11 +735,12 @@ def test_raise_faulty_qubits(self): estimator = Estimator(session=session) with self.assertRaises(ValueError) as err: - sampler.run(transpiled, skip_transpilation=True) + estimator.run(transpiled, observable, skip_transpilation=True) self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception)) + transpiled.measure_all() with self.assertRaises(ValueError) as err: - estimator.run(transpiled, observable, skip_transpilation=True) + sampler.run(transpiled, skip_transpilation=True) self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception)) def test_raise_faulty_qubits_many(self): @@ -759,11 +765,14 @@ def test_raise_faulty_qubits_many(self): estimator = Estimator(session=session) with self.assertRaises(ValueError) as err: - sampler.run(transpiled, skip_transpilation=True) + estimator.run(transpiled, [observable, observable], skip_transpilation=True) self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception)) + for circ in transpiled: + circ.measure_all() + with self.assertRaises(ValueError) as err: - estimator.run(transpiled, [observable, observable], skip_transpilation=True) + sampler.run(transpiled, skip_transpilation=True) self.assertIn(f"faulty qubit {faulty_qubit}", str(err.exception)) def test_raise_faulty_edge(self): @@ -785,12 +794,13 @@ def test_raise_faulty_edge(self): estimator = Estimator(session=session) with self.assertRaises(ValueError) as err: - sampler.run(transpiled, skip_transpilation=True) + estimator.run(transpiled, observable, skip_transpilation=True) self.assertIn("cx", str(err.exception)) self.assertIn(f"faulty edge {tuple(edge_qubits)}", str(err.exception)) + transpiled.measure_all() with self.assertRaises(ValueError) as err: - estimator.run(transpiled, observable, skip_transpilation=True) + sampler.run(transpiled, skip_transpilation=True) self.assertIn("cx", str(err.exception)) self.assertIn(f"faulty edge {tuple(edge_qubits)}", str(err.exception)) @@ -813,11 +823,12 @@ def test_faulty_qubit_not_used(self): estimator = Estimator(session=session) with patch.object(Session, "run") as mock_run: - sampler.run(transpiled, skip_transpilation=True) + estimator.run(transpiled, observable, skip_transpilation=True) mock_run.assert_called_once() + transpiled.measure_active() with patch.object(Session, "run") as mock_run: - estimator.run(transpiled, observable, skip_transpilation=True) + sampler.run(transpiled, skip_transpilation=True) mock_run.assert_called_once() def test_faulty_edge_not_used(self): @@ -841,11 +852,12 @@ def test_faulty_edge_not_used(self): estimator = Estimator(session=session) with patch.object(Session, "run") as mock_run: - sampler.run(transpiled, skip_transpilation=True) + estimator.run(transpiled, observable, skip_transpilation=True) mock_run.assert_called_once() + transpiled.measure_all() with patch.object(Session, "run") as mock_run: - estimator.run(transpiled, observable, skip_transpilation=True) + sampler.run(transpiled, skip_transpilation=True) mock_run.assert_called_once() def test_no_raise_skip_transpilation(self): @@ -870,11 +882,12 @@ def test_no_raise_skip_transpilation(self): estimator = Estimator(session=session) with patch.object(Session, "run") as mock_run: - sampler.run(transpiled) + estimator.run(transpiled, observable) mock_run.assert_called_once() + transpiled.measure_all() with patch.object(Session, "run") as mock_run: - estimator.run(transpiled, observable) + sampler.run(transpiled) mock_run.assert_called_once() def _update_dict(self, dict1, dict2):