qat.experimental.dialect.pulse.utils module

Structural utilities for the Pulse dialect.

extract_frequency_hz(op)

Extract a constant frame frequency in Hertz from pulse.create_frame.

Parameters:

op (CreateFrameOp) – The create-frame operation to extract from.

Return type:

float

Returns:

Frequency in Hertz as a Python float.

Raises:

PassFailedException – If the frequency operand is not a constant or its attribute is not a FrequencyAttr.

extract_phase_radians(op)

Extract a constant phase in radians from a phase-manipulation operation.

Parameters:

op (PhaseSetOp | PhaseShiftOp) – The phase operation to extract from.

Return type:

float

Returns:

Phase angle in radians as a Python float.

Raises:

PassFailedException – If the phase operand is not a constant or its attribute is not a PhaseAttr.

extract_time_seconds(op)

Extract a constant wait duration in seconds from pulse.wait.

Parameters:

op (WaitOp) – The wait operation to extract from.

Return type:

float

Returns:

Duration in seconds as a Python float.

Raises:

PassFailedException – If the duration operand is not a constant or its attribute is not a TimeAttr.

pulse_entry_block(module)

Return the block that carries the Pulse instruction stream.

Current repository producers use three concrete module shapes:

  • Frontend importers build a single func.func @main and place Pulse ops in its body block.

  • The PuRR importer builds a pulse.kernel containing the executable Pulse stream and a func.func @main containing results processing.

  • Some transforms and unit tests build a flat module with Pulse ops at top-level.

TODO(COMPILER-1380): remove this multi-shape logic once the canonical module shape is settled.

Parameters:

module (ModuleOp) – The Pulse module to inspect.

Return type:

Block

Returns:

The entry block containing the Pulse instruction sequence.

Raises:

PassFailedException – If the module contains multiple kernels, multiple functions without a kernel, or mixes a function with other non-kernel operations.

require_constant_operand(op_name, operand_name, operand)

Return the defining pulse.constant op for an SSA operand.

Parameters:
  • op_name (str) – Qualified name of the enclosing operation, used in error messages.

  • operand_name (str) – Semantic label of the operand, used in error messages.

  • operand (SSAValue) – The SSA value whose defining operation must be a ConstantOp.

Return type:

ConstantOp

Returns:

The ConstantOp defining the operand.

Raises:

PassFailedException – If the operand is not defined by a ConstantOp.