Skip to content
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

Fix AerBackend.set_max_qubits #2159

Merged
merged 2 commits into from
Jun 5, 2024
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
1 change: 1 addition & 0 deletions qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def set_max_qubits(self, max_qubits):
"""Set maximun number of qubits to be used for this backend."""
if self._target is None:
self._configuration.n_qubits = max_qubits
self._set_configuration_option("n_qubits", max_qubits)

def clear_options(self):
"""Reset the simulator options to default values."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
`AerBackend.set_max_qubits` did not update `n_qubits` in configuration
that was overwritten by setting backend option `method` at initialization.
This fix set `n_qubits` in configuration by calling `_set_configuration_option`
18 changes: 16 additions & 2 deletions test/terra/primitives/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

from qiskit_aer.primitives import Sampler

from test.terra.backends.simulator_test_case import supported_methods


@ddt
class TestSampler(QiskitAerTestCase):
Expand Down Expand Up @@ -270,9 +272,21 @@ def test_multiple_cregs(self):
result = Sampler().run(qc, shots=100).result()
self.assertDictAlmostEqual(result.quasi_dists[0], {0: 1})

def test_truncate_large_circuit(self):
@supported_methods(
[
"automatic",
"statevector",
"density_matrix",
"matrix_product_state",
"stabilizer",
"extended_stabilizer",
"tensor_network",
]
)
def test_truncate_large_circuit(self, method, device):
"""Test trancate large circuit in transplier"""
sampler = Sampler()
options = {"method": method, "device": device}
sampler = Sampler(backend_options=options)
qc = QuantumCircuit(100, 2)
qc.h(98)
qc.cx(98, 99)
Expand Down
Loading