Given the fact the the same machine processes all the elements I would expect the output to be identical as it happens for cpu.

Don’t the cpu tests above actually give the same result? Only the cuda version shows differences right?
Also you can try to set OMP_NUM_THREADS=1 (or corresponding MKL version if you use that)to avoid non-determinism on the CPU.

Seems reshaping (ravel/unravel) is one of the reasons. Works nice without it.

What did you change exactly in the code?