qbraid.passes.qasm.rebase

rebase(qasm, gateset, require_predicates=True)[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.

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