Skip to content

v3.12.0

Choose a tag to compare

@github-actions github-actions released this 01 Nov 03:04
· 3 commits to main since this release
feat(ops): slice, cat and index_select

Multi-head attention is, mechanically, "cut the last axis into pieces, run each
piece, put them back". Before this change none of those three moves existed: the
library could multiply matrices but could not assemble heads.

Three operators, all reducing along a single axis:

- slice(dim, start, end)   copies a range; backward writes the gradient back into
                           that range and leaves the rest zero
- cat(other, dim)          joins two tensors; backward splits the gradient at the
                           seam
- indexSelect(dim, idx)    gathers by index; backward scatters and accumulates,
                           so repeated indices add up

Native operators go from 34 to 37. The split-and-rejoin path is covered by
attentionHeadSplitAndMergeRoundTrips, which slices a [1,2,4] tensor into two
heads and asserts the concatenation is bit-identical to the original.

Two implementation notes:

The gather index tensor holds floats because tensors are f32 everywhere, so the
values are validated for integrality and range rather than truncated silently.

cat checks that the non-joined axes match in Java before crossing into native
code. Without that the failure surfaced as BasaltShapeException from the engine
while every other argument error was IllegalArgumentException, which made the
API inconsistent for no benefit.

Version 3.12.0. 32 Rust tests, 15 Java tests, verify.sh green with 9 groups,
1616 of 1616 public members documented, 0 placeholders.