Skip to main content

Module gdn

Module gdn 

Source
Expand description

The Gated-DeltaNet row engine as Verilog: one value row of a memory through one token (crate::spatial::decode_engine::numerics::gdn_row), sixteen elements a cycle.

A row streams in as N/16 beats of sixteen f32 elements, the row’s value on its first beat. Each beat feeds sixteen lanes of two dots, element 16·beat + l into lane l in index order — the key’s dot and the query’s — and is kept. After the last beat the lanes fold by the pairwise tree, the coefficient beta·(v − decay·(row·k)) and the read-out (decay·(row·q) + coef·(k·q))·scale follow, and the kept row streams back out updated, sixteen elements a cycle, each decay·m + coef·k rounded to binary16 and back when the state is stored in f16; the read-out rides the last beat.

The state’s codec is super::fp32’s binary16 conversions.

logos_gdn_lazy_row is the row under a lazily flushed memory (crate::spatial::decode_engine::numerics::gdn_read, gdn_flush): the row streams in with its carried value and its logged values, its dot with the head’s folded query in sixteen lanes and the tree gives the read-out (row·y + carried)·scale; when the log is full every logged update is replayed over the held row in order — the row’s dot with the token’s key, the coefficient, the rank-one update, no rounding between — and the row streams back out stored once.

logos_gdn_read_p is the lazily flushed read-out for the user clock, on the pipelined units: rows stream in beat by beat, row-major, up to a beat a clock, and out comes each row’s (row·y + carried)·scale, the rows in their order. It gathers rows four at a time into one of two buffers and sends each group through its sixteen lanes beat-major — the four rows’ first beats, then their second — so the add’s latency of four clocks is exactly the time between a lane’s terms for one row, and each lane’s sum feeds back into its own add; a row’s lanes then fold through the pipelined tree. A group takes its query and scale with its first beat, so heads stream back to back.

logos_gdn_flush_p is the flush for the user clock: a head’s log written beat by beat, then its rows in fours, each with its logged values. For every logged token the group’s beats pass through the same sixteen lanes to the tree for each row’s dot with the token’s key, the coefficient beta·(v − decay·(row·k)) follows on the pipelined units, and a second pass writes decay·m + coef·k back over the held rows; after the last token the rows stream out, stored once.

logos_gdn_fold_p folds a head’s query back through its log for the user clock (gdn_fold): every logged token’s decay through the pipelined exponential first, then the tokens newest first — the key’s dot with the folded query a beat each four clocks, so each lane’s sum comes back to its add as the next term enters, the tree, the gate’s product, then a beat a clock the values collected and the query decayed past the token.

Constants§

FOLD_M_READ_LATENCY
Clocks the head lanes’ fold (logos_gdn_fold_m) takes from a read-back’s address (rd_bank, rd_slot, rd_beat) to its words: the address registered beside the banks, then read.
LANE_CREDIT
The lines the recurrence’s coordinator and each head lane ask ahead of those they have taken (OUTSTANDING) unless a build gives more (super::engine::Streaming::with_recurrence_credit): behind a memory that answers latency clocks after an ask, a credit of c lines reads at most c / latency lines a clock. Each line queue is the power of two past the credit, 64 lines at least.
LANE_CREDIT_MAX
The most lines LANE_CREDIT may be raised to: a channel’s read FIFO holds 512 lines, and the channel multiplexer takes 30 runs a channel.

Functions§

delta_normed_lanes
lanes_verilog’s or lanes_trailing_verilog’s head lanes with each lane’s read-outs gated and normed where they are made, as a recurrence job that carries a crate::spatial::decode_engine::machine::DeltaNorm asks (Streaming::with_delta_norm): the job’s norm, its epsilon, the gate’s slot (each row’s beat of it, from the rows module, z_beat) and the norm’s weight’s first line (w_line) come in beside the job’s other fields. The lanes fetch the weight’s hd / 16 lines on the coordinator’s port at the job’s start, before its first row, and give every lane each as it comes. A lane’s loader reads each head’s gate beats after its query’s into the gate’s slot of the head (logos_gdn_gate_p, heads taking its NZ slots in turn), loading a batch only while the heads loaded and not yet gated leave the batch room; its read-outs go through the gate, which writes the store; a row is done only once the gate has written its every head. A job without a norm runs as the lanes run it.
delta_normed_rows
rows_verilog giving each row’s beat of one more vector, the gate of a recurrence job’s norm (z_slot, z_beat), for delta_normed_lanes.
flush_m_verilog
logos_gdn_flush_m, a trailing flush’s shares of several heads at once in two banks, emitted beside gdn_stream_verilog’s units, which it is built from.
gate_verilog
logos_gdn_gate_p, a head lane’s read-outs gated and normed head by head as the machine’s gated norm makes them (crate::spatial::decode_engine::machine::DeltaNorm): each head’s sum of squares in sixteen lanes as it comes in, its r through the tree, the product with recip(HD), the sum with epsilon and the reciprocal square root, then each element’s ((o·r)·w)·silu(z) a clock at a time, on the pipelined units.
gdn_stream_verilog
The streaming units for the user clock with the f32 units and the pipelined exponential they are built from: logos_gdn_read_p, a lazily flushed head’s read-out a beat a clock; logos_gdn_flush_p, its rows’ flush; logos_gdn_fold_p, its query folded back through its log.
gdn_verilog
The row engine with the f32 units and the codec it is built from.
lanes_trailing_verilog
lanes_verilog under a trailing flush of window tokens a window: the coordinator keeps the log as a ring of two windows and hands the lanes the share of rows each row replays; lane k is logos_gdn_lane_t, its window’s flush logos_gdn_flush_m; each copy of the log holds two windows. The lanes’ TMAX is the log’s two windows.
lanes_verilog
The recurrence on head lanes (logos_gdn_lanes): a coordinator (the side’s MODE 1) that counts, appends and reads the log once into each lane’s copy of it, and L head lanes (logos_gdn_lane), lane k taking value heads k, k + L, … a batch at a time through the fold of several heads at once and its own memory port; emitted beside gdn_stream_verilog’s units, the side and the fold among them.
rows_verilog
logos_gdn_rows, a recurrence job’s token rows given on one after another as the descriptors logos_gdn_lanes takes (and the side, a row at a time): each row’s region from a copy of the rows table, each vector’s store beat from a copy of the slots table, the copies written as the host writes the tables.