-
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
being able to look up InstructionProperties from Instruction (not name) in Target #8892
Comments
So you can do: names = target.operation_names_for_qargs((0, 1))
operation_and_errors = [(target.operation_from_name(name), target[name][(0, 1)].error) for name in names] there is also the The one constraint in general is that the name is the canonical reference to operations in the target, and each operation defined in the target needs a unique name accordingly. So if we work with anything other than the name it will be an That being said we should support the use case of lookup needed here, can you describe what you want the lookup method to look like and what the return is I think we can easily add this for 0.23.0. |
I think I'm realizing now that I agree the lookup will be O(n) and we should document that. But I think having the option is useful. For now I'll use the first solution you proposed. |
Just thinking out loud would the interface for So it would be something like |
yeah that works too. and raise KeyError if not available. |
This commit adds 6 new helper methods to the Target class. These methods are used to query the target by either name or class to extract the InstructionProperties (or attributes of them) for a given instruction. Previously doing this by name was possible using the mapping protocol, but handling the combination of ideal gates with ``None`` at different levels in the internal dictionaries was cumbersome and error prone. These methods give a simple entry point to do the query which abstracts away the internal structure of the target. For the methods which use a class based lookup this wasn't easily accomplishable before, the closest available method would just return a boolean about whether the class was supported on the target or not. Implements Qiskit#8892
What should we add?
Here's a small Target. The Operation names differ from the string by which they are keyed in the Target.
So if I want to know the gates I have available on (0,1), I could do,
target.operations_for_qargs((0,1))
, which gives:But to look up the error for any of these, it seems like I need to know the associated key in the Target which is difficult.
If I try to get that via,
target.operation_names_for_qargs((0,1))
I get a set which is not ordered like the above Instructions.{'rzz_30', 'rzz_45'}
It would be helpful to be able to go directly from an Instruction to its error rate, and not have to go via the Target key, which may be some arbitrary string even.
The text was updated successfully, but these errors were encountered: