Compiler#
Module: iqm.cpc.compiler.compiler
- class iqm.cpc.compiler.compiler.Compiler(*, dut_label, loading_rules, chip_topology, software_version_set_id, component_mapping, station_control_settings, controller_mapping=None, gate_definitions=None, observation_handler=None, circuit_stages=None, pulse_stages=None, final_stages=None, pp_stages=None, compiler_options=None, name='IQM Compiler')#
Bases:
objectCompile quantum circuits into jobs that can be submitted to a quantum computer.
- Parameters:
dut_label (str) – DUT label of the chip being used.
loading_rules (Sequence[RuleType]) – Observation loading rules.
chip_topology (ChipTopology) – Physical layout and connectivity of the quantum chip.
software_version_set_id (int) – An integer ID representing the software versions in the current python environment.
component_mapping (dict[str, str] | None) – Mapping of logical QPU component names to physical QPU component names.
Nonemeans the identity mapping.station_control_settings (SettingNode) – Settings representing the device and station controllers.
controller_mapping (dict[str, dict[str, str]] | None) – Dictionary that maps physical QPU component names to their device controller names. The dictionary is of the form:
{<component_name>: {<operation_name>: <controller name>}}, where operation is one of the following: “drive”, “readout”, “flux” (not all components have all operations supported).gate_definitions (dict[str, QuantumOp] | None) – Names of quantum operations mapped to their definitions, see
QuantumOp.observation_handler (ObservationHandlerBase | None) – Observation handler.
circuit_stages (list[CompilationStage] | None) – Compilation stages to use in processing gate-level (and above) circuits.
Nonemeans none. Note that meaningful circuit compilation requires at least some stages. These stages are sweepable in the compilation loop via their stage settings.pulse_stages (list[CompilationStage] | None) – Compilation stages to use in processing TimeBox-level (and below) circuits.
Nonemeans none. Note that meaningful circuit compilation requires at least some stages. These stages are sweepable in the compilation loop via their stage settings.final_stages (list[CompilationStage] | None) – Compilation stages to use in creating the final run request. These stages are not sweepable.
pp_stages (list[CompilationStage] | None) – Post-processing stages to use.
compiler_options (CompilerOptions | None) – General options to define the compiler behaviour.
name (str) – The name of this compiler.
Methods
Adds a new implementation for a quantum operation (gate).
Run all compiler stages.
Return initial compiler context dictionary.
Run
self.final_stages, i.e. finalize the payload to be sent for execution..Retrieves and modifies settings for Compiler.
Run
self.pp_stages.Run the circuit- and pulses-level stages on the given data.
Set the default implementation of a gate.
Set the default implementation for a gate for a specific loci.
Displays an interactive HTML representation of the compiler stages.
- get_settings(circuits=None, timeboxes=None, circuit_stages=None, pulse_stages=None, final_stages=None, qubits=None, couplers=None, computational_resonators=None)#
Retrieves and modifies settings for Compiler.
- Parameters:
circuits (Any | None) – Circuit-level input to be compiled.
timeboxes (Any | None) – TimeBox-level input to be compiled. Either
circuitsortimeboxesmust be provided.circuit_stages (list[CompilationStage] | None) – Circuit-level (and above) compilation stages. If not provided,
self.circuit_stageswill be used.pulse_stages (list[CompilationStage] | None) – TimeBox-level (and below) compilation stages. If not provided,
self.pulse_stageswill be used.final_stages (list[CompilationStage] | None) – Station-control job finalization stages. If not provided,
self.final_stageswill be used.qubits (list[str] | None) – Names of the qubits to get the settings for.
couplers (list[str] | None) – Names of the couplers to get the settings for.
computational_resonators (list[str] | None) – Names of the computational resonators to get the settings for..
- Returns:
The settings tree.
- Return type:
- compiler_context(components, settings, **kwargs)#
Return initial compiler context dictionary.
Used automatically by
compile().- Parameters:
components (ComponentGrouping | None)
settings (SettingNode)
- Return type:
- compile(circuits=None, timeboxes=None, components=None, settings=None, sweeps=None, context=None)#
Run all compiler stages.
Initial context will be derived using
compiler_context()unless a custom context dictionary is provided.- Parameters:
circuits (Any | None) – Circuit-level input to be compiled.
timeboxes (Any | None) – TimeBox-level input to be compiled. Either
circuitsortimeboxesmust be provided. If this argument is provided, the stages inself.circuit_stageswill not be run.components (list[str] | list[tuple[str, ...]] | list[list[tuple[str, ...]]] | None) – Apply the circuits on these active components. If logical component names are used,
self.component_mappingmust contain logic for mapping them into physical ones. IfcomponentsisNone, the active components used in the circuits can be automatically resolved in a compiler pass.settings (SettingNode | None) – The settings tree to use. If None, the default settings tree will be generated.
sweeps (list[tuple[Sweep, ...]] | None) – The sweeps to perform in the job. If None, the job will consist of one trivial sweep spot.
context (dict[str, Any] | None) – Custom initial compiler context dictionary. Contents are updated into the default context given by
compiler_context().
- Returns:
Compiled `data, final context.
- Return type:
- run_stages(data, context, stages=None, sweeps=None)#
Run the circuit- and pulses-level stages on the given data.
Circuit- and pulse-level stages can be swept as per the provided sweeps. The provided hard sweeps determine the dimensions of the final Playlist such that one segment (circuit) is generated per hard sweep spot.
- Parameters:
data (Any) – The data to compile.
context (dict[str, Any]) – Custom initial compiler context dictionary.
sweeps (list[tuple[Sweep, ...]] | None) – Sweeps to run on
data.stages (list[CompilationStage] | None) – compilation stages to be run on
data. If not provided,self.circuit stages + self.pulse_stageswill be used. Each stage may make modifications tocontextbefore it is passed to the next stage.sweeps – Sweeps to run on
data. Can contain both hard- and soft sweeps.
- Returns:
Processed data, final context.
- Return type:
- finalize(data, context, stages=None)#
Run
self.final_stages, i.e. finalize the payload to be sent for execution.The final stages are not sweepable but their settings can be changed.
- Parameters:
- Returns:
The finalized payload to be sent for execution and the compiler context.
- Return type:
- post_process(data, context, stages=None)#
Run
self.pp_stages.Post-processing stages are not sweepable and their settings cannot be changed, but one may still pass stateful effects via the context.
- Parameters:
- Returns:
Human-readable result data and the compiler context.
- Return type:
- set_default_implementation(gate_name, implementation_name)#
Set the default implementation of a gate.
- set_default_implementation_for_loci(gate_name, implementation_name, loci)#
Set the default implementation for a gate for a specific loci.
- add_implementation(op_name, impl_name, impl_class, *, set_as_default=False, overwrite=False, quantum_op=None)#
Adds a new implementation for a quantum operation (gate).
Refreshes the compiler after adding a new implementation.
- Parameters:
op_name (str) – The name of the quantum operation for which to register a new implementation.
impl_name (str) – The “human-readable” name with which the new implementation will be found e.g. in settings.
impl_class (type[GateImplementation]) – The class of the new implementation to be added.
set_as_default (bool) – Whether to set the new implementation as the default implementation for the operation.
overwrite (bool) – If True, replaces any existing implementation of the same name for the operation.
quantum_op (QuantumOp | None) – The quantum operation this gate represents. If a QuantumOp is given, it is used as is. If None is given and the same gate has been registered before, the previously registered properties are used. Existing operations cannot be replaced or modified.
- Return type:
None
Inheritance
