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

Cache the target of AerSimulator #2328

Open
wshanks opened this issue Mar 5, 2025 · 0 comments
Open

Cache the target of AerSimulator #2328

wshanks opened this issue Mar 5, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@wshanks
Copy link
Contributor

wshanks commented Mar 5, 2025

What is the expected behavior?

Currently, generating a backend with AerSimulator() does not cache the .target property. The target is only cached if AerSimulator._from_backend is set by passing a target to AerSimulator's constructor. The target generation is somewhat expensive, about 0.7 seconds on my machine. When looping over circuits, this time can add up. Looking at the code, I think the target could be cached safely as long as the cache was invalidated by calling set_option since that is the only supported way of changing configuration() and properties() which are the only things AerSimulator.target references.

I noticed this when finally tracking down why some code that looped over circuits calling transpile had gotten slow (it had been slow for a while, probably since support for BackendV2 was added to Aer). I can address it locally by changing the code to call transpile on the lists of circuits but it would still be worth considering doing this caching if it seems reasonable to the maintainers.

@wshanks wshanks added the enhancement New feature or request label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant