[WIP] Readd support for directed basis gates to RB experiments#957
Closed
itoko wants to merge 2 commits into
Closed
[WIP] Readd support for directed basis gates to RB experiments#957itoko wants to merge 2 commits into
itoko wants to merge 2 commits into
Conversation
Contributor
Author
|
Close in favor of #960 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a feature regression introduced in #922 by re-adding the support of directed basis gates to RB module.
Details and comments
#922 accidentally dropped the support of backends with directed basis gates since it replaced the call of
transpile(circ, backend)withtranspile(circ, basis_gates=basis_gates). This commit re-add the support.For that, it newly introduces
ReducedTargetclass that is a custom Target class sufficient for basis translation in RB circuit generation. So that enables a calltranspile(circ, target=target)and caches the resulting circuit.Alternative solution
We might to need to discuss more if ReducedTarget is the right object to represent directed basis gates. It's essentially a set of (op_name, qargs) tuple, e.g. ("cx", (0, 1)) etc. The developer of translator may want to get Instruction object corresponding to the op_name string. Target does provide such a function. That's why I introduce ReducedTarget inheriting Target instead of having yet-another type similar to Target. However, it would take much more time than we thought to think of the best interface data class. So for now, it might be better to have a logic to check if available operations on the physical qubits are directed or not and if all are directed, fall back to call
transpileas before. It means we give up a speed up for some cases with directed basis. #960 is an implementation taking this alternative approach.