Broadcasting Rules
Two tensors are broadcastable if, for each dimension from trailing to leading, the dimensions are equal or one of them is 1. A missing dimension is treated as 1.
Broadcasting is applied before elementwise operations. The TensorEngine validates broadcastability before executing any op.
Elementwise Operations
For elementwise add, sub, mul, div:Reductions
Matmul Shape Rules for Transformer Weights
For a linear layer with weight W and input x:Precision and Numerical Range
Numerical Stability Rules
- All elementwise accumulation uses fp32 intermediates.
- Norms are computed in fp32 regardless of input dtype.
- SLERP dot products use fp64 for precision.
- int4 and int8 weights are dequantized to fp32 before merge ops.
- Results are cast to the target dtype only at the final step.
Cross-Links
- Merge Math for shared notation and weight shapes.
- Tensor Operations for the TensorEngine operation catalog.
- SLERP Math for spherical interpolation formulas.
- TIES Math for trim and disjoint merge.
- DARE Math for sparsification and rescaling.