Skip to content

Tolerances in warp.autograd.gradcheck #508

@JonathanKuelz

Description

@JonathanKuelz

The docs for gradcheck mention

Fails if the relative or absolute errors between the autodiff and finite difference gradients exceed the specified tolerance, ...

which sounds like the check would fail in any of two cases: Either atol is exceeded, or if rtol * |jac_fd| > |jac_ad- jac_fd|. However, internally, grad check uses np.allclose, which fails iff |a-b| > atol + rtol * |b|. This leads to confusing outputs such as this:

Input   | Output   | Max Abs Error       | AD at MAE | FD at MAE | Max Rel Error | Pass | 
-----------------------------------------------------------------------------------------
actions | output_0 | 1.751e-04 at (0, 0) | 4.840e-05 | 2.235e-04 | 1.587e+03     | PASS | 
Gradient check for kernel step passed

where the maximum relative error is clearly above the (default) value, but still the check passes.

Metadata

Metadata

Assignees

Labels

docsImprovements or additions to documentation

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions