-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
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.
…into v2-providers-lite
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
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. |
: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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
allow_sample_measuring=False, seed_simulator=None, | |
allow_sample_measuring=True, seed_simulator=None, |
There was a problem hiding this comment.
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.
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
…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>
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