# BasisTranslator¶

class BasisTranslator(*args, **kwargs)[source]

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 Return the name of the pass. run Translate an input DAGCircuit to the target basis.

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