Skip to main content

Module lane

Module lane 

Source
Expand description

The block-scale lane: a weight block’s integer sums as the array and the activation side deliver them, turned into the block’s f32 value and added into its row, exactly as super::numerics::dot does under ActScaling::PerBlock.

The array never sees a signed code. A weight code q (a decoder’s unsigned code, one or two 4-bit digits) meets an activation word in excess form: a one-word code a as a + 128, a two-word code’s signed high byte as hi + 128 and its unsigned low byte as itself. Per 16-element unit the array delivers P′ = Σ q·a′ for each word, the weight image carries Q = Σ q, and the activation side carries S′ = Σ a′. The unit’s sums against the signed codes follow exactly:

Σ (q − z)·a = P′ − 128·Q − z·S′ + 128·16·z and Σ a = S′ − 128·16 for an excess word, P′ − z·S′ and S′ for the low byte, the high word weighted by 256;

the coefficient sum is Σ_u c_u·Σ(q − z)·a and the offset sum Σ_u n_u·Σ a. The lane multiplies them by the block’s scales times the activation scale, sums the two terms exactly, rounds once and adds into the row.

Structs§

LaneBlock
One weight block as a lane reads it.
UnitSums
What the array and the activation side hand a lane for one unit of one word.
WordSums
One word’s unit sums: whether the word crossed in excess form, and its weight in the code (1, or 256 for a two-word code’s high byte).

Constants§

SUB_BLOCK
Elements a per-32 activation scale covers: a sub-block of the lane.

Functions§

block_sums
The block’s two exact sums: Σ coef·a and Σ offs·a.
deliver
What the array, the weight image and the activation side deliver a lane for block b of a row: the row’s decoded units units (the block’s own), its block scales a, b_scale, and the block’s activations of act in words.
deliver32
What the array, the weight image and the activation side deliver the per-32 lane for the 32-element sub-block s of a row’s weight block b: the block’s decoded units units (the sub-block’s two among them), the block’s scales, and the sub-block’s activations of act, scaled per 32 elements, in words.
group
A group of the row — super::numerics::GROUP elements, its sub-blocks subs — rounded once and added into acc: every sub-block’s two exact sums times its block’s scales and its own activation scale, the group’s terms summed exactly, as super::numerics::dot does under ActScaling::Sub32.
lane
The block’s value rounded once and added into acc.