Repository navigation
Fixed
-
PSUM accumulation groups now open with a matmul write
(trnsci/trnsci#185). The kernels zeroed their fp32 PSUM accumulators
withnl.zeros(..., buffer=nl.psum)or a PSUMmemsetand then
accumulated withnc_matmul(..., accumulate=True). Thenc_matmul
documentation calls a matmul accumulating onto PSUM that a non-matmul
instruction initialised undefined behaviour on NeuronCore-v3 (Trn2): the
first matmul into a PSUM location must useaccumulate=False. Device
results have matched references so far, but the pattern could break with a
compiler or runtime change. Now the first matmul of each group overwrites
(accumulate=False, oraccumulate=k > 0over a Pythonrange) in the
dense, BSR, screened and pre-transposed SpMM kernels, the screened-tile and
row-group kernels, and the gather and static attention kernels (forward and
backward). An accumulator is zeroed only when no matmul writes it (an
empty padded group). The fused CG / power-iteration matvec tiles hold many
groups (one per block row, interleaved, overlapping in the spread layout,
none for an empty row), so a matmul of bf16 zeros (one partition) now
zeroes each tile instead of the memset, one extra TensorE instruction per
matvec PSUM tile; the partition-sum dot products, one matmul each, now
overwrite instead. The GP kernel-matmul (kernel_matmul) tiles and
segment_sumalready opened their groups withaccumulate=Falseand are
unchanged. Simulator outputs are bitwise equal to the previous ones at
every simulator test shape.tests/test_psum_accumulate_lint.pyfails on
the pattern. -
test_feature_chunks_bitwiseno longer depends on the CI host's CPU
(#146). The simulator runsnc_matmulasnp.matmul, and OpenBLAS
picks its sgemm kernel by CPU. On some kernels the fp32 sum order for a
column changes with the matrix width, so the unaligned 700-column chunks
(512 + 188-column matmuls) were not bitwise equal to one launch. The test
then failed on some runners only. The unaligned case now uses integer
messages, whose fp32 sums are exact in any order. The aligned case still
uses random messages, since its matmul shapes match one launch's. Library
code and hardware results are unchanged.