atomiq.point_schema

Point schema entries, tiers and the mapping of argument values to kernel types.

The point schema lists every attribute of a scan point together with its tier and kernel type. It is frozen once per run and drives the generated point class, the chunk-fetch RPC and the generated kernel code.

Classes

Tier

Classification of a point attribute by when its value can change.

PointSchemaEntry

One attribute of the frozen point schema.

Functions

kernel_type_of(value)

Return the kernel type for a host value.

to_wire(value, entry)

Cast a host value to the scalar that is sent to the kernel for a schema entry.

Module Contents

class atomiq.point_schema.Tier(*args, **kwds)[source]

Bases: enum.Enum

Classification of a point attribute by when its value can change.

CONSTANT attributes are fixed for the whole run. They are declared as kernel invariants, so the compiler can hoist their loads out of loops. They hold arguments that are neither scanned nor mutable, and the run id.

SCANNED attributes vary per point. They hold scan axes with more than one value and the step counter. The kernel writes them for every point from the columns of the fetched chunk.

CHUNK attributes belong to mutable arguments that are not an active scan axis. The value is read once per chunk. It is constant within a chunk and may differ between chunks.

COMPUTED attributes are set inside the kernel and never sent by the host. The point identifier is one.

CONSTANT = 'constant'
SCANNED = 'scanned'
CHUNK = 'chunk'
COMPUTED = 'computed'
class atomiq.point_schema.PointSchemaEntry[source]

One attribute of the frozen point schema.

Parameters:
  • name -- Attribute name, read as point.<name> in user code.

  • tier -- Tier of the attribute.

  • type -- Kernel type of the attribute, for example float or str.

  • options -- Allowed values of an enumeration. The wire value is the index into this tuple. None for all other entries.

name: str
tier: Tier
type: type
options: tuple[str, ...] | None = None
atomiq.point_schema.kernel_type_of(value)[source]

Return the kernel type for a host value.

The mapping is bool to bool, integers to numpy.int64, floats to float and strings to str. The bool check comes first because bool is a subclass of int.

Parameters:

value (object) -- Host value of an argument.

Returns:

The kernel type of the value.

Raises:

TypeError -- If the value has no kernel type.

Return type:

type

atomiq.point_schema.to_wire(value, entry)[source]

Cast a host value to the scalar that is sent to the kernel for a schema entry.

This only casts. Callers validate the value first, because the casts truncate silently: numpy.int64(2.7) is 2 and bool("False") is True. ARTIQ checks RPC return values strictly. A numpy.bool_ is rejected for a bool and an int is rejected for a float, so every value is cast to the exact type of its entry. Enumeration values are sent as a numpy.int32 index into the options of the entry.

Parameters:
  • value (object) -- Host value of the argument.

  • entry (PointSchemaEntry) -- Schema entry of the argument.

Returns:

The value as the kernel type of the entry, or the option index for an enumeration.

Raises:
  • ValueError -- If the entry has options and the value is not one of them.

  • OverflowError -- If an integer value does not fit into numpy.int64.

Return type:

object