Skip to content

Commit ff55d2c

Browse files
authored
Attempt to remedy random CI failures (#925)
1 parent 5165746 commit ff55d2c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/algorithms/inference/test_qbayesian.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2023, 2024.
3+
# (C) Copyright IBM 2023, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -24,6 +24,7 @@
2424
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
2525

2626
from qiskit_ibm_runtime import Session, SamplerV2
27+
from qiskit_ibm_runtime.options import SamplerOptions, SimulatorOptions
2728

2829
from qiskit_machine_learning.utils import algorithm_globals
2930
from qiskit_machine_learning.algorithms import QBayesian
@@ -222,8 +223,12 @@ def test_trivial_circuit_V2(self):
222223
seed=123,
223224
)
224225
session = Session(backend=backend)
225-
_sampler = SamplerV2(mode=session)
226-
pass_manager = generate_preset_pass_manager(optimization_level=0, backend=backend)
226+
simopts = SimulatorOptions(seed_simulator=123)
227+
samopts = SamplerOptions(simulator=simopts)
228+
_sampler = SamplerV2(mode=session, options=samopts)
229+
pass_manager = generate_preset_pass_manager(
230+
optimization_level=0, backend=backend, seed_transpiler=123
231+
)
227232

228233
# Define rotation angles
229234
theta_a = 2 * np.arcsin(np.sqrt(0.2))

test/gradients/test_estimator_gradient.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2019, 2024.
3+
# (C) Copyright IBM 2019, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -29,6 +29,7 @@
2929
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
3030

3131
from qiskit_ibm_runtime import Session, EstimatorV2
32+
from qiskit_ibm_runtime.options import EstimatorOptions, SimulatorOptions
3233

3334
from qiskit_machine_learning.gradients import (
3435
LinCombEstimatorGradient,
@@ -461,7 +462,9 @@ class TestEstimatorGradientV2(QiskitAlgorithmsTestCase):
461462
def __init__(self, TestCase):
462463
backend = GenericBackendV2(num_qubits=3, seed=123)
463464
session = Session(backend=backend)
464-
self.estimator = EstimatorV2(mode=session)
465+
simopts = SimulatorOptions(seed_simulator=123)
466+
estopts = EstimatorOptions(simulator=simopts)
467+
self.estimator = EstimatorV2(mode=session, options=estopts)
465468
self.pass_manager = generate_preset_pass_manager(optimization_level=1, backend=backend)
466469
super().__init__(TestCase)
467470

0 commit comments

Comments
 (0)