Thank you for the answer! I have the same doubt indeed.

I assume you are purely comparing the gradients computed via using the entire dataset vs. single samples.

Exactly
if I consider a batch size of 2 element, for example, I get, for each single componenet of the gradient, an error of ~1e-5 or ~1e-6, as you predicted.
May I ask you how did you guess the order of magnitude of the difference in the 2 cases? (Sorry for the stupid question)
Is it possible to pass to a double precision for the gradients component in order to verify that this is the right source of error? (in that case the order of magnitude of the difference should decrease and, in particular, it should be possible to predict the new order of magnitude as you just did for the floating precision)