qbraid_qir.qasm3.qasm3_to_qir

qasm3_to_qir(program, name=None, external_gates=None, profile=Profile.BASE, **kwargs)[source]

Converts an OpenQASM 3 program to a PyQIR module.

Parameters:
  • program (openqasm3.ast.Program or str) – The OpenQASM 3 program to convert.

  • name (str, optional) – Identifier for created QIR module. Auto-generated if not provided.

  • external_gates (list[str], optional) – A list of custom gate names that are not natively recognized by pyqasm but should be treated as valid during program unrolling.

  • profile (Profile or str) – The specific QIR profile to use for the conversion. Can be Profile.BASE, Profile.ADAPTIVE, or equivalent strings. Defaults to Profile.BASE.

Keyword Arguments:
  • initialize_runtime (bool) – Whether to perform quantum runtime environment initialization, defaults to True.

  • record_output (bool) – Whether to record output calls for registers, defaults to True.

  • emit_barrier_calls (bool) – Whether to emit barrier calls, defaults to True.

Return type:

Module

Returns:

The QIR pyqir.Module representation of the input OpenQASM 3 program.

Raises:
  • TypeError – If the input is not a valid OpenQASM 3 program.

  • Qasm3ConversionError – If the conversion fails.

  • NotImplementedError – If string doesn’t match any valid profile