Finally, I found the source of the error and this is not very promising…
Instead of
costs = zeros(T, NN, D)
@inbounds for (i,v) in enumerate(ns)
costs[i,:] = (Vector(prediction[i]) .- Vector(Y[v+Tw])).^2
end
this here
costs = abs2.(Matrix(prediction) - Matrix(Y[ns.+Tw]))
works perfectly on all machines and runners and test-environments. So in the end that was not an issue with the test-environment. Confusing…