Skip to content

Commit

Permalink
Fix MPS size estimator (Qiskit#2229)
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Sep 13, 2024
1 parent 8dee229 commit 47ac790
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
SIGSEGV raised when the circuits with unsupported gates is
passed to MPS simulator, because of `std::set.find()` in
size estimator for MPS.
This fix avoids SIGSEGV if unsupported gates is passed.
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ uint_t MPSSizeEstimator::estimate(const std::vector<Operations::Op> &ops,
case Operations::OpType::gate:
if (ops[i].qubits.size() > 1) {
auto it = gateset.find(ops[i].name);
switch (it->second) {
case Gates::rxx:
case Gates::ryy:
case Gates::rzx:
pi2 = std::real(ops[i].params[0]) / M_PI;
pi2_int = (double)std::round(pi2);
if (!AER::Linalg::almost_equal(pi2, pi2_int))
apply_qubits(ops[i].qubits);
break;
default:
break;
if (it != gateset.end()) {
switch (it->second) {
case Gates::rxx:
case Gates::ryy:
case Gates::rzx:
pi2 = std::real(ops[i].params[0]) / M_PI;
pi2_int = (double)std::round(pi2);
if (!AER::Linalg::almost_equal(pi2, pi2_int))
apply_qubits(ops[i].qubits);
break;
default:
break;
}
}
}
break;
Expand Down

0 comments on commit 47ac790

Please sign in to comment.