Japanese
言語
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

TranslateParameterizedGates

class TranslateParameterizedGates(*args, **kwargs)[ソース]

ベースクラス: TransformationPass

Translate parameterized gates to a supported basis set.

Once a parameterized instruction is found that is not in the supported_gates list, the instruction is decomposed one level and the parameterized sub-blocks are recursively decomposed. The recursion is stopped once all parameterized gates are in supported_gates, or if a gate has no definition and a translation to the basis is attempted (this might happen e.g. for the UGate if it’s not in the specified gate list).

サンプル

The following, multiply nested circuit:

from qiskit.circuit import QuantumCircuit, ParameterVector
from qiskit.transpiler.passes import TranslateParameterizedGates

x = ParameterVector("x", 4)
block1 = QuantumCircuit(1)
block1.rx(x[0], 0)

sub_block = QuantumCircuit(2)
sub_block.cx(0, 1)
sub_block.rz(x[2], 0)

block2 = QuantumCircuit(2)
block2.ry(x[1], 0)
block2.append(sub_block.to_gate(), [0, 1])

block3 = QuantumCircuit(3)
block3.ccx(0, 1, 2)

circuit = QuantumCircuit(3)
circuit.append(block1.to_gate(), [1])
circuit.append(block2.to_gate(), [0, 1])
circuit.append(block3.to_gate(), [0, 1, 2])
circuit.cry(x[3], 0, 2)

supported_gates = ["rx", "ry", "rz", "cp", "crx", "cry", "crz"]
unrolled = TranslateParameterizedGates(supported_gates)(circuit)

is decomposed to:

     ┌──────────┐     ┌──────────┐┌─────────────┐
q_0: ┤ Ry(x[1]) ├──■──┤ Rz(x[2]) ├┤0            ├─────■──────
     ├──────────┤┌─┴─┐└──────────┘│             │     │
q_1: ┤ Rx(x[0]) ├┤ X ├────────────┤1 circuit-92 ├─────┼──────
     └──────────┘└───┘            │             │┌────┴─────┐
q_2: ─────────────────────────────┤2            ├┤ Ry(x[3]) ├
                                  └─────────────┘└──────────┘
パラメータ
  • supported_gates – A list of suppported basis gates specified as string. If None, a target must be provided.

  • equivalence_library – The equivalence library to translate the gates. Defaults to the equivalence library of all Qiskit standard gates.

  • target – A Target containing the supported operations. If None, supported_gates must be set. Note that this argument takes precedence over supported_gates, if both are set.

例外

ValueError – If neither of supported_gates and target are passed.

Methods

name

Return the name of the pass.

run

Run the transpiler pass.

Attributes

is_analysis_pass

Check if the pass is an analysis pass.

If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.

is_transformation_pass

Check if the pass is a transformation pass.

If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).