LAWS.both_sum: law of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/LAWS.bend as LAWS Lines 61-74 of bendtorch@1.3.0.0/LAWS.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/LAWS.bend&start_line=61&end_line=74 import Base import bendtorch@1.3.0.0/main.bend as T import bendtorch@1.3.0.0/spec.bend as Spec # LAW (both_sum): T.Both's own code, running two linear layers side by side on the two inputs of a pair, gives a backward # pass that is the adjoint of its forward pass: dy1·y1 + dy2·y2 == dx1·x1 + dx2·x2. Each layer gets its own input's # gradient and nothing crosses between the two sides. Attention applies RoPE to q and k this way (Both(RoPE, Both(RoPE, # Id))). law both_sum: for +w1: List<&2, List<&2, Nat>> for +w2: List<&2, List<&2, Nat>> for +x1: List<&2, Nat> for +x2: List<&2, Nat> for +dy1: List<&2, Nat> for +dy2: List<&2, Nat> for g1: List<&2, List<&2, Nat>> for g2: List<&2, List<&2, Nat>> {Spec.pdot(T.Two{dy1, dy2}, Spec.fy(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, T.Layer.fwd(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, Spec.BothL(), T.Two{w1, w2}, T.Two{x1, x2}))) == Spec.pdot(Spec.bdx(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Layer.bwd(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, Spec.BothL(), T.Two{w1, w2}, Spec.fsv(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, T.Layer.fwd(T.Two>, List<&2, List<&2, Nat>>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, T.Two, List<&2, Nat>>, Spec.BothL(), T.Two{w1, w2}, T.Two{x1, x2})), T.Two{dy1, dy2}, T.Two{g1, g2})), T.Two{x1, x2}) : Nat} Uses (17): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.cong https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.trans https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/LAWS.bend&name=adjoint https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Layer.bwd https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Layer.fwd https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Two https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=BothL https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=bdx https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=dotn https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=fsv https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=fy https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=mtv https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=mv https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/spec.bend&name=pdot