ensure that historical gradient is always the same length as the passed in gradient