From a713dde93f20b2e6ce44faa992ec83ccb03cf66a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:45:53 +0000 Subject: [PATCH] Extended support for different V2 transpilers from different backends. (backport #879) (#882) * Added checks for different transpiler types (#879) (cherry picked from commit e1859ddbbe99734ac7dd56b05512e5a7420085aa) * Update constraints.txt --------- Co-authored-by: M. Emre Sahin <40424147+OkuyanBoga@users.noreply.github.com> Co-authored-by: Edoardo Altamura <38359901+edoaltamura@users.noreply.github.com> --- 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