qat.experimental.dialect.q1_scf package

The q1_scf dialect.

q1_scf is the structured control flow dialect for the QBlox Q1 sequence processor. It sits above q1_cf, the target-specific block CFG, and below the pulse level, and provides an if conditional and while/for loop containers with the condition and yield terminators. The dialect neither lowers control flow nor performs register allocation. It is the representation on which a subsequent register-allocation pass operates.

Structured control flow branches on register values alone. A measurement outcome reaches q1_scf only as a q1.reg dequeued through q1_linq; an outcome consumed through q1_trigger drives predicated execution without exposing its value and never reaches this dialect.

Reference: https://docs.qblox.com/en/main/products/qblox_instruments/q1/index.html

class BinaryPredicate(value)

Bases: StrEnum

Comparison applied between two operand values.

eq = 'eq'
ne = 'ne'
sge = 'sge'
sgt = 'sgt'
sle = 'sle'
slt = 'slt'
uge = 'uge'
ugt = 'ugt'
ule = 'ule'
ult = 'ult'
class BinaryPredicateAttr(data)

Bases: EnumAttribute[BinaryPredicate], SpacedOpaqueSyntaxAttribute

Attribute wrapper carrying a BinaryPredicate.

data: DataElement
enum_type

alias of BinaryPredicate

name: ClassVar[str] = 'q1_cf.binary_predicate'

The attribute name should be a static field in the attribute classes.

class ConditionOp(predicate, predicate_args, forward_args)

Bases: ConditionOp, IRDLOperation, Operation, _IRNode, ABC, object

Terminate the before region of a WhileOp.

The loop continues while predicate holds over its register operands, and the forward_args are threaded to the after region or, on exit, to the loop results.

q1_scf.condition slt %x : q1.reg, %n : q1.reg (%acc : q1.reg)
forward_args

Access a variadic construct when there is a “segment size” attribute.

classmethod get_irdl_definition()

Get the IRDL operation definition.

irdl_options = (AttrSizedOperandSegments(as_property=False),)
name: ClassVar[str] = 'q1_scf.condition'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

predicate

Accessor for an operation property.

predicate_args

Access a variadic construct when there is a “segment size” attribute.

print(printer)
Return type:

None

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class ForOp(iter_count, iter_args, body, iter_domain=None)

Bases: ForOp, IRDLOperation, RegisterAllocatableOperation, Operation, _IRNode, ABC, object

Counted loop whose induction value is the remaining count.

iter_count counts down to zero, mapping one-to-one onto the native Q1 decrement-and-branch loop and onto q1_cf.loop_branch. The body is a single block terminated by YieldOp, and its entry block arguments are the induction counter followed by the carried values. A ForOp is reducible to a WhileOp. The optional iter_domain records the linear iteration the counted loop realises.

q1_scf.for %n : q1.reg iter_args(%acc : q1.reg) { ... }
allocate_registers(allocator)

Entry point for structured register allocation over this loop.

This allocation is done under the following assumptions: :rtype: None

  • The iter_args that instantiate the loop-carried arguments are not consumed after initialising the loop. This is to prevent accidental reallocation due to the coalescing constraints between the iter_args and the block arguments.

  • The iter_count is not consumed after initialising the loop. This is to prevent accidental reallocation due to the coalescing constraints between the iter_count and the induction variable.

  • Relocations are applied to block arguments where required to allow for register allocation with the coalescing constraints.

Because of these assumptions, not every allocation is possible. It’s expected that legalisation via relocations happens prior to allocation. In particular, lowering from other dialects would enforce this through move operations on iter args, block arguments and the induction variable.

body

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

iter_args

Access a variadic construct in the case where it is the only variadic.

iter_count

Access a non-variadic construct which appears before any variadic arguments.

iter_domain

Accessor for an optional operation property.

name: ClassVar[str] = 'q1_scf.for'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

print(printer)
Return type:

None

res

Access a variadic construct in the case where it is the only variadic.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class IfOp(predicate, predicate_args, result_types, then_region, else_region=None)

Bases: IfOp, IRDLOperation, RegisterAllocatableOperation, Operation, _IRNode, ABC, object

Structured conditional for single-sequencer feedforward.

Evaluates predicate over its register operands, runs the then region or the optional else region, and returns their yielded values as its results. Both regions are terminated by YieldOp. Feedforward here denotes intra-sequencer conditional execution, distinct from a loop or a cross-sequencer message.

q1_scf.if nez %flag : q1.reg -> (q1.reg) { ... } else { ... }
allocate_registers(allocator)

Entry point for structured register allocation over this conditional.

Ensures the yield arguments of the then and else regions are allocated to the same registers as the results of the IfOp, and that the predicate operands are allocated to registers. Allocates each region separately, allowing use of shared registers between the two regions.

Return type:

None

else_region

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

