Skip to main content
IBM Quantum Platform
This page is from an old version of Qiskit SDK Go to the latest version

BasisTranslator

class BasisTranslator(*args, **kwargs)

GitHub

Bases: qiskit.transpiler.basepasses.TransformationPass

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’].

Methods

name

BasisTranslator.name()

Return the name of the pass.

run

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


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

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