TorchLean API

NN.Proofs.Autograd.Tape.Ops.Attention.MaskedScaledDotProduct

Additive-Bias Scaled-Dot-Product Attention #

This file proves the differentiable fixed-score-bias form:

softmax(c · QKᵀ + bias) V.

The bias tensor is fixed data. This is useful for relative-position biases or other intentional finite score shifts. It is not the boolean causal-mask semantics: boolean attention masks in the spec/runtime path use hard masking, where blocked entries contribute zero softmax numerator.

@[reducible, inline]

Saved tensors for fixed-bias scaled-dot-product attention.

Instances For

    Scaled dot-product attention with a fixed additive score bias.

    The proof follows the unmasked graph with one extra affine identity node between scaling and softmax. Because the bias is fixed, its derivative is the identity on the scaled logits.

    Instances For

      Reverse-mode theorem for finite additive-mask scaled-dot-product attention.