# BasisTranslator¶

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

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

Attributes

 BasisTranslator.is_analysis_pass Check if the pass is an analysis pass. BasisTranslator.is_transformation_pass Check if the pass is a transformation pass.

Methods

 Return the name of the pass. Translate an input DAGCircuit to the target basis.