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

FakeBackends are inefficient because noise model is repeatedly built #7911

Closed
nonhermitian opened this issue Apr 8, 2022 · 1 comment · Fixed by #7912
Closed

FakeBackends are inefficient because noise model is repeatedly built #7911

nonhermitian opened this issue Apr 8, 2022 · 1 comment · Fixed by #7912
Labels
mod: fake_provider Related to the fake_provider module and fake backends type: enhancement It's working, but needs polishing

Comments

@nonhermitian
Copy link
Contributor

What is the expected enhancement?

When using FakeBackends there are multiple calls to noise_model.from_backend that lead to hug performance hits. E.g from profiling one VQE run, 40 out of 58 seconds is just building noise models repeatedly:

201    0.019    0.000   40.505    0.202 noise_model.py:209(from_backend)

However, doing the building direct in Aer removes all of this overhead. Namely:

sim = Aer.get_backend('aer_simulator')
nsim = sim.from_backend(FAKE_BACKEND_INSTANCE)

is dramatically faster.

I am guessing this is because FakeBackend was created before Aer had this capability.

@nonhermitian nonhermitian added the type: enhancement It's working, but needs polishing label Apr 8, 2022
@mtreinish mtreinish added the mod: fake_provider Related to the fake_provider module and fake backends label Apr 8, 2022
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Apr 8, 2022
This commit updates the FakeBackend and FakeBackendV2 classes
(FakeLegacyBackend is being removed in Qiskit#7886) to only build a noise
model from the stored properties one. This is done by initializing the
internal simulator object only once at storing it as an instance
attribute. The noise model is then constructed once at object
initialization and used to update the backend at the same time.

Fixes Qiskit#7500
Fixes Qiskit#7911
@mtreinish
Copy link
Member

This should be fixed by: #7912 I've tagged it for backport to 0.20.1 (which will hopefully go out next week).

@mergify mergify bot closed this as completed in #7912 Apr 19, 2022
mergify bot added a commit that referenced this issue Apr 19, 2022
* Initialize simulator at FakeBackend inititialization

This commit updates the FakeBackend and FakeBackendV2 classes
(FakeLegacyBackend is being removed in #7886) to only build a noise
model from the stored properties one. This is done by initializing the
internal simulator object only once at storing it as an instance
attribute. The noise model is then constructed once at object
initialization and used to update the backend at the same time.

Fixes #7500
Fixes #7911

* Lazy load simulator backend objects and properties

This commit fixes another regression introduced in the previous commit
around the import and __init__ performance of fake backends. By parsing
the properties payload and creating a noise model we significantly
slowed down the initialization of fake backend objects. This commit
fixes this by ensuring we are lazy loading the noise model and simulator
object creation as well as not parsing the properties (or defaults)
payloads until we actually need them.

* Use qubit properties in target for backendv2

* Filter all noise model warnings

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot pushed a commit that referenced this issue Apr 19, 2022
* Initialize simulator at FakeBackend inititialization

This commit updates the FakeBackend and FakeBackendV2 classes
(FakeLegacyBackend is being removed in #7886) to only build a noise
model from the stored properties one. This is done by initializing the
internal simulator object only once at storing it as an instance
attribute. The noise model is then constructed once at object
initialization and used to update the backend at the same time.

Fixes #7500
Fixes #7911

* Lazy load simulator backend objects and properties

This commit fixes another regression introduced in the previous commit
around the import and __init__ performance of fake backends. By parsing
the properties payload and creating a noise model we significantly
slowed down the initialization of fake backend objects. This commit
fixes this by ensuring we are lazy loading the noise model and simulator
object creation as well as not parsing the properties (or defaults)
payloads until we actually need them.

* Use qubit properties in target for backendv2

* Filter all noise model warnings

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 57f16ab)
mergify bot added a commit that referenced this issue Apr 19, 2022
* Initialize simulator at FakeBackend inititialization

This commit updates the FakeBackend and FakeBackendV2 classes
(FakeLegacyBackend is being removed in #7886) to only build a noise
model from the stored properties one. This is done by initializing the
internal simulator object only once at storing it as an instance
attribute. The noise model is then constructed once at object
initialization and used to update the backend at the same time.

Fixes #7500
Fixes #7911

* Lazy load simulator backend objects and properties

This commit fixes another regression introduced in the previous commit
around the import and __init__ performance of fake backends. By parsing
the properties payload and creating a noise model we significantly
slowed down the initialization of fake backend objects. This commit
fixes this by ensuring we are lazy loading the noise model and simulator
object creation as well as not parsing the properties (or defaults)
payloads until we actually need them.

* Use qubit properties in target for backendv2

* Filter all noise model warnings

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 57f16ab)

Co-authored-by: Matthew Treinish <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: fake_provider Related to the fake_provider module and fake backends type: enhancement It's working, but needs polishing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants