qbraid.passes.qasm.rebase
- rebase(qasm, gateset, require_predicates=True, gate_mappings=None, case_sensitive=False)[source]
Rebases an OpenQASM 3 program according to a given basis gate set.
- Parameters:
qasm (str) – The original OpenQASM 3 program as a string.
gateset (set[str]) – The target basis gates to decompose the program to.
require_predicates (bool) – If True, raises an error if the program fails to meet compilation predicates. If False, returns the original program on failure. Defaults to True.
gate_mappings (dict[str, str]) – A dictionary mapping gate names to new gate names.
case_sensitive (bool) – If True, the gate mappings are case-sensitive. Defaults to False.
- Returns:
The decomposed OpenQASM 3 program.
- Return type:
str
- Raises:
ValueError – If no basis gates are provided or if the basis gate set identifier is invalid
TypeError – If the basis gate set is not a set of strings or a string identifier
QasmDecompositionError – If an error occurrs during the decomposition process
CompilationError – If the program cannot be rebased to the provided basis gate set