Skip to content

Commit

Permalink
Merge branch 'Qiskit:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanro authored Nov 7, 2024
2 parents 1424eff + 5994b77 commit feaadfc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes a bug preventing the MPS simulator from running when its estimate
for the required memory is too large, even when `max_memory_mb=-1`.
2 changes: 1 addition & 1 deletion src/simulators/circuit_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ uint_t Executor<state_t>::get_max_parallel_shots(
const Config &config, const Circuit &circ,
const Noise::NoiseModel &noise) const {
uint_t mem = required_memory_mb(config, circ, noise);
if (mem == 0)
if (mem == 0 || !check_required_memory_)
return circ.shots * circ.num_bind_params;

if (sim_device_ == Device::GPU && num_gpus_ > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import math
import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.circuit.library import PauliEvolutionGate
from qiskit.quantum_info import SparsePauliOp
from qiskit.synthesis import SuzukiTrotter
from test.terra.backends.simulator_test_case import SimulatorTestCase, supported_methods


Expand Down Expand Up @@ -60,3 +63,32 @@ def test_save_matrix_product_state(self, method, device):
self.assertTrue(np.allclose(val, target))
for val, target in zip(value[1], target_lambda_reg):
self.assertTrue(np.allclose(val, target))

@supported_methods(["automatic", "matrix_product_state"])
def test_save_matrix_product_state_memory_limit(self, method, device):
"""Test save matrix_product_state instruction when max memory check is disabled"""
backend = self.backend(
method=method,
device=device,
matrix_product_state_max_bond_dimension=10,
max_memory_mb=-1, # Disable memory limit check
)

L = 100
hamiltonian = SparsePauliOp.from_sparse_list([], num_qubits=L)
for x in range(L - 1):
hamiltonian += SparsePauliOp.from_sparse_list(
[
("XX", (x, x + 1), 1),
("YY", (x, x + 1), 1),
],
num_qubits=L,
)
qc = QuantumCircuit(L)
qc.append(
PauliEvolutionGate(hamiltonian, synthesis=SuzukiTrotter(reps=100)), qargs=qc.qubits
)
qc = qc.decompose()
qc.save_matrix_product_state("mps")
result = backend.run(qc).result().data(0)
self.assertTrue("mps" in result)

0 comments on commit feaadfc

Please sign in to comment.