The influencing factors of machining errors are analyzed aiming at the characteristics of the CNC spiral bevel gears grinding machine. The relation between those factors and machine setting errors is built. The optimization model of nonlinear least square is deduced. According to the mathematics model, an experiment of tooth form deviation correction is done in YK2075 CNC spiral bevel gears grinding machine manufactured by Tianjin No.1 Machine Tool Works. And the mathematics model is verified in the experiment.