Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK. Go to the latest version.

qiskit.transpiler.passes.BasisTranslator

class BasisTranslator(*args, **kwargs)

GitHub

Translates gates to a target basis by searching for a set of translations from a given EquivalenceLibrary.

This pass operates in several steps:

  • Determine the source basis from the input circuit.
  • Perform an A* search over basis sets, starting from the source basis and targeting the device’s target_basis, with edges discovered from the provided EquivalenceLibrary. The heuristic used by the A* search is the number of distinct circuit basis gates not in the target_basis, plus the number of distinct device basis gates not used in the current basis.
  • The found path, as a set of rules from the EquivalenceLibrary, is composed into a set of gate replacement rules.
  • The composed replacement rules are applied in-place to each op node which is not already in the target_basis.

Initialize a BasisTranslator instance.

Parameters

  • equivalence_library (EquivalenceLibrary) – The equivalence library which will be used by the BasisTranslator pass. (Instructions in this library will not be unrolled by this pass.)
  • target_basis (list[str]) – Target basis names to unroll to, e.g. [‘u3’, ‘cx’].

__init__

__init__(equivalence_library, target_basis)

Initialize a BasisTranslator instance.

Parameters

  • equivalence_library (EquivalenceLibrary) – The equivalence library which will be used by the BasisTranslator pass. (Instructions in this library will not be unrolled by this pass.)
  • target_basis (list[str]) – Target basis names to unroll to, e.g. [‘u3’, ‘cx’].

Methods

__init__(equivalence_library, target_basis)Initialize a BasisTranslator instance.
name()Return the name of the pass.
run(dag)Translate an input DAGCircuit to the target basis.

Attributes

is_analysis_passCheck if the pass is an analysis pass.
is_transformation_passCheck if the pass is a transformation pass.

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).

name

name()

Return the name of the pass.

run

run(dag)

Translate an input DAGCircuit to the target basis.

Parameters

dag (DAGCircuit) – input dag

Raises

TranspilerError – if the target basis cannot be reached

Returns

translated circuit.

Return type

DAGCircuit

Was this page helpful?
Report a bug or request content on GitHub.