qat.frontend.qir module
- class QIRFrontend(model, pipeline=None)
Bases:
BaseFrontend
,ABC
A frontend for handling QIR programs.
Handles the parsing of QIR programs, and optionally implements a pipeline for validation and transformation.
- Parameters:
model¶ (
QuantumHardwareModel
) – The hardware model can be required for the pipeline and is used in parsing.pipeline¶ (
Optional
[PassManager
]) – A pipeline for validation and optimising QASM, defaults to a predefined pipeline that optimizes the QASM file.
- static build_pass_pipeline()
Creates an empty pipeline for QIR compilation.
- Return type:
- Returns:
The pipeline as a pass manager.
- check_and_return_source(src)
Checks that the source program (or file path) can be interpreted as a QIR file by checking against the language.
- Parameters:
src¶ (
str
|bytes
) – The QIR program, or the file path to the program.- Return type:
bool
|str
- Returns:
If the program is determined to not be valid, False is returned. Otherwise, the program is returned (and loaded if required).
- emit(src, res_mgr=None, met_mgr=None, compiler_config=None)
Compiles the source QIR program into QAT’s intermediate representation.
- Parameters:
src¶ (
str
) – The source program, or path to the source program.res_mgr¶ (
Optional
[ResultManager
]) – The result manager to store results from passes within the pipeline, defaults to an emptyResultManager
.met_mgr¶ (
Optional
[MetricsManager
]) – The metrics manager to store metrics, such as the optimized QIR circuit, defaults to an emptyMetricsManager
.compiler_config¶ (
Optional
[CompilerConfig
]) – The compiler config is used in both the pipeline and for parsing.
- Raises:
ValueError – An error is thrown if the the program is not detected to be a QIR program.
- Return type:
- Returns:
The program as an
InstructionBuilder
.
- is_qir_path(src)
Determines if the string corresponds to a path, and has a .ll or .rb extension.
- Return type:
bool
- is_qir_str(src)
Determines if the string contains QIR semantics.
- Return type:
bool