name: ClassVar[str] = 'q1_scf.if'

The operation name. Should be a static member of the class

output

Access a variadic construct in the case where it is the only variadic.

classmethod parse(parser)
Return type:

Self

predicate

Accessor for an operation property.

predicate_args

Access a variadic construct in the case where it is the only variadic.

print(printer)
Return type:

None

then_region

Access a non-variadic construct which appears before any variadic arguments.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class IterDomainAttr(start, stop, step, count, parameter)

Bases: IterDomainAttr

Linear iteration domain of a ForOp.

The domain is the affine sequence start, start + step, ... truncated to count points, all measured in the unit implied by parameter. It records the physical meaning of a counted loop and does not alter its control-flow semantics.

Parameters:
  • start (float) – First value of the varied quantity.

  • stop (float) – Exclusive upper bound of the varied quantity.

  • step (float) – Increment between successive iterations; must be non-zero.

  • count (int) – Number of loop iterations, which must equal ceil((stop - start) / step).

  • parameter (IterParameter) – The varied quantity and, implicitly, its unit.

count: IntAttr = <xdsl.irdl.attributes._ParameterDef object>
classmethod get_irdl_definition()

Get the IRDL attribute definition.

name: ClassVar[str] = 'q1_scf.iter_domain'

The attribute name should be a static field in the attribute classes.

parameter: IterParameterAttr = <xdsl.irdl.attributes._ParameterDef object>
start: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
step: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
stop: FloatAttr = <xdsl.irdl.attributes._ParameterDef object>
verify()

Verify the domain is a well-formed linear iteration.

Raises:

VerifyException – If step is zero, if count is negative, or if count does not equal ceil((stop - start) / step).

Return type:

None

class IterParameter(value)

Bases: StrEnum

The quantity varied across iterations, which also fixes the domain unit.

duration = 'duration'
frequency = 'frequency'
gain = 'gain'
phase = 'phase'
class IterParameterAttr(data)

Bases: EnumAttribute[IterParameter], SpacedOpaqueSyntaxAttribute

Attribute wrapper carrying an IterParameter.

enum_type

alias of IterParameter

name: ClassVar[str] = 'q1_scf.iter_parameter'

The attribute name should be a static field in the attribute classes.

class UnaryPredicate(value)

Bases: StrEnum

Condition-code test applied to a single register value.

eqz = 'eqz'
gez = 'gez'
ltz = 'ltz'
nez = 'nez'
class UnaryPredicateAttr(data)

Bases: EnumAttribute[UnaryPredicate], SpacedOpaqueSyntaxAttribute

Attribute wrapper carrying a UnaryPredicate.

data: DataElement
enum_type

alias of UnaryPredicate

name: ClassVar[str] = 'q1_cf.unary_predicate'

The attribute name should be a static field in the attribute classes.

class WhileOp(init_args, result_types, before_region, after_region)

Bases: WhileOp, IRDLOperation, RegisterAllocatableOperation, Operation, _IRNode, ABC, object

General structured loop with a before/after split.

The before region computes and tests the loop condition and is terminated by ConditionOp. The after region is the loop body, terminated by YieldOp, whose yielded values feed back to the before block arguments. Any structured loop is expressible in this form.

q1_scf.while (%acc : q1.reg) -> (q1.reg) { ... } do { ... }
after_region

Access a non-variadic construct which appears before any variadic arguments.

allocate_registers(allocator)

Entry point for structured register allocation over this loop.

Return type:

None

before_region

Access a non-variadic construct which appears before any variadic arguments.

classmethod get_irdl_definition()

Get the IRDL operation definition.

init_args

Access a variadic construct in the case where it is the only variadic.

name: ClassVar[str] = 'q1_scf.while'

The operation name. Should be a static member of the class

classmethod parse(parser)
Return type:

Self

print(printer)
Return type:

None

res

Access a variadic construct in the case where it is the only variadic.

traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()
class YieldOp(*arguments)

Bases: YieldOp, IRDLOperation, Operation, _IRNode, ABC, object

Terminate a structured region, forwarding register values to its parent.

Terminates the body of a ForOp, the after region of a WhileOp, and each region of an IfOp.

q1_scf.yield %a, %b : q1.reg, q1.reg
arguments

Access a variadic construct in the case where it is the only variadic.

assembly_format: ClassVar[str | None] = 'attr-dict ($arguments^ `:` type($arguments))?'
classmethod get_irdl_definition()

Get the IRDL operation definition.

name: ClassVar[str] = 'q1_scf.yield'

The operation name. Should be a static member of the class

classmethod parse(parser: Parser) IRDLOperationInvT
Return type:

TypeVar(IRDLOperationInvT, bound= IRDLOperation)

print(printer: Printer)
traits: ClassVar[OpTraits] = <xdsl.ir.core.OpTraits object>

Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.

verify_()

Subpackages