Skip to content

being able to look up InstructionProperties from Instruction (not name) in Target #8892

@ajavadia

Description

@ajavadia

What should we add?

Here's a small Target. The Operation names differ from the string by which they are keyed in the Target.

import math
from qiskit.transpiler import Target, InstructionProperties
from qiskit.circuit.library import RZZGate
from qiskit.circuit import Parameter

rzz_30_props = {
    (0, 1): InstructionProperties(duration=0.74e-7, error=.00002)
}

rzz_45_props = {
    (0, 1): InstructionProperties(duration=1.04e-6, error=.0002)
}

target = Target()
target.add_instruction(RZZGate(math.pi / 6), rzz_30_props, name='rzz_30')
target.add_instruction(RZZGate(math.pi / 4), rzz_45_props, name='rzz_45')

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:

[Instruction(name='rzz', num_qubits=2, num_clbits=0, params=[0.5235987755982988]),
 Instruction(name='rzz', num_qubits=2, num_clbits=0, params=[0.7853981633974483])]

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions