def group_att

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

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

788# the query heads of one group over its key/value head, in order; the arrays are threaded through
789def group_att(hs: List<&2, Head>, +hd: Nat, +t: Nat, +scale: F32, k: Array<F32>, v: Array<F32>, +acc: List<&2, F32>) -> HO:
790  match hs:
791    case Nil{}:
792      HO{k, v, acc}
793    case Con{h, rest}:
794      HO.then(HO, head_att(hd, t, scale, k, v, join(h)), k2 => v2 => +o =>
795        # bend-lint: disable-next bend-lint-rules/performance/append_in_loop -- the loop runs over one group of query heads (at most 15 of 64 numbers) not-expected-because: measured 2026-10-17 with a 1,190-token prompt: no change (NOTES)
796        group_att(rest, hd, t, scale, k2, v2, List.append(&2, F32, acc, o)))

Uses (10)

Used by (1)