Skip to content

Commit 86f768b

Browse files
MoritzWillmannDavid-KreplinCopilot
committed
Qiskit 2 support (#326)
* fix some primitive imports * remove unnecessary import * unfix qiskit version * fix BackendProperties * black * fix parallel sampler estimator imports * fix clbit import * fix imports in optree * add sympy requirement * use pennylane target * us sympify instead of _symbol_expr * use if_test instead of c_if * clean build_circuit_instructions * use recursive call to build_pennylane_circuit * fix some imports * add qulacs target * fix parameter and condition access in qulacs circuit * use draw to check if circuit is correct * fix condition checks * split executor tests * adapt executor tests * catch empty observable error * use np allclose in optree derivative test * use pure numerical expected gradients * Initial plan * Fix non-linear parameter detection in optree derivative - Add check to detect when parameters appear in non-linear functions - Parameter shift rule only works for linear/affine parameter dependencies - Updated tests to remove non-linear arccos(x[0]) from test circuits - Added new test to verify non-linear parameters raise ValueError Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * Drop Python 3.9 support to align with qiskit-machine-learning 0.9.0 - Update minimum Python version to 3.10 - Remove Python 3.9 from CI workflows - Remove autoray pinning for Python 3.9 - Remove old Qiskit version tests (0.46, 1.x) - Update classifiers in pyproject.toml This change is necessary because qiskit-machine-learning 0.9.0 dropped Python 3.9 support when migrating to Qiskit 2.0. Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * Address code review feedback - Use multiple test values (0.3, 0.7) for non-linearity check - Relax tolerance from 1e-10 to 1e-8 for floating-point precision - Add comment explaining larger tolerance for second derivatives Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * Address review feedback: Keep Python 3.9, add 3.14, use sympy for polynomial check - Keep Python 3.9 minimum version in pyproject.toml - Add Python 3.14 to all test matrices - Restore Python 3.9 for minimal requirements test - Add Qiskit 1.x compatibility test - Update Python classifiers to include 3.9 and 3.14 - Replace numerical gradient check with sympy-based polynomial degree check - Use second derivative to determine if parameter enters gate linearly Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * Update minimum qiskit version to 1.0.0 to fix Target.num_qubits issue - Update qiskit>=1.0.0 (was >=0.45.0) - fixes Target.num_qubits=None bug - Update qiskit-aer>=0.13.0 (was >=0.12.0) - for qiskit 1.0 compatibility - Update qiskit-ibm-runtime>=0.20.0 (was >=0.18.0) - for qiskit 1.0 compatibility - Update documentation to reflect new minimum versions The issue was that qiskit 0.45.0's Target.from_configuration() creates a Target without num_qubits, causing TypeError when transpiling with targets in pennylane_circuit.py. Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * Remove Python 3.14 from test matrices due to qulacs build issues - Remove Python 3.14 from quick_tests.yaml - Remove Python 3.14 from elaborate_tests.yaml (full, Windows, macOS) - Update Python 3.14 -> 3.13 for Windows and macOS tests - Remove Python 3.14 from classifiers in pyproject.toml Python 3.14 cannot build qulacs (C++ extension) from source due to missing Boost dependencies, causing all 3.14 tests to fail. Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * use different encoding circuit in test * black * Improve polynomial degree check using sympy.Poly and update qiskit 1.x test - Use sympy.Poly to check polynomial degree instead of second derivative - Use ParameterExpression.sympify() to convert to sympy expressions - Catch PolynomialError and GeneratorsNeeded for non-polynomial functions - Update qiskit 1.x test to use latest versions: - qiskit: 1.1.2 -> 1.4.5 - qiskit-aer: (implicit) -> 0.15.1 - qiskit-algorithms: 0.3.0 -> 0.3.1 - qiskit-ibm-runtime: 0.27.1 -> 0.45.1 This approach is more direct and mathematically sound - it explicitly checks if the expression is a polynomial and its degree, rather than inferring from the second derivative. Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * black * use argnum/s as arg to accomodate both * use 3.13 in qiskit 1 test * use n_local * fix parallel sampler output * double wrap sympify * check if condition is not None * reset shots after setting * qiskit version shenanigans * remove qiskit<1 support * remove qiskit smaller 1 from tests * fix mark error * black * new black * update example * Initial plan * Implement review comments from PR #326 Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * fix example * Add tests for if_else gate handling in PennyLaneCircuit Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * black examples * black * Initial plan * Apply review comments from PR #326 review 3845990151 Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com> * fix tests * fix qiskit version dependencies * add black jupyter to pyproject toml * fix minimal tests * adress review comments * adress review comments * fix bitstring handling qiskit<2 --------- Co-authored-by: David Kreplin <david.kreplin@ipa.fraunhofer.de> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 14fddc6 commit 86f768b

36 files changed

Lines changed: 1766 additions & 960 deletions

.github/workflows/elaborate_tests.yaml

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ jobs:
2323
- name: Set up Python
2424
uses: actions/setup-python@v6
2525
with:
26-
python-version: '3.9'
26+
python-version: '3.10'
2727
- name: Install dependencies
2828
run: |
2929
python -m venv venv_minimal
3030
source venv_minimal/bin/activate
3131
python -m pip install --upgrade pip
32-
pip install toml autoray==0.7.2 matplotlib-inline==0.1.7
32+
pip install toml autoray==0.7.2 matplotlib-inline==0.1.7 "setuptools<81"
3333
python3 install_lowest_dependencies.py
34+
pip install "numpy==1.23.5"
3435
- name: Test with pytest
3536
run: |
3637
source venv_minimal/bin/activate
@@ -40,30 +41,6 @@ jobs:
4041
run: |
4142
rm -rf venv_minimal
4243
43-
pytest_qiskit_0_46:
44-
runs-on: ubuntu-latest
45-
46-
steps:
47-
- uses: actions/checkout@v5
48-
- name: Set up Python
49-
uses: actions/setup-python@v6
50-
with:
51-
python-version: '3.9'
52-
- name: Install dependencies
53-
run: |
54-
python -m venv venv_qiskit_0_46
55-
source venv_qiskit_0_46/bin/activate
56-
python -m pip install --upgrade pip
57-
pip install . qiskit==0.46.3 qiskit-ibm-runtime==0.20.0 autoray==0.7.2
58-
- name: Test with pytest
59-
run: |
60-
source venv_qiskit_0_46/bin/activate
61-
pip install pytest
62-
pytest tests/
63-
- name: clean
64-
run: |
65-
rm -rf venv_qiskit_0_46
66-
6744
pytest_qiskit_1:
6845
runs-on: ubuntu-latest
6946

@@ -72,13 +49,13 @@ jobs:
7249
- name: Set up Python
7350
uses: actions/setup-python@v6
7451
with:
75-
python-version: '3.9'
52+
python-version: '3.13'
7653
- name: Install dependencies
7754
run: |
7855
python -m venv venv_qiskit_1
7956
source venv_qiskit_1/bin/activate
8057
python -m pip install --upgrade pip
81-
pip install . qiskit==1.1.2 qiskit-algorithms==0.3.0 qiskit-ibm-runtime==0.27.1 autoray==0.7.2
58+
pip install . "qiskit<2"
8259
- name: Test with pytest
8360
run: |
8461
source venv_qiskit_1/bin/activate
@@ -94,7 +71,7 @@ jobs:
9471

9572
strategy:
9673
matrix:
97-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
74+
python-version: ["3.10", "3.11", "3.12", "3.13"]
9875

9976
steps:
10077
- uses: actions/checkout@v5
@@ -111,11 +88,6 @@ jobs:
11188
source venv_latest/bin/activate
11289
python -m pip install --upgrade pip
11390
pip install .[examples]
114-
- name: Install old autoray
115-
if: matrix.python-version == '3.9'
116-
run: |
117-
source venv_latest/bin/activate
118-
pip install autoray==0.7.2
11991
- name: Test with pytest
12092
run: |
12193
source venv_latest/bin/activate
@@ -136,7 +108,7 @@ jobs:
136108

137109
strategy:
138110
matrix:
139-
python-version: ["3.9", "3.12"]
111+
python-version: ["3.10", "3.13"]
140112

141113
steps:
142114
- uses: actions/checkout@v5
@@ -152,10 +124,6 @@ jobs:
152124
python -m venv venv_latest
153125
.\venv_latest\Scripts\python.exe -m pip install --upgrade pip
154126
.\venv_latest\Scripts\pip.exe install .
155-
- name: Install old autoray
156-
if: matrix.python-version == '3.9'
157-
run: |
158-
.\venv_latest\Scripts\pip.exe install autoray==0.7.2
159127
- name: Test with pytest
160128
run: |
161129
.\venv_latest\Scripts\pip.exe install pytest
@@ -170,7 +138,7 @@ jobs:
170138

171139
strategy:
172140
matrix:
173-
python-version: ["3.9", "3.12"]
141+
python-version: ["3.10", "3.13"]
174142

175143
steps:
176144
- uses: actions/checkout@v5
@@ -187,11 +155,6 @@ jobs:
187155
source venv_latest/bin/activate
188156
python -m pip install --upgrade pip
189157
pip install .
190-
- name: Install old autoray
191-
if: matrix.python-version == '3.9'
192-
run: |
193-
source venv_latest/bin/activate
194-
pip install autoray==0.7.2
195158
- name: Test with pytest
196159
run: |
197160
source venv_latest/bin/activate

.github/workflows/quick_tests.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
21+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2222

2323
steps:
2424
- uses: actions/checkout@v5
@@ -35,11 +35,6 @@ jobs:
3535
source venv_latest/bin/activate
3636
python -m pip install --upgrade pip
3737
pip install .
38-
- name: Install old autoray
39-
if: matrix.python-version == '3.9'
40-
run: |
41-
source venv_latest/bin/activate
42-
pip install autoray==0.7.2
4338
- name: Test with pytest
4439
run: |
4540
source venv_latest/bin/activate

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sQUlearn offers scikit-learn compatible high-level interfaces for various kernel
1414

1515
## Prerequisites
1616

17-
The package requires **at least Python 3.9**.
17+
The package requires **at least Python 3.10**.
1818
## Install sQUlearn
1919

2020
### Stable Release

docs/install/install.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ Installation
66
Prerequisites
77
-------------
88

9-
sQUlearn requires a recent python3 (>=3.9) installation.
9+
sQUlearn requires a recent python3 (>=3.10) installation.
1010
Additionally the following python packages are necessary: ::
1111

1212
bayesian-optimization>=1.4.3,<2,
13-
dill>=0.3.4,
14-
mapomatic>=0.10.0,
13+
dill>=0.3.5,
14+
mapomatic>=0.12.0,
1515
networkx>=3.0,
16-
numpy>=1.20,
16+
numpy>=1.22,
1717
pennylane>=0.34.0,
18-
qiskit>=0.45.0,<2,
19-
qiskit-aer>=0.12.0,
18+
qiskit>=1.0.0,<3.0.0,
19+
qiskit-aer>=0.14.0.1,
2020
qiskit-algorithms>=0.3.0,
21-
qiskit-ibm-runtime>=0.18.0,
21+
qiskit-ibm-runtime>=0.19.0,
2222
qiskit-machine-learning>=0.7.0,
2323
scipy>=1.8.0,
2424
scikit-learn>=1.2.0,
25+
sympy>=1.8,
2526
tqdm>=4.1.0,
2627
qulacs>=0.6.0,
2728

docs/user_guide/encoding_circuits.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ It is also possible to utilize the wrapper :class:`QiskitEncodingCircuit` to bui
8383
.. jupyter-execute::
8484

8585
from squlearn.encoding_circuit import QiskitEncodingCircuit
86-
from qiskit.circuit.library import TwoLocal
87-
local = TwoLocal(3, 'ry', 'cx', 'linear', reps=2, insert_barriers=True)
86+
from qiskit.circuit.library import n_local
87+
local = n_local(3, 'ry', 'cx', 'linear', reps=2, insert_barriers=True)
8888
QiskitEncodingCircuit(local).draw(output="mpl")
8989

9090

examples/encoding_circuits/various_encoding_circuit.ipynb

Lines changed: 17 additions & 17 deletions
Large diffs are not rendered by default.

examples/executor/example_executor_qiskit.ipynb

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
"source": [
1818
"from qiskit_aer import Aer\n",
1919
"from qiskit.circuit.random import random_circuit\n",
20-
"from qiskit.primitives import Sampler, Estimator, BackendSampler, BackendEstimator\n",
20+
"from qiskit.primitives import (\n",
21+
" StatevectorSampler,\n",
22+
" StatevectorEstimator,\n",
23+
" BackendSamplerV2,\n",
24+
" BackendEstimatorV2,\n",
25+
")\n",
2126
"from qiskit.quantum_info import SparsePauliOp\n",
2227
"from qiskit_ibm_runtime import QiskitRuntimeService, Session\n",
2328
"from qiskit_ibm_runtime import Estimator as RuntimeEstimator\n",
@@ -60,28 +65,13 @@
6065
"cell_type": "code",
6166
"execution_count": 3,
6267
"metadata": {},
63-
"outputs": [
64-
{
65-
"name": "stderr",
66-
"output_type": "stream",
67-
"text": [
68-
"C:\\Users\\mow\\AppData\\Local\\Temp\\ipykernel_28608\\3565786267.py:2: DeprecationWarning: The class ``qiskit.primitives.estimator.Estimator`` is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the `BaseEstimatorV1` interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the `Estimator` class is `StatevectorEstimator`.\n",
69-
" executor = Executor(Estimator())\n",
70-
"C:\\Users\\mow\\AppData\\Local\\Temp\\ipykernel_28608\\3565786267.py:3: DeprecationWarning: The class ``qiskit.primitives.sampler.Sampler`` is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the `BaseSamplerV1` interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the `Sampler` class is `StatevectorSampler`.\n",
71-
" executor = Executor(Sampler())\n",
72-
"C:\\Users\\mow\\AppData\\Local\\Temp\\ipykernel_28608\\3565786267.py:4: DeprecationWarning: The class ``qiskit.primitives.backend_estimator.BackendEstimator`` is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the `BaseEstimatorV1` interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the `BackendEstimator` class is `BackendEstimatorV2`.\n",
73-
" executor = Executor(BackendEstimator(Aer.get_backend(\"aer_simulator\")))\n",
74-
"C:\\Users\\mow\\AppData\\Local\\Temp\\ipykernel_28608\\3565786267.py:5: DeprecationWarning: The class ``qiskit.primitives.backend_sampler.BackendSampler`` is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the `BaseSamplerV1` interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the `BackendSampler` class is `BackendSamplerV2`.\n",
75-
" executor = Executor(BackendSampler(Aer.get_backend(\"aer_simulator\")))\n"
76-
]
77-
}
78-
],
68+
"outputs": [],
7969
"source": [
8070
"# from a Qiskit simulator primitive:\n",
81-
"executor = Executor(Estimator())\n",
82-
"executor = Executor(Sampler())\n",
83-
"executor = Executor(BackendEstimator(Aer.get_backend(\"aer_simulator\")))\n",
84-
"executor = Executor(BackendSampler(Aer.get_backend(\"aer_simulator\")))"
71+
"executor = Executor(StatevectorEstimator())\n",
72+
"executor = Executor(StatevectorSampler())\n",
73+
"executor = Executor(BackendEstimatorV2(backend=Aer.get_backend(\"aer_simulator\")))\n",
74+
"executor = Executor(BackendSamplerV2(backend=Aer.get_backend(\"aer_simulator\")))"
8575
]
8676
},
8777
{
@@ -98,7 +88,7 @@
9888
},
9989
{
10090
"cell_type": "code",
101-
"execution_count": null,
91+
"execution_count": 4,
10292
"metadata": {
10393
"tags": [
10494
"skip-execution"
@@ -206,7 +196,7 @@
206196
},
207197
{
208198
"cell_type": "code",
209-
"execution_count": 8,
199+
"execution_count": 7,
210200
"metadata": {
211201
"tags": [
212202
"skip-execution"
@@ -224,7 +214,7 @@
224214
"name": "stderr",
225215
"output_type": "stream",
226216
"text": [
227-
"C:\\Users\\mow\\Documents\\dev\\squlearn\\src\\squlearn\\util\\executor.py:2476: SessionContextMisuseWarning: \u001b[1;91mCreating a session outside of a context manager may lead to unclosed sessions. It is recommended to use the Executor within a 'with' statement. At least make sure to call 'executor.close_session()' when you are done with the executor or make sure it is properly garbage collected.\u001b[0m\n",
217+
"C:\\Users\\mow\\Documents\\dev\\squlearn\\src\\squlearn\\util\\executor.py:2453: SessionContextMisuseWarning: \u001b[1;91mCreating a session outside of a context manager may lead to unclosed sessions. It is recommended to use the Executor within a 'with' statement. At least make sure to call 'executor.close_session()' when you are done with the executor or make sure it is properly garbage collected.\u001b[0m\n",
228218
" warnings.warn(\n"
229219
]
230220
},
@@ -260,7 +250,7 @@
260250
},
261251
{
262252
"cell_type": "code",
263-
"execution_count": 9,
253+
"execution_count": 8,
264254
"metadata": {},
265255
"outputs": [
266256
{
@@ -292,14 +282,14 @@
292282
"source": [
293283
"## Using Executor Primitives\n",
294284
"\n",
295-
"In this cell, we calculate an expectation value using the Estimator primitive, which is accessible through the ``Executor`` class. \n",
285+
"In this cell, we calculate an expectation value using the StatevectorEstimator primitive, which is accessible through the ``Executor`` class. \n",
296286
"The executor generates modified Primitives with enhanced functionality, including caching, automatic session management, and logging capabilities.\n",
297287
"These modified primitives can be seamlessly incorporated into your workflow or other Qiskit routines."
298288
]
299289
},
300290
{
301291
"cell_type": "code",
302-
"execution_count": 10,
292+
"execution_count": 9,
303293
"metadata": {},
304294
"outputs": [
305295
{
@@ -347,16 +337,16 @@
347337
},
348338
{
349339
"cell_type": "code",
350-
"execution_count": 11,
340+
"execution_count": 10,
351341
"metadata": {},
352342
"outputs": [
353343
{
354344
"data": {
355345
"text/plain": [
356-
"Result(backend_name='aer_simulator', backend_version='0.17.2', qobj_id='', job_id='e29cbd7e-ad0e-4169-b300-0e4036903372', success=True, results=[ExperimentResult(shots=1024, success=True, meas_level=2, data=ExperimentResultData(), header=QobjExperimentHeader(creg_sizes=[], global_phase=0.0, memory_slots=0, n_qubits=2, name='circuit-162', qreg_sizes=[['q', 2]], metadata={}), status=DONE, seed_simulator=4162277737, metadata={'batched_shots_optimization': False, 'required_memory_mb': 0, 'method': 'stabilizer', 'active_input_qubits': [], 'device': 'CPU', 'remapped_qubits': False, 'num_qubits': 0, 'num_clbits': 0, 'time_taken': 0.0002513, 'input_qubit_map': [], 'max_memory_mb': 16135, 'measure_sampling': False, 'parallel_shots': 1, 'parallel_state_update': 12, 'runtime_parameter_bind': False, 'num_bind_params': 1}, time_taken=0.0002513)], date=2026-01-21T15:24:12.886139, status=COMPLETED, header=None, metadata={'omp_enabled': True, 'parallel_experiments': 1, 'max_memory_mb': 16135, 'max_gpu_memory_mb': 0, 'time_taken_execute': 0.0021461, 'time_taken_parameter_binding': 0.0004058}, time_taken=0.010211467742919922)"
346+
"Result(backend_name='aer_simulator', backend_version='0.17.2', job_id='3bb9f877-e6e0-4ee7-a053-26827a3f2578', success=True, results=[ExperimentResult(shots=1024, success=True, meas_level=2, data=ExperimentResultData(), header={'creg_sizes': [], 'global_phase': 0.0, 'memory_slots': 0, 'n_qubits': 2, 'name': 'circuit-46', 'qreg_sizes': [['q', 2]], 'metadata': {}}, status=DONE, seed_simulator=2800168535, metadata={'batched_shots_optimization': False, 'required_memory_mb': 0, 'method': 'stabilizer', 'active_input_qubits': [], 'device': 'CPU', 'remapped_qubits': False, 'num_qubits': 0, 'num_clbits': 0, 'time_taken': 3.08e-05, 'input_qubit_map': [], 'max_memory_mb': 16135, 'measure_sampling': False, 'parallel_shots': 1, 'parallel_state_update': 12, 'runtime_parameter_bind': False, 'num_bind_params': 1}, time_taken=3.08e-05)], date=2026-02-24T07:43:07.700442, status=COMPLETED, header=None, qobj_id='', metadata={'omp_enabled': True, 'parallel_experiments': 1, 'max_memory_mb': 16135, 'max_gpu_memory_mb': 0, 'time_taken_execute': 0.0001108, 'time_taken_parameter_binding': 1.15e-05}, time_taken=0.0011229515075683594)"
357347
]
358348
},
359-
"execution_count": 11,
349+
"execution_count": 10,
360350
"metadata": {},
361351
"output_type": "execute_result"
362352
}
@@ -380,7 +370,7 @@
380370
},
381371
{
382372
"cell_type": "code",
383-
"execution_count": 12,
373+
"execution_count": 11,
384374
"metadata": {},
385375
"outputs": [
386376
{
@@ -416,7 +406,7 @@
416406
},
417407
{
418408
"cell_type": "code",
419-
"execution_count": 13,
409+
"execution_count": 12,
420410
"metadata": {},
421411
"outputs": [
422412
{
@@ -427,19 +417,11 @@
427417
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(), dtype=float64>), stds=np.float64(0.0)), metadata={'target_precision': 0.028467047115478598, 'shots': 1235, 'circuit_metadata': {}})], metadata={'version': 2})\n",
428418
"PrimitiveResult([PubResult(data=DataBin(evs=np.ndarray(<shape=(), dtype=float64>), stds=np.float64(0.0)), metadata={'target_precision': 0.01521275485262189, 'shots': 4321, 'circuit_metadata': {}})], metadata={'version': 2})\n"
429419
]
430-
},
431-
{
432-
"name": "stderr",
433-
"output_type": "stream",
434-
"text": [
435-
"C:\\Users\\mow\\AppData\\Local\\Temp\\ipykernel_28608\\735415858.py:2: DeprecationWarning: The class ``qiskit.primitives.backend_sampler.BackendSampler`` is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the `BaseSamplerV1` interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the `BackendSampler` class is `BackendSamplerV2`.\n",
436-
" BackendSampler(Aer.get_backend(\"qasm_simulator\")),\n"
437-
]
438420
}
439421
],
440422
"source": [
441423
"executor = Executor(\n",
442-
" BackendSampler(Aer.get_backend(\"qasm_simulator\")),\n",
424+
" BackendSamplerV2(backend=Aer.get_backend(\"qasm_simulator\")),\n",
443425
" log_file=\"example_log_cache.log\",\n",
444426
" caching=True,\n",
445427
" cache_dir=\"_cache\",\n",
@@ -472,7 +454,7 @@
472454
],
473455
"metadata": {
474456
"kernelspec": {
475-
"display_name": "venv",
457+
"display_name": "squlearn",
476458
"language": "python",
477459
"name": "python3"
478460
},
@@ -486,7 +468,7 @@
486468
"name": "python",
487469
"nbconvert_exporter": "python",
488470
"pygments_lexer": "ipython3",
489-
"version": "3.13.9"
471+
"version": "3.13.12"
490472
},
491473
"orig_nbformat": 4
492474
},

examples/qnn/example_qcnn_encoding_circuit.ipynb

Lines changed: 53 additions & 50 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)