grad() requires some communication, need to compute it outside