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

Store simulator Backend in FakeBackend instance #7912

Merged
merged 5 commits into from
Apr 19, 2022

Conversation

mtreinish
Copy link
Member

Summary

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.

Details and comments

Fixes #7500
Fixes #7911

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 mtreinish added stable backport potential The bug might be minimal and/or import enough to be port to stable performance Changelog: None Do not include in changelog labels Apr 8, 2022
@mtreinish mtreinish requested a review from a team as a code owner April 8, 2022 16:29
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

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.
@mtreinish mtreinish added the mod: fake_provider Related to the fake_provider module and fake backends label Apr 8, 2022
@mtreinish mtreinish changed the title Initialize simulator at FakeBackend inititialization Store simulator Backend in FakeBackend instance Apr 8, 2022
@coveralls
Copy link

coveralls commented Apr 8, 2022

Pull Request Test Coverage Report for Build 2186799126

  • 66 of 71 (92.96%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 83.965%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/test/mock/fake_backend.py 58 63 92.06%
Files with Coverage Reduction New Missed Lines %
qiskit/test/mock/fake_backend.py 2 83.4%
qiskit/pulse/library/waveform.py 3 89.36%
Totals Coverage Status
Change from base Build 2186752988: 0.02%
Covered Lines: 54238
Relevant Lines: 64596

💛 - Coveralls

@mtreinish mtreinish added this to the 0.20.1 milestone Apr 13, 2022
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mergify mergify bot merged commit 57f16ab into Qiskit:main Apr 19, 2022
mergify bot pushed a commit that referenced this pull request 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 pull request 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]>
@mtreinish mtreinish deleted the optimize-noise-model-fake-backends branch April 25, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog mod: fake_provider Related to the fake_provider module and fake backends performance stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
4 participants