qat.experimental.conversion.pulse_to_q1.phase module

Phase rewrite strategies for the Pulse-to-Q1 conversion.

PhaseLegalisation canonicalises constant pulse.phase operands into the [0, 2π) range.

PhaseLowering consumes canonical constants and converts radians to degrees, then to NCO phase steps.

Q1 parameter instructions (set_ph, set_ph_delta, set_freq and set_awg_offs) take no time and do not latch themselves: the next upd_param, play or acquire applies them. Lowerings therefore emit parameter instructions without an upd_param, and every Pulse wait lowers to upd_param so pending changes apply at their Pulse time. A lowering that adds set_freq must follow the same rule.

Dynamic phase operands are unsupported: Q1 phase instructions only accept an immediate operand, so there is no numeric radians-to-steps runtime conversion for a dynamic value. Q1PulseValidationPass rejects a dynamic pulse.phase_set or pulse.phase_shift operand upstream of both stages.

class PhaseLegalisation

Bases: object

Callable strategy that canonicalises a pulse.phase_set or pulse.phase_shift operand to the [0, 2π) radian range and replaces the op with an equivalent Pulse op carrying the normalised constant.

The stage stays within the Pulse dialect. Constant operand finiteness is enforced upstream by Q1PulseValidationPass, which also rejects a dynamic phase operand before this stage runs.

class PhaseLowering

Bases: object

Callable strategy for the lowering stage.

Lowering is distinct from legalisation. Canonical Pulse constants map to immediate Q1 phase instructions.

Conversion from radians is lossy. Values are quantised into sequencer NCO phase-step space prior to emission.

The emitted set_ph or set_ph_delta is not followed by upd_param: the next timed instruction latches it, so the phase update takes no time, as in the Pulse schedule.