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

CostBasedFusion aggregate_operations crash #2074

Closed
aromanro opened this issue Feb 26, 2024 · 2 comments
Closed

CostBasedFusion aggregate_operations crash #2074

aromanro opened this issue Feb 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@aromanro
Copy link
Contributor

Informations

  • Qiskit Aer version: Latest dev main branch sources
  • Python version: Irrelevant, as I'm using it from a c++ project
  • Operating system: Windows 11

What is the current behavior?

During some tests I do, CostBasedFusion::aggregate_operations crashes.

Steps to reproduce the problem

I'm executing some randomly generated circuits, I'm not yet sure how to reproduce it, but I think I could point out to a reason and a solution.

This is the problem code:

        double estimated_cost =
            estimate_cost(ops, (uint_t)j,
                          i) // fusion gate from j-th to i-th, and
            + (j == 0 ? 0.0 : costs[j - 1 - fusion_start]); // cost of (j-1)-th

With debug, I end up with j being 2, fusion_start also 2 and costs size being 2. This results in a costs[-1], resulting in a crash.

What is the expected behavior?

Not crashing, obviously :)

Suggested solutions

Replace the j == 0 check with j == fusion_start.

@aromanro aromanro added the bug Something isn't working label Feb 26, 2024
@aromanro
Copy link
Contributor Author

More info:

I think this commit introduced the issue: a5e3aa2

@hhorii
Copy link
Collaborator

hhorii commented Apr 16, 2024

We believe that #2075 fixes this issue.

@hhorii hhorii closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants