Skip to main content

Module field

Module field 

Source
Expand description

Descriptor field reads for the Hurray C ABI (ADR-039, ADR-040).

hurray_descriptor_decode validates every layout and every optional section hurray-core supports, but the scalar accessors beside it stop at the fixed header. A C caller handed a CSR descriptor would learn layout_tag == 0x07 and nothing more — not nnz, not which buffer is row_ptr — and one handed a per-block-quantized tensor would learn nothing at all about the scheme. This module is what closes that gap.

§Five functions, not seventy

The layout payloads and the five optional sections hold about seventy fields between them. Rather than one accessor each, a field is named by a HurrayDescriptorField identifier and read through one of five typed functions:

FunctionReads
hurray_descriptor_field_u64every unsigned or boolean scalar
hurray_descriptor_field_i64signed scalars (zero_point)
hurray_descriptor_field_f64real scalars (scale, the statistics)
hurray_descriptor_field_u64_arraytile_shape, morton_bits, mode_order, parent_shape, shard_offset
hurray_descriptor_field_i64_arraystrides, outer_strides, inner_strides

A new layout or section adds identifier constants, not symbols — which is how the wire format itself evolves (ADR-019), applied to the ABI. The trade is that a C compiler cannot check a field against the sub-object in hand; a mismatch is HURRAY_ERR_FIELD_NOT_APPLICABLE at runtime instead.

§Reading one

Scalars are a single call. Arrays use the capacity/length in-out pattern hurray_descriptor_shape established: pass the capacity in *out_len, read the true length back out, and retry after HURRAY_ERR_BUFFER_TOO_SMALL.

Constants§

HURRAY_COMPOSITE_MEMBER_FIELD_ROLE
This tensor’s role within its enclosing composite: correction 0x00, base 0x01.
HURRAY_EXT_TYPE_FIELD_BIT_WIDTH
Width of one element in bits.
HURRAY_EXT_TYPE_FIELD_EXPONENT_BIAS
Exponent bias; 0 for integer types.
HURRAY_EXT_TYPE_FIELD_EXPONENT_BITS
Number of exponent bits; 0 for integer types.
HURRAY_EXT_TYPE_FIELD_HAS_INF
Whether the type encodes infinity. 0 or 1.
HURRAY_EXT_TYPE_FIELD_HAS_NAN
Whether the type encodes NaN. 0 or 1.
HURRAY_EXT_TYPE_FIELD_IS_FLOAT
Whether the type is floating-point. 0 or 1.
HURRAY_EXT_TYPE_FIELD_IS_SIGNED
Whether the type is signed. 0 or 1.
HURRAY_EXT_TYPE_FIELD_MANTISSA_BITS
Number of mantissa bits.
HURRAY_EXT_TYPE_FIELD_PACKING_FACTOR
Elements packed per storage byte; 1 when unpacked.
HURRAY_EXT_TYPE_FIELD_SIGN_BITS
Number of sign bits.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_INDEX_TYPE
Block-paged (0x0A) block-table element width: u32 0x00, u64 0x01.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_KV_ROLE
Block-paged (0x0A) KV role wire byte: key 0x00, value 0x01, fused 0x02.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_LAYER_INDEX
Block-paged (0x0A) transformer layer index. Optional.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_NUM_PAGES
Block-paged (0x0A) total pages in the shared pool.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_NUM_SEQS
Block-paged (0x0A) number of sequences sharing the pool.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_PAGED_AXIS
Block-paged (0x0A) index of the paged axis.
HURRAY_LAYOUT_FIELD_BLOCK_PAGED_PAGE_SIZE
Block-paged (0x0A) elements per page along the paged axis.
HURRAY_LAYOUT_FIELD_COMPOSITE_COMBINE_OP
Composite (0x0B) combine-op wire byte; 0x00 unless the rule is overlay.
HURRAY_LAYOUT_FIELD_COMPOSITE_MEMBER_COUNT
Composite (0x0B) number of member descriptors following the head.
HURRAY_LAYOUT_FIELD_COMPOSITE_RULE
Composite (0x0B) composition rule wire byte.
HURRAY_LAYOUT_FIELD_COO_IS_SORTED
COO (0x06) whether coordinates are in lexicographic order. 0 or 1.
HURRAY_LAYOUT_FIELD_COO_NNZ
COO (0x06) stored non-zero count.
HURRAY_LAYOUT_FIELD_CSC_NNZ
CSC (0x08) stored non-zero count.
HURRAY_LAYOUT_FIELD_CSF_MODE_ORDER
CSF (0x09) mode storage order. Unsigned array.
HURRAY_LAYOUT_FIELD_CSF_NNZ
CSF (0x09) stored non-zero count.
HURRAY_LAYOUT_FIELD_CSR_NNZ
CSR (0x07) stored non-zero count.
HURRAY_LAYOUT_FIELD_HILBERT_ORDER
Hilbert (0x40) curve order; every dimension equals 2^order.
HURRAY_LAYOUT_FIELD_HILBERT_RANK
Hilbert (0x40) curve rank.
HURRAY_LAYOUT_FIELD_MORTON_BITS
Morton (0x05) per-dimension interleave bit counts. Unsigned array.
HURRAY_LAYOUT_FIELD_STRIDED_STRIDES
Strided (0x03) per-dimension strides, in logical elements. Signed array.
HURRAY_LAYOUT_FIELD_TILED_DEPTH
Tiled (0x04) number of nesting levels from level downward.
HURRAY_LAYOUT_FIELD_TILED_INNER_LAYOUT
Tiled (0x04) layout tag governing the order of elements within a tile.
HURRAY_LAYOUT_FIELD_TILED_INNER_STRIDES
Tiled (0x04) explicit strides within a tile. Signed array, optional.
HURRAY_LAYOUT_FIELD_TILED_OUTER_LAYOUT
Tiled (0x04) layout tag governing the order of tiles.
HURRAY_LAYOUT_FIELD_TILED_OUTER_STRIDES
Tiled (0x04) explicit strides between tiles. Signed array, optional.
HURRAY_LAYOUT_FIELD_TILED_TILE_SHAPE
Tiled (0x04) tile extent per dimension. Unsigned array.
HURRAY_QUANT_FIELD_MXFP_AXIS
MXFP (0x05) quantization axis.
HURRAY_QUANT_FIELD_MXFP_BLOCK_SIZE
MXFP (0x05) elements per quantization block.
HURRAY_QUANT_FIELD_MXFP_SCALE_BUFFER
MXFP (0x05) buffer index holding the shared-exponent vector.
HURRAY_QUANT_FIELD_NF4_AXIS
NF4 (0x04) quantization axis.
HURRAY_QUANT_FIELD_NF4_BLOCK_SIZE
NF4 (0x04) elements per quantization block.
HURRAY_QUANT_FIELD_NF4_SCALE_BUFFER
NF4 (0x04) buffer index holding the scale vector.
HURRAY_QUANT_FIELD_PER_BLOCK_AXIS
Per-block affine (0x03) quantization axis.
HURRAY_QUANT_FIELD_PER_BLOCK_BLOCK_SIZE
Per-block affine (0x03) elements per quantization block.
HURRAY_QUANT_FIELD_PER_BLOCK_SCALE_BUFFER
Per-block affine (0x03) buffer index holding the scale vector.
HURRAY_QUANT_FIELD_PER_BLOCK_SCALE_TYPE
Per-block affine (0x03) element type tag of the scale vector.
HURRAY_QUANT_FIELD_PER_BLOCK_ZERO_POINT_BUFFER
Per-block affine (0x03) buffer index holding the zero-point vector. Absent for a symmetric scheme.
HURRAY_QUANT_FIELD_PER_CHANNEL_AXIS
Per-channel affine (0x02) quantization axis.
HURRAY_QUANT_FIELD_PER_CHANNEL_SCALE_BUFFER
Per-channel affine (0x02) buffer index holding the scale vector.
HURRAY_QUANT_FIELD_PER_CHANNEL_SCALE_TYPE
Per-channel affine (0x02) element type tag of the scale vector.
HURRAY_QUANT_FIELD_PER_CHANNEL_ZERO_POINT_BUFFER
Per-channel affine (0x02) buffer index holding the zero-point vector. Absent for a symmetric scheme.
HURRAY_QUANT_FIELD_PER_TENSOR_SCALE
Per-tensor affine (0x01) scale. Real scalar, float32 on the wire.
HURRAY_QUANT_FIELD_PER_TENSOR_ZERO_POINT
Per-tensor affine (0x01) zero point. Signed scalar, int32 on the wire.
HURRAY_QUANT_FIELD_SCHEME_TAG
Quantization scheme tag of the section this descriptor carries: per-tensor affine 0x01, per-channel affine 0x02, per-block affine 0x03, NF4 0x04, MXFP 0x05.
HURRAY_SHARD_FIELD_PARENT_SHAPE
Shape of the logical parent tensor. Unsigned array, length equal to the rank.
HURRAY_SHARD_FIELD_SHARD_OFFSET
This shard’s starting index within the parent. Unsigned array, length equal to the rank.
HURRAY_STATS_FIELD_COMPUTED_MASK
Raw computed_mask bitfield. Always present when the section is.
HURRAY_STATS_FIELD_HAS_INF
Whether any element is infinite. 0 or 1, guarded by NAN_INF_VALID (bit 5).
HURRAY_STATS_FIELD_HAS_NAN
Whether any element is NaN. 0 or 1, guarded by NAN_INF_VALID (bit 5).
HURRAY_STATS_FIELD_NM_M
M of N:M structured sparsity. Guarded by NM_SPARSITY_VALID (bit 4).
HURRAY_STATS_FIELD_NM_N
N of N:M structured sparsity. Guarded by NM_SPARSITY_VALID (bit 4).
HURRAY_STATS_FIELD_NNZ
Non-zero element count. Guarded by NNZ_VALID (bit 0).
HURRAY_STATS_FIELD_SPARSITY_RATIO
Fraction of elements that are zero. Real scalar, guarded by SPARSITY_VALID (bit 1).
HURRAY_STATS_FIELD_VALUE_ABS_MAX
Largest absolute stored value. Real scalar, guarded by VALUE_RANGE_VALID (bit 2).
HURRAY_STATS_FIELD_VALUE_MAX
Largest stored value. Real scalar, guarded by VALUE_RANGE_VALID (bit 2).
HURRAY_STATS_FIELD_VALUE_MEAN
Arithmetic mean. Real scalar, guarded by VALUE_STATS_VALID (bit 3).
HURRAY_STATS_FIELD_VALUE_MIN
Smallest stored value. Real scalar, guarded by VALUE_RANGE_VALID (bit 2).
HURRAY_STATS_FIELD_VALUE_STDDEV
Standard deviation. Real scalar, guarded by VALUE_STATS_VALID (bit 3).

Functions§

hurray_descriptor_field_f64⚠
Reads a real scalar field of the descriptor.
hurray_descriptor_field_i64⚠
Reads a signed scalar field of the descriptor.
hurray_descriptor_field_i64_array⚠
Reads a signed array field of the descriptor.
hurray_descriptor_field_u64⚠
Reads an unsigned or boolean scalar field of the descriptor.
hurray_descriptor_field_u64_array⚠
Reads an unsigned array field of the descriptor.

Type Aliases§

HurrayDescriptorField
Identifies one field of a tensor descriptor’s layout payload or of one of its optional sections.