gpuDeltaRule (Function)
Signature: gpuDeltaRule(state: GpuBuffer<float32>, queries: GpuBuffer<float32>, keys: GpuBuffer<float32>, values: GpuBuffer<float32>, beta: GpuBuffer<float32>, decay: GpuBuffer<float32>, heads: int, dim: int) -> Result<GpuBuffer<float32>, Error>
Description: One token of the recurrent gated delta rule [LLM-DELTA-RULE], fused into one library kernel: each value element decays its state column, recalls through the keys, writes the updated column and reads it out through the queries, in one fixed order on every backend. The result holds heads x dim x dim state cells, then heads x dim outputs, and feeds the next step as its state.
Parameters
- state (
GpuBuffer<float32>): A previous result, or zeros of its length - queries (
GpuBuffer<float32>): dim values per head - keys (
GpuBuffer<float32>): dim values per head - values (
GpuBuffer<float32>): dim values per head - beta (
GpuBuffer<float32>): One value per head - decay (
GpuBuffer<float32>): One value per head - heads (
int): The head count - dim (
int): The width of a head
Returns: Result<GpuBuffer<float32>, Error>
Example
fn showStep(previous, queries, keys, values, beta, decay) = match gpuDeltaRule(previous, queries, keys, values, beta, decay, 48, 128) {
Success { value } => print(gpuLength(value))
Error { message } => print(message)
}
showStep (previous, queries, keys, values, beta, decay) =
match gpuDeltaRule (previous, queries, keys, values, beta, decay, 48, 128)
Success value => print (gpuLength value)
Error message => print message