Add configurable sum gradient reduction (#8232)