Portuguese
Idiomas
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

Target

class Target(description=None, num_qubits=0, dt=None, granularity=1, min_length=1, pulse_alignment=1, acquire_alignment=1, qubit_properties=None)[código fonte]

Bases: Mapping

The intent of the Target object is to inform Qiskit’s compiler about the constraints of a particular backend so the compiler can compile an input circuit to something that works and is optimized for a device. It currently contains a description of instructions on a backend and their properties as well as some timing information. However, this exact interface may evolve over time as the needs of the compiler change. These changes will be done in a backwards compatible and controlled manner when they are made (either through versioning, subclassing, or mixins) to add on to the set of information exposed by a target.

As a basic example, let’s assume backend has two qubits, supports UGate on both qubits and CXGate in both directions. To model this you would create the target like:

from qiskit.transpiler import Target, InstructionProperties
from qiskit.circuit.library import UGate, CXGate
from qiskit.circuit import Parameter

gmap = Target()
theta = Parameter('theta')
phi = Parameter('phi')
lam = Parameter('lambda')
u_props = {
    (0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
    (1,): InstructionProperties(duration=4.52e-8, error=0.00032115),
}
gmap.add_instruction(UGate(theta, phi, lam), u_props)
cx_props = {
    (0,1): InstructionProperties(duration=5.23e-7, error=0.00098115),
    (1,0): InstructionProperties(duration=4.52e-7, error=0.00132115),
}
gmap.add_instruction(CXGate(), cx_props)

Each instruction in the Target is indexed by a unique string name that uniquely identifies that instance of an Instruction object in the Target. There is a 1:1 mapping between a name and an Instruction instance in the target and each name must be unique. By default the name is the name attribute of the instruction, but can be set to anything. This lets a single target have multiple instances of the same instruction class with different parameters. For example, if a backend target has two instances of an RXGate one is parameterized over any theta while the other is tuned up for a theta of pi/6 you can add these by doing something like:

import math

from qiskit.transpiler import Target, InstructionProperties
from qiskit.circuit.library import RXGate
from qiskit.circuit import Parameter

target = Target()
theta = Parameter('theta')
rx_props = {
    (0,): InstructionProperties(duration=5.23e-8, error=0.00038115),
}
target.add_instruction(RXGate(theta), rx_props)
rx_30_props = {
    (0,): InstructionProperties(duration=1.74e-6, error=.00012)
}
target.add_instruction(RXGate(math.pi / 6), rx_30_props, name='rx_30')

Then in the target object accessing by rx_30 will get the fixed angle RXGate while rx will get the parameterized RXGate.

Nota

This class assumes that qubit indices start at 0 and are a contiguous set if you want a submapping the bits will need to be reindexed in a new``Target`` object.

Nota

This class only supports additions of gates, qargs, and qubits. If you need to remove one of these the best option is to iterate over an existing object and create a new subset (or use one of the methods to do this). The object internally caches different views and these would potentially be invalidated by removals.

Create a new Target object

Obsoleto desde a versão 0.23.0: qiskit.transpiler.target.Target.__init__()”s argument aquire_alignment is deprecated as of qiskit-terra 0.23.0. It will be removed no earlier than 3 months after the release date. Instead, use the argument acquire_alignment, which behaves identically.

Parâmetros
  • description (str) – An optional string to describe the Target.

  • num_qubits (int) – An optional int to specify the number of qubits the backend target has. If not set it will be implicitly set based on the qargs when add_instruction() is called. Note this must be set if the backend target is for a noiseless simulator that doesn’t have constraints on the instructions so the transpiler knows how many qubits are available.

  • dt (float) – The system time resolution of input signals in seconds

  • granularity (int) – An integer value representing minimum pulse gate resolution in units of dt. A user-defined pulse gate should have duration of a multiple of this granularity value.

  • min_length (int) – An integer value representing minimum pulse gate length in units of dt. A user-defined pulse gate should be longer than this length.

  • pulse_alignment (int) – An integer value representing a time resolution of gate instruction starting time. Gate instruction should start at time which is a multiple of the alignment value.

  • acquire_alignment (int) – An integer value representing a time resolution of measure instruction starting time. Measure instruction should start at time which is a multiple of the alignment value.

  • qubit_properties (list) – A list of QubitProperties objects defining the characteristics of each qubit on the target device. If specified the length of this list must match the number of qubits in the target, where the index in the list matches the qubit number the properties are defined for. If some qubits don’t have properties available you can set that entry to None

Levanta
  • ValueError – If both num_qubits and qubit_properties are both

  • defined and the value of num_qubits differs from the length of

  • qubit_properties`

Methods

add_instruction

Add a new instruction to the Target

build_coupling_map

Get a CouplingMap from this target.

durations

Get an InstructionDurations object from the target

from_configuration

Create a target object from the individual global configuration

get

get_calibration

Get calibrated pulse schedule for the instruction.

get_non_global_operation_names

Return the non-global operation names for the target

has_calibration

Return whether the instruction (operation + qubits) defines a calibration.

instruction_properties

Get the instruction properties for a specific instruction tuple

instruction_schedule_map

Return an InstructionScheduleMap for the instructions in the target with a pulse schedule defined.

instruction_supported

Return whether the instruction (operation + qubits) is supported by the target

items

keys

operation_from_name

Get the operation class object for a given name

operation_names_for_qargs

Get the operation names for a specified qargs tuple

operations_for_qargs

Get the operation class object for a specified qargs tuple

qargs_for_operation_name

Get the qargs for a given operation name

timing_constraints

Get an TimingConstraints object from the target

update_from_instruction_schedule_map

Update the target from an instruction schedule map.

update_instruction_properties

Update the property object for an instruction qarg pair already in the Target

values

Attributes

num_qubits
description
dt
granularity
min_length
pulse_alignment
acquire_alignment
qubit_properties
aquire_alignment

Alias of deprecated name. This will be removed.

Obsoleto desde a versão 0.24.0: The property qiskit.transpiler.target.Target.aquire_alignment is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Use the property acquire_alignment instead.

instructions

Get the list of tuples (:class:`~qiskit.circuit.Instruction`, (qargs)) for the target

For globally defined variable width operations the tuple will be of the form (class, None) where class is the actual operation class that is globally defined.

operation_names

Get the operation names in the target.

operations

Get the operation class objects in the target.

physical_qubits

Returns a sorted list of physical_qubits

qargs

The set of qargs in the target.