Skip to content

TensorLib v0.2.0

Choose a tag to compare

@nisbenz nisbenz released this 06 Sep 18:03
· 91 commits to main since this release

TensorLib 0.2.0 is a performance-focused release that substantially reduces
TinyLM forward and training costs while preserving deterministic gradients,
checkpoint compatibility, and the public tensor API.

Optimization highlights

  • Parallel contiguous, packed, and batched matrix multiplication with adaptive
    OpenMP scheduling.
  • Cached and reusable transpose-aware matrix packs across Linear forward and
    backward passes.
  • Direct batched RHS-gradient and projected weight-gradient kernels, including
    deterministic vectorized Linear weight-gradient GEMM.
  • Fast paths for contiguous cloning, reductions, broadcast operations, and
    slice backward; tiled strided cloning and stride-cursor broadcast iteration.
  • Fused LayerNorm, softmax/log-softmax, indexed cross-entropy, and GELU backward
    kernels, with deterministic parallel backward paths.
  • Lower-overhead autograd through first-gradient ownership transfer, in-place
    compatible accumulation, producer-side broadcast reduction, and reusable
    traversal storage.
  • Faster AdamW through contiguous single-pass updates, specialized gradient
    scanning, and deterministic parallel updates.

On the repository's i5-13400F reference host, the matched full-profile
benchmarks measured gains of 1,186% for LayerNorm, 1,099% for transposed copy,
261% for causal attention, 164% for TinyLM forward, and 141% for a decoder
block. Results are machine- and workload-specific; see CHANGELOG.md and the
benchmark documentation for methodology and the complete breakdown.

TinyLM checkpoint

This release includes a new tiny_lm.chk for the fixed 1,902,976-parameter
TinyLM preset (4 layers, width 192, 6 heads, context 128, byte vocabulary 256).
It includes model weights, AdamW state, and RNG state and can be resumed with:

./build/tiny_lm CORPUS --checkpoint tiny_lm.chk --resume

SHA-256:
bc11a667129224f64f9ede0788bb6367206dc912ac1e42a5bca5c5115edd21fc

Verification

  • 37/37 tests passed in a Release build with warnings treated as errors.
  • The release checkpoint loaded successfully and produced validation loss
    1.27012 against the local evaluation corpus.
  • All local Markdown links passed validation.

Full changelog: https://github.com/nisbenz/TensorLib/blob/v0.2.0/CHANGELOG.md