Inconsistent results using view()

I don’t understand why there would be any difference by using view():

julia> Random.seed!(1);

julia> xhmat = randn(Float32, 10, 1000);

julia> [sum(xhmat[d, :]) for d in 1:10]
10-element Vector{Float32}:
   6.1436114
  31.91372
   9.005221
 -40.03097
 -48.17327
  -6.9555407
  35.577076
 -33.41585
  12.131447
 -22.086914

julia> [sum(view(xhmat, d, :)) for d in 1:10]
10-element Vector{Float32}:
   6.1436205
  31.913723
   9.005228
 -40.030956
 -48.173267
  -6.9555435
  35.577084
 -33.41586
  12.13145
 -22.086939

using 1.12.6

I can’t reproduce the difference, and my printed values are close to but not exactly either of your results. Save those 2 vectors to y and z then check all(iszero, y .- z) in case it’s just some odd display rounding. If it’s some platform-specific issue, share your full versioninfo().

Here’s what I see:

julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f0 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, icelake-client)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)

julia> using Random; Random.seed!(1);

julia> y = [sum(xhmat[d, :]) for d in 1:10];

julia> z = [sum(view(xhmat, d, :)) for d in 1:10];

julia> all(iszero, y .- z)
true

julia> y # z prints the same thing
10-element Vector{Float32}:
   6.143616
  31.913727
   9.005218
 -40.030968
 -48.173264
  -6.9555407
  35.577076
 -33.41585
  12.131446
 -22.086918

obviously not from display rounding:

julia> y = [sum(xhmat[d, :]) for d in 1:10];

julia> z = [sum(view(xhmat, d, :)) for d in 1:10];

julia> all(iszero, y .- z)
false

julia> any(iszero, y .- z)
false
julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 24 × Apple M2 Ultra
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m2)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 16 virtual cores)
Environment:
  DYLD_LIBRARY_PATH = /Developer/NVIDIA/CUDA-9.1/lib:
  JULIA_EDITOR = Atom

I think that’s worth filing an issue, I shared my results if you need a Windows comparison.

indeed there’re a lot more strange inconsistencies… I just trying to produce a minimum example here…

how to file an issue???

Here:

There might already be an issue there so try searching for it a bit first. If you miss it, people will link them and close the less general ones.

This is

Summing floating point numbers doesn’t guarantee the associativity of the operation — and the results really depend upon it!

issue filed

It does appear that sum SIMDs for the vectors and not the non-contiguous views, so are my equal results just some architecture quirk?