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

Migrate basic aer provider to new versioned interface #5128

Merged
merged 65 commits into from
Mar 30, 2021

Conversation

mtreinish
Copy link
Member

Summary

This commit migrates the basic aer provider to the v2 interface. This
was originally included in #5086 but had to be removed because of a
potential backwards compatibility issue with aqua when using basic aer
as the provider (aqua 0.7.x explicity checks for v1 interface backends).

Details and comments

mtreinish and others added 23 commits September 18, 2020 13:54
This commit is a lighterweight v2 provider interface. This is an
alternative to what is built in Qiskit#4885. While the model in Qiskit#4885 is a
desireable end state it requires a lot of changes all at once for
providers and potentially users. Instead this commit brings the core
concept from Qiskit#4885 of a cleaner explicitly versioned abstract interface
but minimizes the changes to the data model used in v1. Only some small
changes are made, mainly that jobs can be sync or async, Backend.run()
takes a circuit or schedule, options are set via an Options object at
__init__, with set_option(), or as kwargs on run(). In all other places
the object models from the v1 provider interface are used. This makes
the migration to a versioned interface simpler to start. From there we
can continue to evolve the interface as was done in Qiskit#4485, like moving
to a target object, reimplementing properties and defaults as versioned
objects, etc.

Since the differences here are so small this commit brings the basicaer
provider over to the v2 provider interface. This can be done with
minimal effort to showcase how similar the 2 interfaces are.
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
@mtreinish mtreinish added on hold Can not fix yet Changelog: New Feature Include in the "Added" section of the changelog Changelog: API Change Include in the "Changed" section of the changelog labels Sep 25, 2020
@mtreinish mtreinish added this to the 0.17 milestone Sep 25, 2020
@mtreinish mtreinish modified the milestones: 0.17, 0.18 Mar 16, 2021
@mtreinish mtreinish changed the title Migrate basic aer provider to v2 interface Migrate basic aer provider to new versioned interface Mar 16, 2021
@mtreinish
Copy link
Member Author

Once qiskit-community/qiskit-aqua#1554 merges we can temporarily use qiskit-aqua from master in the tutorials job and that should unblock this for inclusion in the release. We do need to be careful with this approach though, because if we use master on the tutorial CI job we open up an opportunity to introduce breaking changes (for aqua's terra usage) which we want to avoid.

@mtreinish mtreinish modified the milestones: 0.18, 0.17 Mar 25, 2021
@mtreinish mtreinish removed the on hold Can not fix yet label Mar 25, 2021
:class:`~qiskit.providers.JobV1`. This means that calls to
the :meth:`~qiskit.providers.basicaer.QasmSimulatorPy.run` will block
until the simulation finishes executing. If you want to restore the
previous async behavior you'll need to wrap
Copy link
Member

Choose a reason for hiding this comment

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

incomplete sentence here

def _default_options(cls):
return Options(shots=1024, memory=False,
initial_statevector=None, chop_threshold=1e-15,
allow_sample_measuring=False, seed_simulator=None,
Copy link
Member

Choose a reason for hiding this comment

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

I think allow_sample_measuring should be True by default otherwise it will be very slow (1000x slower for a 1000-shot simulation).

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just mirroring what was the default before. I'll change it here and add an upgrade release note about the change

Suggested change
allow_sample_measuring=False, seed_simulator=None,
allow_sample_measuring=True, seed_simulator=None,

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually think we'll be ok without a release note for this. Looking at the code for checking the option: https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/providers/basicaer/qasm_simulator.py#L340-L378 it would default to True if nothing was set if the circuit is capable of using sample measuring. So I think putting either value here doesn't matter too much as it doesn't really change the behavior.

mtreinish and others added 2 commits March 27, 2021 13:00
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
@mergify mergify bot merged commit f34c0da into Qiskit:master Mar 30, 2021
ElePT pushed a commit to ElePT/qiskit-algorithms that referenced this pull request Jul 27, 2023
…5128)

* Add lightweight v2 provider interface starter

This commit is a lighterweight v2 provider interface. This is an
alternative to what is built in Qiskit/qiskit#4885. While the model in Qiskit/qiskit#4885 is a
desireable end state it requires a lot of changes all at once for
providers and potentially users. Instead this commit brings the core
concept from Qiskit/qiskit#4885 of a cleaner explicitly versioned abstract interface
but minimizes the changes to the data model used in v1. Only some small
changes are made, mainly that jobs can be sync or async, Backend.run()
takes a circuit or schedule, options are set via an Options object at
__init__, with set_option(), or as kwargs on run(). In all other places
the object models from the v1 provider interface are used. This makes
the migration to a versioned interface simpler to start. From there we
can continue to evolve the interface as was done in Qiskit/qiskit#4485, like moving
to a target object, reimplementing properties and defaults as versioned
objects, etc.

Since the differences here are so small this commit brings the basicaer
provider over to the v2 provider interface. This can be done with
minimal effort to showcase how similar the 2 interfaces are.

* Fix basicaer simulator init

* Fix lint

* Add provider property to basicaer for Aqua backwards compat

* Add provider method back to backend class for backwards compat

* Fix lint

* Add release notes

* Add v2 provider to docs

* Fix lint

* Revert basicaer v2 provider migration

* Apply suggestions from code review

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Add missing version attributes

* Make Options a simplenamespace subclass

* Update Backend docstrings

* Add v2 Backend support to the rest of terra

* Fix lint

* Fix lint

* Flatten providers subpackage

* Apply suggestions from code review

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update release notes

* Migrate basic aer provider to v2 interface

This commit migrates the basic aer provider to the v2 interface. This
was originally included in Qiskit/qiskit#5086 but had to be removed because of a
potential backwards compatibility issue with aqua when using basic aer
as the provider (aqua 0.7.x explicity checks for v1 interface backends).

* DNM install aqua from source to test tutorials

* Remove deprecated schema validation

* Test failures

* Fix tests and lint

* Install aqua from source until release

* Add release notes

* Add ignis from source too as a dependency of aqua

* Apply suggestions from code review

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Finish upgrade release note

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants