qat.experimental.dialect.results.ir.ops module
Models the operations in the results dialect, which are used to store and manipulate collections of results.
- class AddRecordOp(collection, record)
Bases:
AddRecordOp,IRDLOperation,Operation,_IRNode,ABC,objectAdds a results record to a results collection.
The operation takes a results collection and a results record as operands, and produces a new results collection that includes the added record.
- Variables:
collection – The SSA value representing the existing results collection.
record – The SSA value representing the results record to be added.
result – The resulting collection type, which is a ResultsCollectionType.
Initializes the AddRecordOp with the given collection and record.
- Parameters:
collection¶ (
Union[SSAValue[ResultsCollectionType],Operation]) – The SSA value representing the existing results collection.record¶ (
Union[SSAValue[RecordType],Operation]) – The SSA value representing the results record to be added.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- collection
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.add_record'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- record
Access a non-variadic construct which appears before any variadic arguments.
- result
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 CreateRecordOp(keys, values)
Bases:
CreateRecordOp,IRDLOperation,Operation,_IRNode,ABC,objectCreates a results record, which can be added to a results collection.
The operation contains a sequence of keys and values, which are used to construct a results record. The keys must be unique, and each key must have a corresponding value.
Since a record takes dictionary semantics, the keys and values are variable-length.
- Variables:
keys – An array of string attributes representing the keys for the record.
values – A sequence of SSA values representing the values for the record.
result – The resulting record type, which is a RecordType.
Initializes the CreateRecordOp with the given keys and values.
- Parameters:
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
-
keys:
ArrayAttr[StringAttr] Accessor for an operation property.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.create_record'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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.
- values
Access a variadic construct in the case where it is the only variadic.
- verify_()
Verifies that the number of keys and values match.
- class CreateResultsArrayOp(values)
Bases:
CreateResultsArrayOp,IRDLOperation,Operation,_IRNode,ABC,objectCreates a results array, which can be added to a results collection.
The operation contains a sequence of values, which are used to construct a results array. The values can be of any type.
- Variables:
values – A sequence of SSA values representing the values for the array.
result – The resulting array type, which is a ResultsArrayType.
Initializes the CreateResultsArrayOp with the given values.
- Parameters:
values¶ (
Sequence[SSAValue]) – A sequence of SSA values representing the values for the array.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.create_array'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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.
- values
Access a variadic construct in the case where it is the only variadic.
- verify_()
- class CreateResultsCollectionOp
Bases:
CreateResultsCollectionOp,IRDLOperation,Operation,_IRNode,ABC,objectCreates a results collection, which can be added to and filtered with given operations.
The operation creates an empty results collection that can be populated by later operations such as
AddRecordOp.- Variables:
result – The resulting empty collection, which is a ResultsCollectionType.
Initializes the CreateResultsCollectionOp with no values, as the collection is empty upon creation.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.create_collection'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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 ExtractOp(record, key, result_type)
Bases:
ExtractOp,IRDLOperation,Operation,_IRNode,ABC,objectExtracts an entry from a record from a string key.
As part of building the operation, the type of the extracted object must be specified.
Initializes the ExtractOp with the given record, key, and result type.
- Parameters:
record¶ (
Union[SSAValue[RecordType],Operation]) – The SSA value representing the existing results record.key¶ (
str) – A string representing the key to extract from the record.result_type¶ (
Attribute) – The type of the extracted value, for example a built-in scalar type, RecordType, or ResultsArrayType.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- key
Accessor for an operation property.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.extract'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- record
Access a non-variadic construct which appears before any variadic arguments.
- result
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 GroupEntriesOp(collection, keys, group_key)
Bases:
GroupEntriesOp,IRDLOperation,Operation,_IRNode,ABC,objectGroups entries in a record into a single entry, producing an array of those entries, ordered by the given keys, with the array stored with a provided key in the record.
This operation is roughly equivalent to the Assign instruction in legacy IR. This operation has a lowering path which could make use of
ExtractOpto extract the values from the record, and then a make a new record with the grouped entries. But currently, this operation is more useful to the current runtime.Note
This operation exists to support legacy runtime implementations of post-processing. Going forward, it is highly encouraged to assemble records in the structure that is desired to promote proper dataflow semantics.
Warning
This operation is likely to be flagged for deprecation in the future.
Initializes the GroupEntriesOp with the given collection, keys, and group key.
- Parameters:
collection¶ (
Union[SSAValue[RecordType],Operation]) – The SSA value representing the existing results record.keys¶ (
Sequence[str]) – A list of strings representing the keys to group in the new entry.group_key¶ (
str) – A string representing the key for the new grouped entry.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- collection
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
-
group_key:
StringAttr Accessor for an operation property.
-
keys:
ArrayAttr[StringAttr] Accessor for an operation property.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.group_entries'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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 MapOp(value, body)
Bases:
MapOp,IRDLOperation,Operation,_IRNode,ABC,objectMaps a transformation over a record to a collection of records, producing a new collection of records.
The operation contains a single region, which contains the operations that transform a record into a new record. The region has a block argument of type
RecordType, which represents the input record, and must yield a value of typeRecordType. The operation takes aResultsCollectionTypeoperand, which represents the collection of records to be transformed, and produces a newResultsCollectionTyperesult. The implication is that the transformation is applied to each record in the collection.The operation is modelled as pure to not allow for any side effects to be introduced within the region, and is enforced to be isolated from above to ensure that the region does not have access to any values outside of the region, which could introduce side effects.
This is intended to allow for a granular post-processing chain to be implemented that acts locally to a record. It intentionally does not specify any details of how this is implemented, e.g., in parallel or sequentially, apply every operation to each record before moving onto the next or going operation-by-operation (on every record). Those details are left to the runtime implementation, or lowering if relevant.
Within this block, you might expect to see operations such as
ExtractOpto extract values from the record, and then post-processing chains (such as those defined in the pulse dialect) to transform the values, and then aCreateRecordOpto create a new record. You might also expect to see operations such asGroupEntriesOpto group entries in the record, or aReduceOpto filter out entries.- Variables:
value – The SSA value representing the existing results collection.
body – The region containing the operations that transform a record into a new record.
result – The resulting collection type, which is a ResultsCollectionType.
Initializes the MapOp with the given collection and body.
- Parameters:
value¶ (
Union[SSAValue[ResultsCollectionType],Operation]) – The SSA value representing the existing results collection.body¶ (
Block|Region|Sequence[Block]) – The region or block(s) containing the operations that transform a record into a new record.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- body
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.map'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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.
- value
Access a non-variadic construct which appears before any variadic arguments.
- verify_()
Verifies that the region begins with a block that has a single argument of type RecordType, and that the region yields a value of type RecordType.
- class PostSelectOp(collection, *predicates)
Bases:
PostSelectOp,IRDLOperation,Operation,_IRNode,ABC,objectFilters a results collection based on a given predicate, producing a new collection that only includes records satisfying the predicate.
The operation takes a results collection operand and a predicates property, and produces a new results collection that includes only the records that satisfy all configured predicates.
This is used to filter a results collection to records that satisfy the predicate. This is modelled around legacy runtime implementations of post-selection, which post-selects on an entire collection of records, and filters them down. Lowering paths could be implemented to allow for an on-the-fly implementation of post-selection making use of classical control flow, given hardware compatibility.
- Variables:
collection – The operand representing the existing results collection.
predicates – The predicate attributes used to filter records in the collection.
result – The resulting collection type, which is a ResultsCollectionType.
Initializes the PostSelectOp with the given collection and predicates.
- Parameters:
collection¶ (
Union[SSAValue[ResultsCollectionType],Operation]) – The SSA value representing the existing results collection.predicates¶ (
PostSelectPredicateAttr) – The array of predicate attributes to filter records.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- collection
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.post_select'
The operation name. Should be a static member of the class
-
predicates:
ArrayAttr[PostSelectPredicateAttr] Accessor for an operation property.
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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 ReduceOp(collection, keys)
Bases:
ReduceOp,IRDLOperation,Operation,_IRNode,ABC,objectReduces a record, down to a subset of the entries in the record, producing a new record or collection of records.
We often want to gather a number of measurements to use in post-processing for use cases such as post-selection, and more general error mitigation methods. But not each of these measurements are the measurements that are requested in the original circuit. After the post-processing has completed and we have no need for these measurements, we can reduce records down to only the entries we would like to return.
This is a high-level operation that is roughly equivalent to the Return instruction in legacy IR. This has a lowering path to extract the entries from the record, and then create a new record with only the entries that are requested. But currently, this operation is more useful to the current runtime.
Note
This operation exists to support legacy runtime implementations of post-processing. Going forward, it is highly encouraged to assemble records in the structure that is desired to promote proper dataflow semantics.
Warning
This operation is likely to be flagged for deprecation in the future.
Initializes the ReduceOp with the given collection and keys.
- Parameters:
collection¶ (
Union[SSAValue[RecordType],Operation]) – The SSA value representing the existing results record.keys¶ (
Sequence[str]) – A list of strings representing the keys to retain in the reduced records.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- collection
Access a non-variadic construct which appears before any variadic arguments.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
-
keys:
ArrayAttr[StringAttr] Accessor for an operation property.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.reduce'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- result
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 YieldOp(record)
Bases:
YieldOp,IRDLOperation,Operation,_IRNode,ABC,objectYields a record from a region, which can be used to produce a new collection of records.
This operation is used to yield a record from a region, which can be used to produce a new collection of records. The yielded record must be of type RecordType.
- Variables:
record – The SSA value representing the record to be yielded.
Initializes the YieldOp with the given record.
- Parameters:
record¶ (
Union[SSAValue[RecordType],Operation]) – The SSA value representing the record to be yielded.
- attributes: dict[str, Attribute]
The attributes attached to the operation.
- classmethod get_irdl_definition()
Get the IRDL operation definition.
- location: LocationAttr
The source location attached to this operation.
- name: ClassVar[str] = 'results.yield'
The operation name. Should be a static member of the class
- properties: dict[str, Attribute]
The properties attached to the operation. Properties are inherent to the definition of an operation’s semantics, and thus cannot be discarded by transformations.
- record
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_()