-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fractional gate opt-in #1715
Fractional gate opt-in #1715
Conversation
a798fe8
to
8097c3b
Compare
Pull Request Test Coverage Report for Build 9401855600Details
💛 - Coveralls |
(clue for review) I added unit tests in three steps:
|
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.
Some relatively minor comments, but overall looks good!
Co-authored-by: Jessie Yu <[email protected]>
Thanks @jyu00 I updated the PR. Do you have any comment on the rest of two topics in the PR comment?: Mutability and Breaking API change |
2007873
to
f8fdf8a
Compare
Do you want to add checks at the client side that PEC and PEA are not requested along with fractional gates? |
Co-authored-by: Yael Ben-Haim <[email protected]>
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.
LGTM!
Doing it on the client side has the disadvantage that down level client code would become stale when updates are made on the server side (e.g. if/when we support fractional gates with dynamic circuits). So I was really hoping the validation service will be setup in time, although that's not looking likely. Regardless, I'd highly recommend doing the check in a separate PR, if we don't want to wait on the validation service. |
Summary
This PR adds the fractional gate opt-in feature. In IBM backend architecture, dynamic circuits and fractional gates will be exclusively supported. However, Qiskit Target model doesn't express such a constraint. This means one must create two target instances, namely, one only with the fractional gate instructions and the other one only with the control flow instructions. The choice of target is the responsibility of the end users.
This opt-in might be removed without announce when IBM backend architecture changes.
Details and comments
This PR is draft to conclude the final design.
Both
QiskitRuntimeService.backends()
andQiskitRuntimeService.backend()
gainsuse_fractional_gate
argument. User needs to set True to include fractional gates in the backend target.In the current implementation, the service instance pre caches all backends associated with the account. This has been reasonable design. However, with the new flag, the same backend will have two instances with/without fractional gates/control flow instructions in their target. Change of the flag will silently mutate the cached backend. For example,
The easiest solution is to deepcopy the instance before returning it to users (target is created when the end user calls any attribute from the target for the first time). We don't like deepcopy though. Alternatively we can remove this cache and always call
_create_backend_obj
when the backend is retrieved. This maybe increase REST GET call overhead to get configuration data from server, but makes internal code simpler (and might reduce memory footprint if retrieved backend is GC'd). If the user doesn't retrieve the same backend multiple times there is no overhead with this change.We set default of
use_fractional_gates
to True because dynamic circuit seems not being heavily used. However this is indeed a breaking API change for end users because it silently mutates basis gates and changes the resulting isa circuits, and maybe fidelity too. We can also start with False, then turn it on with deprecation warning if we want. From the API break viewpoint, another concern is a user can still use qiskit-ibm-runtime before this commit even after our backends start to report fractional basis gates. This will create a target with mixture of fractional and control flow instructions, which will create invalid isa circuits when it includes any control flow. In the current version there is no warning mechanism in the client software, which might frustrate end users using outdated runtime.TODO