From f49232e2458f3838b867411ae37569fd9aa504ba Mon Sep 17 00:00:00 2001 From: "M. Emre Sahin" <40424147+OkuyanBoga@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:07:42 +0000 Subject: [PATCH 1/2] Added checks for different transpiler types (#879) (cherry picked from commit e1859ddbbe99734ac7dd56b05512e5a7420085aa) --- qiskit_machine_learning/neural_networks/estimator_qnn.py | 5 ++++- qiskit_machine_learning/neural_networks/sampler_qnn.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qiskit_machine_learning/neural_networks/estimator_qnn.py b/qiskit_machine_learning/neural_networks/estimator_qnn.py index 96696a07c..89ac0fbd1 100644 --- a/qiskit_machine_learning/neural_networks/estimator_qnn.py +++ b/qiskit_machine_learning/neural_networks/estimator_qnn.py @@ -183,7 +183,10 @@ def __init__( self.num_virtual_qubits = circuit.num_qubits else: circuit = pass_manager.run(circuit) - self.num_virtual_qubits = circuit.layout._input_qubit_count + if hasattr(circuit.layout, "_input_qubit_count"): + self.num_virtual_qubits = circuit.layout._input_qubit_count + else: + self.num_virtual_qubits = circuit.num_qubits self._org_circuit = circuit diff --git a/qiskit_machine_learning/neural_networks/sampler_qnn.py b/qiskit_machine_learning/neural_networks/sampler_qnn.py index b6a1eb911..ad2a17870 100644 --- a/qiskit_machine_learning/neural_networks/sampler_qnn.py +++ b/qiskit_machine_learning/neural_networks/sampler_qnn.py @@ -209,7 +209,10 @@ def __init__( self.num_virtual_qubits = circuit.num_qubits else: circuit = pass_manager.run(circuit) - self.num_virtual_qubits = circuit.layout._input_qubit_count + if hasattr(circuit.layout, "_input_qubit_count"): + self.num_virtual_qubits = circuit.layout._input_qubit_count + else: + self.num_virtual_qubits = circuit.num_qubits self._org_circuit = circuit From 1edad30d7becd540b4bd763c05e44a75c5dad85a Mon Sep 17 00:00:00 2001 From: Edoardo Altamura <38359901+edoaltamura@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:50:31 +0100 Subject: [PATCH 2/2] Update constraints.txt