Summary
On a fresh DirectCpuExecutionContext() the first dense FP32 matmul in a JVM process produces results that differ by 1 ULP (in ~37k of 153k elements for m=300, k=64, n=512) from every later call on the same context with the same inputs. After that first call the results are stable and independent of threading or schedule.
Observed while writing SKEEP-005 parity tests (DirectCpuExecutionContextScheduleTest): probe output
same-ctx twice diff=37355 (first call vs second call)
seq twice diff=0
par-vs-seq diff=0
Likely cause
PanamaVectorMatmulKernel reduces with FloatVector.reduceLanes(ADD), whose lane-reduction order is unspecified and differs between the interpreter/C1 fallback and the C2 intrinsic. The first call runs before the intrinsic is compiled.
Why it matters
- Golden-token parity gates (
*GoldenTokenParityTest in SKaiNET-transformers) assert exact llama.cpp text equality; a warm-up-dependent ULP can flip a greedy argmax.
- Any test comparing two contexts must warm up first (the SKEEP-005 tests now do).
Options
- Replace
reduceLanes with an explicit fixed-order tree reduction (reduceLanesToLong-style) or accumulate into a vector and reduce with a deterministic scalar loop.
- Document the property and add a warm-up helper for parity tests.
Not fixed in feature/skeep-005-schedules; the schedule tests warm up before comparing.
Summary
On a fresh
DirectCpuExecutionContext()the first dense FP32matmulin a JVM process produces results that differ by 1 ULP (in ~37k of 153k elements for m=300, k=64, n=512) from every later call on the same context with the same inputs. After that first call the results are stable and independent of threading or schedule.Observed while writing SKEEP-005 parity tests (
DirectCpuExecutionContextScheduleTest): probe outputLikely cause
PanamaVectorMatmulKernelreduces withFloatVector.reduceLanes(ADD), whose lane-reduction order is unspecified and differs between the interpreter/C1 fallback and the C2 intrinsic. The first call runs before the intrinsic is compiled.Why it matters
*GoldenTokenParityTestin SKaiNET-transformers) assert exact llama.cpp text equality; a warm-up-dependent ULP can flip a greedy argmax.Options
reduceLaneswith an explicit fixed-order tree reduction (reduceLanesToLong-style) or accumulate into a vector and reduce with a deterministic scalar loop.Not fixed in
feature/skeep-005-schedules; the schedule tests warm up before comparing.