qat.experimental.frontend.purr module
Expose PuRR-to-IR import as a QAT frontend.
This module provides a frontend that normalises legacy PuRR instruction builders with a sanitisation pass pipeline, then imports the result into pulse IR.
- class PurrFrontend(model=None, run_purr_pipeline=True)
Bases:
BaseFrontendImport PuRR builders into pulse-level IR after legacy sanitisation.
PuRR IR built using
QuantumInstructionBuildercan omit structure that legacy execution paths insert implicitly. This frontend reconstructs that structure before importing to the new IR stack. The sanitisation pipeline can add:the shots loop via a Repeat instruction, if not provided,
end-of-line resets on the qubits used,
a return instruction if not provided,
start-of-line phase accumulation resets.
This keeps the importer focused on translation while preserving legacy program behaviour expected by existing PuRR workloads.
- Parameters:
model¶ (
Optional[CanonicalSystemData]) – The model as aCanonicalSystemDatarepresentation. Optional, but required if post-selection is enabled. The frontend derives a post-selection view from this model and applies it to the mapped results.run_purr_pipeline¶ (
bool) – Can be used to specify if the pipeline should run before importing.
- check_and_return_source(src)
Validate that the source can be processed by this frontend.
- Parameters:
src¶ (
Any) – The input program.- Return type:
QuantumInstructionBuilder|bool- Returns:
The original source when valid, otherwise
False.
- emit(src, res_mgr=None, met_mgr=None, compiler_config=None, **kwargs)
Build a
ModuleOpfrom a PuRR instruction builder.- Parameters:
src¶ (
QuantumInstructionBuilder) – The legacy PuRR representation of quantum programs.res_mgr¶ (
Optional[ResultManager]) – Collection of analysis results with caching and aggregation capabilities, defaults to None.met_mgr¶ (
Optional[MetricsManager]) – Stores useful intermediary metrics that are generated during compilation, defaults to None.compiler_config¶ (
Optional[CompilerConfig]) – Compiler settings, defaults to None.
- Return type:
ModuleOp- Returns:
A compiler
ModuleOpthat holds the program in pulse-level representation.- Raises:
TypeError – If src is not a
QuantumInstructionBuilder.ValueError – If post-selection is enabled but no canonical model was provided at frontend construction.