CUDA Tape Operations: Normalization and Row Softmax #
Normalization #
LayerNorm over the last dimension for (seqLen, embedDim) buffers.
The tape records one normalization operation and keeps TorchLean's usual VJP. A fused buffer primitive evaluates the forward formula and that VJP without materializing each reduction, broadcast, and pointwise intermediate as a separate device buffer.
epsilon is added to the variance before taking the square root. Backward reuses the normalized
input and inverse standard deviation saved by forward, so both passes use the caller's value.
Instances For
Batch normalization over every axis after the channel axis.
The spatial shape is folded to one contiguous dimension for the CUDA reduction. This is a view of the storage layout, not a rank-specific implementation.
Instances For
Softmax (last axis, row folding) #
We implement softmax along the last axis by folding all leading dimensions into one rows axis.
This covers:
- 2D softmax (
(rows, cols)), - 3D batched softmax (
(batch, rows, cols)) by foldingbatch*rowsintorows.
Record a last-axis softmax on the tape, returning the extended tape and the new node id.
Instances For
Stable log-softmax along the last axis, implemented directly on CUDA buffers.