def seq_att

bend-ml-llama@0.2.1.0 · main.bend:818

import bend-ml-llama@0.2.1.0/main.bend as BendMlLlama
import Base

818# some groups one after another, in order
819def seq_att(ws: List<&1, GW>, +hd: Nat, +t: Nat, +scale: F32, aks: List<&1, Array<F32>>, avs: List<&1, Array<F32>>, +acc: List<&2, F32>) -> AT:
820  match ws:
821    case Con{w, wt}:
822      match w:
823        case GW{g, k, v}:
824          HO.then(AT, group_att(g, hd, t, scale, k, v, Nil{}), k2 => v2 => +o =>
825            # bend-lint: disable-next bend-lint-rules/performance/append_in_loop -- the loop runs over the key/value heads of a layer, not the context not-expected-because: measured 2026-10-17 with a 1,190-token prompt: no change (NOTES)
826            seq_att(wt, hd, t, scale, k2 <> aks, v2 <> avs, List.append(&2, F32, acc, o)))
827    case Nil{}:
828      AT{List.reverse(&1, Array<F32>, aks), List.reverse(&1, Array<F32>, avs), acc}

Uses (10)

Used by (2)