lora_matmul

Contents

lora_matmul#

class braintrace.lora_matmul(x, B, A, *, alpha=1.0, bias=None)[source]#

ETP-aware LoRA (Low-Rank Adaptation) matrix multiplication.

Computes \(y = \alpha \cdot x \mathbin{@} B \mathbin{@} A \; (+ b)\).

Auto-dispatches batched/unbatched based on x.ndim.

Parameters:
  • x – Input array.

  • B – Low-rank matrix B, shape (in_features, rank).

  • A – Low-rank matrix A, shape (rank, out_features).

  • alpha – Scaling factor.

  • bias – Optional bias.

Returns:

Output array.