You could try to increase the batch size of both DataLoaders and index d as d[i*bs:(i+1)*bs].
Also, do you need to compute the full matrix, i.e. is
calculate_some_score(a, b) != calculate_some_score(b, a)

?