invert grad, submod ready for unit tests