Skip to content

Attempt to remedy random CI failures (backport #925) #938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions test/algorithms/inference/test_qbayesian.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2023, 2024.
# (C) Copyright IBM 2023, 2025.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -24,6 +24,7 @@
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

from qiskit_ibm_runtime import Session, SamplerV2
from qiskit_ibm_runtime.options import SamplerOptions, SimulatorOptions

from qiskit_machine_learning.utils import algorithm_globals
from qiskit_machine_learning.algorithms import QBayesian
Expand Down Expand Up @@ -222,8 +223,12 @@ def test_trivial_circuit_V2(self):
seed=123,
)
session = Session(backend=backend)
_sampler = SamplerV2(mode=session)
pass_manager = generate_preset_pass_manager(optimization_level=0, backend=backend)
simopts = SimulatorOptions(seed_simulator=123)
samopts = SamplerOptions(simulator=simopts)
_sampler = SamplerV2(mode=session, options=samopts)
pass_manager = generate_preset_pass_manager(
optimization_level=0, backend=backend, seed_transpiler=123
)

# Define rotation angles
theta_a = 2 * np.arcsin(np.sqrt(0.2))
Expand Down
7 changes: 5 additions & 2 deletions test/gradients/test_estimator_gradient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2019, 2024.
# (C) Copyright IBM 2019, 2025.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -29,6 +29,7 @@
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

from qiskit_ibm_runtime import Session, EstimatorV2
from qiskit_ibm_runtime.options import EstimatorOptions, SimulatorOptions

from qiskit_machine_learning.gradients import (
LinCombEstimatorGradient,
Expand Down Expand Up @@ -461,7 +462,9 @@ class TestEstimatorGradientV2(QiskitAlgorithmsTestCase):
def __init__(self, TestCase):
backend = GenericBackendV2(num_qubits=3, seed=123)
session = Session(backend=backend)
self.estimator = EstimatorV2(mode=session)
simopts = SimulatorOptions(seed_simulator=123)
estopts = EstimatorOptions(simulator=simopts)
self.estimator = EstimatorV2(mode=session, options=estopts)
self.pass_manager = generate_preset_pass_manager(optimization_level=1, backend=backend)
super().__init__(TestCase)

Expand Down