Skip to content

Add gradcheck for forward AD by default and functional API#49099

Closed
albanD wants to merge 41 commits intogh/albanD/67/basefrom
gh/albanD/67/head
Closed

Add gradcheck for forward AD by default and functional API#49099
albanD wants to merge 41 commits intogh/albanD/67/basefrom
gh/albanD/67/head

Conversation

@albanD
Copy link
Copy Markdown
Collaborator

@albanD albanD commented Dec 9, 2020

Stack from ghstack:

RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:

  • Forward grad is always checked
  • If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:

  • Forward grad is always checked
  • Failure with not implemented op is an actual failure
  • Users should set check_forward=False if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: D25607502

@albanD albanD requested a review from apaszke as a code owner December 9, 2020 18:45
albanD added a commit that referenced this pull request Dec 9, 2020
@dr-ci
Copy link
Copy Markdown

dr-ci bot commented Dec 9, 2020

💊 CI failures summary and remediations

As of commit 7f4a14a (more details on the Dr. CI page):


  • 17/17 failures possibly* introduced in this PR
    • 2/17 non-scanned failure(s)

🕵️ 15 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See GitHub Actions build mypy (1/15)

Step: "Run mypy" (full log | diagnosis details | 🔁 rerun)

2021-04-14T14:25:34.7396130Z tools/autograd/gen_variable_type.py:757:50: error: Name 'ListType' is not defined
2021-04-14T14:25:22.3122415Z �[36;1mfor CONFIG in mypy*.ini; do mypy --config="$CONFIG"; done�[0m
2021-04-14T14:25:22.3152971Z shell: /bin/bash -e {0}
2021-04-14T14:25:22.3153317Z env:
2021-04-14T14:25:22.3153837Z   pythonLocation: /opt/hostedtoolcache/Python/3.8.9/x64
2021-04-14T14:25:22.3154676Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.9/x64/lib
2021-04-14T14:25:22.3155310Z ##[endgroup]
2021-04-14T14:25:22.3258938Z + for CONFIG in mypy*.ini
2021-04-14T14:25:22.3262432Z + mypy --config=mypy-strict.ini
2021-04-14T14:25:34.1898694Z tools/autograd/load_derivatives.py:101:24: error: Name 'Type' is not defined
2021-04-14T14:25:34.1900129Z tools/autograd/load_derivatives.py:228:45: error: Name 'SchemaKind' is not defined
2021-04-14T14:25:34.7396130Z tools/autograd/gen_variable_type.py:757:50: error: Name 'ListType' is not defined
2021-04-14T14:25:37.4679928Z Found 3 errors in 2 files (checked 53 source files)
2021-04-14T14:25:37.9594254Z ##[error]Process completed with exit code 1.
2021-04-14T14:25:37.9692448Z Post job cleanup.
2021-04-14T14:25:38.0657151Z [command]/usr/bin/git version
2021-04-14T14:25:38.0700810Z git version 2.31.1
2021-04-14T14:25:38.0733916Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-04-14T14:25:38.0770373Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-04-14T14:25:38.1007977Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-04-14T14:25:38.1030018Z http.https://github.com/.extraheader
2021-04-14T14:25:38.1038704Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test2 (2/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:37:02 NameError: name 'fn' is not defined
Apr 14 15:37:02 ======================================================================
Apr 14 15:37:02 ERROR [0.031s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
Apr 14 15:37:02 ----------------------------------------------------------------------
Apr 14 15:37:02 Traceback (most recent call last):
Apr 14 15:37:02   File "test_autograd.py", line 5867, in test_vjp_create_graph
Apr 14 15:37:02     gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
Apr 14 15:37:02   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 2134, in gradcheck
Apr 14 15:37:02     return torch.autograd.gradcheck(fn, inputs, **kwargs)
Apr 14 15:37:02   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:37:02     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:37:02 NameError: name 'fn' is not defined
Apr 14 15:37:02 
Apr 14 15:37:02 ======================================================================
Apr 14 15:37:02 FAIL [0.002s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
Apr 14 15:37:02 ----------------------------------------------------------------------
Apr 14 15:37:02 Traceback (most recent call last):
Apr 14 15:37:02   File "test_autograd.py", line 5960, in test_jvp_no_grad
Apr 14 15:37:02     self.assertIsNotNone(res[0].grad_fn)
Apr 14 15:37:02 AssertionError: unexpectedly None
Apr 14 15:37:02 
Apr 14 15:37:02 ----------------------------------------------------------------------

See CircleCI build pytorch_macos_10_13_py3_test (3/15)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

Apr 14 14:57:24 NameError: name 'fn' is not defined
Apr 14 14:57:24 ======================================================================
Apr 14 14:57:24 ERROR [0.041s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
Apr 14 14:57:24 ----------------------------------------------------------------------
Apr 14 14:57:24 Traceback (most recent call last):
Apr 14 14:57:24   File "test_autograd.py", line 5867, in test_vjp_create_graph
Apr 14 14:57:24     gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
Apr 14 14:57:24   File "/Users/distiller/workspace/miniconda3/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 2134, in gradcheck
Apr 14 14:57:24     return torch.autograd.gradcheck(fn, inputs, **kwargs)
Apr 14 14:57:24   File "/Users/distiller/workspace/miniconda3/lib/python3.7/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 14:57:24     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 14:57:24 NameError: name 'fn' is not defined
Apr 14 14:57:24 
Apr 14 14:57:24 ======================================================================
Apr 14 14:57:24 FAIL [0.003s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
Apr 14 14:57:24 ----------------------------------------------------------------------
Apr 14 14:57:24 Traceback (most recent call last):
Apr 14 14:57:24   File "test_autograd.py", line 5960, in test_jvp_no_grad
Apr 14 14:57:24     self.assertIsNotNone(res[0].grad_fn)
Apr 14 14:57:24 AssertionError: unexpectedly None
Apr 14 14:57:24 
Apr 14 14:57:24 ----------------------------------------------------------------------

See CircleCI build pytorch_xla_linux_bionic_py3_6_clang9_test (4/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:58:05 NameError: name 'partial' is not defined
Apr 14 15:58:03 + echo 'Running in DynamicShape mode: python3' /var/lib/jenkins/workspace/xla/test/../../test/test_nn.py -v TestNNDeviceTypeXLA
Apr 14 15:58:03 Running in DynamicShape mode: python3 /var/lib/jenkins/workspace/xla/test/../../test/test_nn.py -v TestNNDeviceTypeXLA
Apr 14 15:58:03 + XLA_EXPERIMENTAL=nonzero:masked_select
Apr 14 15:58:03 + run_test python3 /var/lib/jenkins/workspace/xla/test/../../test/test_nn.py -v TestNNDeviceTypeXLA
Apr 14 15:58:03 + python3 /var/lib/jenkins/workspace/xla/test/../../test/test_nn.py -v TestNNDeviceTypeXLA
Apr 14 15:58:05 /opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_nn.py:1195: UserWarning: Legacy tensor constructor is deprecated. Use: torch.tensor(...) for creating tensors from tensor-like objects; or torch.empty(...) for creating an uninitialized tensor with specific sizes. (Triggered internally at  /var/lib/jenkins/workspace/torch/csrc/utils/tensor_new.cpp:478.)
Apr 14 15:58:05   random_samples = torch.DoubleTensor(1, 3, 2).uniform_()
Apr 14 15:58:05 Traceback (most recent call last):
Apr 14 15:58:05   File "/var/lib/jenkins/workspace/xla/test/../../test/test_nn.py", line 78, in <module>
Apr 14 15:58:05     gradcheck = partial(gradcheck, check_forward=True)
Apr 14 15:58:05 NameError: name 'partial' is not defined
Apr 14 15:58:05 + cleanup
Apr 14 15:58:05 + retcode=1
Apr 14 15:58:05 + set +x
Apr 14 15:58:05 =================== sccache compilation log ===================
Apr 14 15:58:05 =========== If your build fails, please take a look at the log above for possible reasons ===========
Apr 14 15:58:05 Compile requests                      28
Apr 14 15:58:05 Compile requests executed             26
Apr 14 15:58:05 Cache hits                             2
Apr 14 15:58:05 Cache hits (C/C++)                     2
Apr 14 15:58:05 Cache misses                          24

See CircleCI build pytorch_linux_bionic_py3_6_clang9_noarch_test (5/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:11:58 NameError: name 'fn' is not defined
Apr 14 15:11:58 ======================================================================
Apr 14 15:11:58 ERROR [0.023s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
Apr 14 15:11:58 ----------------------------------------------------------------------
Apr 14 15:11:58 Traceback (most recent call last):
Apr 14 15:11:58   File "test_autograd.py", line 5867, in test_vjp_create_graph
Apr 14 15:11:58     gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
Apr 14 15:11:58   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 2134, in gradcheck
Apr 14 15:11:58     return torch.autograd.gradcheck(fn, inputs, **kwargs)
Apr 14 15:11:58   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:11:58     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:11:58 NameError: name 'fn' is not defined
Apr 14 15:11:58 
Apr 14 15:11:58 ======================================================================
Apr 14 15:11:58 FAIL [0.002s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
Apr 14 15:11:58 ----------------------------------------------------------------------
Apr 14 15:11:58 Traceback (most recent call last):
Apr 14 15:11:58   File "test_autograd.py", line 5960, in test_jvp_no_grad
Apr 14 15:11:58     self.assertIsNotNone(res[0].grad_fn)
Apr 14 15:11:58 AssertionError: unexpectedly None
Apr 14 15:11:58 
Apr 14 15:11:58 ----------------------------------------------------------------------

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test1 (6/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:36:31 NameError: name 'fn' is not defined
Apr 14 15:36:31   File "test_ops.py", line 209, in test_inplace_gradgrad
Apr 14 15:36:31     self._gradgrad_test_helper(device, dtype, op, self._get_safe_inplace(op.get_inplace()))
Apr 14 15:36:31   File "test_ops.py", line 163, in _gradgrad_test_helper
Apr 14 15:36:31     return self._check_helper(device, dtype, op, variant, 'gradgradcheck')
Apr 14 15:36:31   File "test_ops.py", line 150, in _check_helper
Apr 14 15:36:31     check_forward=True))
Apr 14 15:36:31   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 953, in gradgradcheck
Apr 14 15:36:31     check_batched_grad=check_batched_grad, stacklevel=3, check_forward=check_forward)
Apr 14 15:36:31   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:36:31     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:36:31 NameError: name 'fn' is not defined
Apr 14 15:36:31 
Apr 14 15:36:31 ----------------------------------------------------------------------
Apr 14 15:36:31 Ran 4877 tests in 795.605s
Apr 14 15:36:31 
Apr 14 15:36:31 FAILED (errors=645, skipped=781)
Apr 14 15:36:31 
Apr 14 15:36:31 Generating XML reports...
Apr 14 15:36:31 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestCommonCUDA-20210414152311.xml
Apr 14 15:36:31 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestGradientsCUDA-20210414152311.xml
Apr 14 15:36:31 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestOpInfoCUDA-20210414152311.xml

See CircleCI build pytorch_linux_xenial_py3_clang5_asan_test2 (7/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:22:19 NameError: name 'fn' is not defined
Apr 14 15:22:19 ======================================================================
Apr 14 15:22:19 ERROR [0.121s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
Apr 14 15:22:19 ----------------------------------------------------------------------
Apr 14 15:22:19 Traceback (most recent call last):
Apr 14 15:22:19   File "test_autograd.py", line 5867, in test_vjp_create_graph
Apr 14 15:22:19     gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
Apr 14 15:22:19   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 2134, in gradcheck
Apr 14 15:22:19     return torch.autograd.gradcheck(fn, inputs, **kwargs)
Apr 14 15:22:19   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:22:19     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:22:19 NameError: name 'fn' is not defined
Apr 14 15:22:19 
Apr 14 15:22:19 ======================================================================
Apr 14 15:22:19 FAIL [0.003s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
Apr 14 15:22:19 ----------------------------------------------------------------------
Apr 14 15:22:19 Traceback (most recent call last):
Apr 14 15:22:19   File "test_autograd.py", line 5960, in test_jvp_no_grad
Apr 14 15:22:19     self.assertIsNotNone(res[0].grad_fn)
Apr 14 15:22:19 AssertionError: unexpectedly None
Apr 14 15:22:19 
Apr 14 15:22:19 ----------------------------------------------------------------------

See CircleCI build pytorch_linux_bionic_py3_8_gcc9_coverage_test2 (8/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:36:38 NameError: name 'partial' is not defined
Apr 14 15:36:34 Generated XML report: test-reports/python-unittest/test_quantization/TEST-quantization.test_workflow_module.TestRecordHistogramObserver-20210414151041.xml
Apr 14 15:36:34 Generated XML report: test-reports/python-unittest/test_quantization/TEST-quantization.test_backward_compatibility.TestSerialization-20210414151041.xml
Apr 14 15:36:34 Generated XML report: test-reports/python-unittest/test_quantization/TEST-quantization.test_quantized_module.TestStaticQuantizedModule-20210414151041.xml
Apr 14 15:36:35 Running test_nn ... [2021-04-14 15:36:35.467603]
Apr 14 15:36:35 Executing ['coverage', 'run', '--parallel-mode', '--source=torch', 'test_nn.py', '-v'] ... [2021-04-14 15:36:35.467674]
Apr 14 15:36:38 /opt/conda/lib/python3.8/site-packages/torch/testing/_internal/common_nn.py:1195: UserWarning: Legacy tensor constructor is deprecated. Use: torch.tensor(...) for creating tensors from tensor-like objects; or torch.empty(...) for creating an uninitialized tensor with specific sizes. (Triggered internally at  /var/lib/jenkins/workspace/torch/csrc/utils/tensor_new.cpp:475.)
Apr 14 15:36:38   random_samples = torch.DoubleTensor(1, 3, 2).uniform_()
Apr 14 15:36:38 Traceback (most recent call last):
Apr 14 15:36:38   File "test_nn.py", line 78, in <module>
Apr 14 15:36:38     gradcheck = partial(gradcheck, check_forward=True)
Apr 14 15:36:38 NameError: name 'partial' is not defined
Apr 14 15:36:38 Traceback (most recent call last):
Apr 14 15:36:38   File "test/run_test.py", line 1101, in <module>
Apr 14 15:36:38     main()
Apr 14 15:36:38   File "test/run_test.py", line 1080, in main
Apr 14 15:36:38     raise RuntimeError(err_message)
Apr 14 15:36:38 RuntimeError: test_nn failed!
Apr 14 15:36:39 
Apr 14 15:36:39 real	26m1.843s
Apr 14 15:36:39 user	41m23.968s
Apr 14 15:36:39 sys	0m21.179s

See CircleCI build pytorch_windows_vs2019_py36_cuda10.1_test1 (9/15)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

NameError: name 'fn' is not defined
  File "test_ops.py", line 209, in test_inplace_gradgrad
    self._gradgrad_test_helper(device, dtype, op, self._get_safe_inplace(op.get_inplace()))
  File "test_ops.py", line 163, in _gradgrad_test_helper
    return self._check_helper(device, dtype, op, variant, 'gradgradcheck')
  File "test_ops.py", line 150, in _check_helper
    check_forward=True))
  File "C:\Users\circleci\project\build\win_tmp\build\torch\autograd\gradcheck.py", line 953, in gradgradcheck
    check_batched_grad=check_batched_grad, stacklevel=3, check_forward=check_forward)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\autograd\gradcheck.py", line 836, in gradcheck
    fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
NameError: name 'fn' is not defined

----------------------------------------------------------------------
Ran 9682 tests in 694.531s

FAILED (errors=1313, skipped=1395)

Generating XML reports...
Generated XML report: test-reports\python-unittest\test_ops\TEST-TestCommonCPU-20210414151037.xml
Generated XML report: test-reports\python-unittest\test_ops\TEST-TestCommonCUDA-20210414151037.xml
Generated XML report: test-reports\python-unittest\test_ops\TEST-TestGradientsCPU-20210414151037.xml

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_test (10/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:07:19 NameError: name 'fn' is not defined
Apr 14 15:07:19 ======================================================================
Apr 14 15:07:19 ERROR [0.025s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
Apr 14 15:07:19 ----------------------------------------------------------------------
Apr 14 15:07:19 Traceback (most recent call last):
Apr 14 15:07:19   File "test_autograd.py", line 5867, in test_vjp_create_graph
Apr 14 15:07:19     gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
Apr 14 15:07:19   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 2134, in gradcheck
Apr 14 15:07:19     return torch.autograd.gradcheck(fn, inputs, **kwargs)
Apr 14 15:07:19   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:07:19     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:07:19 NameError: name 'fn' is not defined
Apr 14 15:07:19 
Apr 14 15:07:19 ======================================================================
Apr 14 15:07:19 FAIL [0.002s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
Apr 14 15:07:19 ----------------------------------------------------------------------
Apr 14 15:07:19 Traceback (most recent call last):
Apr 14 15:07:19   File "test_autograd.py", line 5960, in test_jvp_no_grad
Apr 14 15:07:19     self.assertIsNotNone(res[0].grad_fn)
Apr 14 15:07:19 AssertionError: unexpectedly None
Apr 14 15:07:19 
Apr 14 15:07:19 ----------------------------------------------------------------------

See CircleCI build pytorch_windows_vs2019_py36_cuda10.1_test2 (11/15)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

NameError: name 'fn' is not defined
======================================================================
ERROR [0.019s]: test_vjp_create_graph (__main__.TestAutogradFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_autograd.py", line 5867, in test_vjp_create_graph
    gradcheck(lambda *args: autogradF.vjp(adder, args[:2], args[2:], create_graph=True)[1], inputs + v)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\testing\_internal\common_utils.py", line 2134, in gradcheck
    return torch.autograd.gradcheck(fn, inputs, **kwargs)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\autograd\gradcheck.py", line 836, in gradcheck
    fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
NameError: name 'fn' is not defined

======================================================================
FAIL [0.003s]: test_jvp_no_grad (__main__.TestAutogradFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_autograd.py", line 5960, in test_jvp_no_grad
    self.assertIsNotNone(res[0].grad_fn)
AssertionError: unexpectedly None

----------------------------------------------------------------------

See CircleCI build pytorch_linux_xenial_py3_clang5_asan_test1 (12/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:35:48 NameError: name 'fn' is not defined
Apr 14 15:35:48   File "test_ops.py", line 209, in test_inplace_gradgrad
Apr 14 15:35:48     self._gradgrad_test_helper(device, dtype, op, self._get_safe_inplace(op.get_inplace()))
Apr 14 15:35:48   File "test_ops.py", line 163, in _gradgrad_test_helper
Apr 14 15:35:48     return self._check_helper(device, dtype, op, variant, 'gradgradcheck')
Apr 14 15:35:48   File "test_ops.py", line 150, in _check_helper
Apr 14 15:35:48     check_forward=True))
Apr 14 15:35:48   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 953, in gradgradcheck
Apr 14 15:35:48     check_batched_grad=check_batched_grad, stacklevel=3, check_forward=check_forward)
Apr 14 15:35:48   File "/opt/conda/lib/python3.6/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:35:48     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:35:48 NameError: name 'fn' is not defined
Apr 14 15:35:48 
Apr 14 15:35:48 ----------------------------------------------------------------------
Apr 14 15:35:48 Ran 4827 tests in 1051.909s
Apr 14 15:35:48 
Apr 14 15:35:48 FAILED (errors=675, skipped=586)
Apr 14 15:35:48 
Apr 14 15:35:48 Generating XML reports...
Apr 14 15:35:48 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestCommonCPU-20210414151807.xml
Apr 14 15:35:48 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestGradientsCPU-20210414151807.xml
Apr 14 15:35:48 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestOpInfoCPU-20210414151807.xml

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_jit_legacy_test (13/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:02:06 RuntimeError: test_jit_legacy failed!
Apr 14 15:02:06 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_typing.TestTyping-20210414150009.xml
Apr 14 15:02:06 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_unsupported_ops.TestUnsupportedOps-20210414150009.xml
Apr 14 15:02:06 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_warn.TestWarn-20210414150009.xml
Apr 14 15:02:06 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_with.TestWith-20210414150009.xml
Apr 14 15:02:06 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_data_parallel.TestDataParallel-20210414150009.xml
Apr 14 15:02:06 Traceback (most recent call last):
Apr 14 15:02:06   File "test/run_test.py", line 1101, in <module>
Apr 14 15:02:06     main()
Apr 14 15:02:06   File "test/run_test.py", line 1080, in main
Apr 14 15:02:06     raise RuntimeError(err_message)
Apr 14 15:02:06 RuntimeError: test_jit_legacy failed!
Apr 14 15:02:06 + cleanup
Apr 14 15:02:06 + retcode=1
Apr 14 15:02:06 + set +x
Apr 14 15:02:06 =================== sccache compilation log ===================
Apr 14 15:02:06 =========== If your build fails, please take a look at the log above for possible reasons ===========
Apr 14 15:02:06 Compile requests                     54
Apr 14 15:02:06 Compile requests executed             0
Apr 14 15:02:06 Cache hits                            0
Apr 14 15:02:06 Cache misses                          0
Apr 14 15:02:06 Cache timeouts                        0

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_jit_legacy_test (14/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:21:46 RuntimeError: test_jit_legacy failed!
Apr 14 15:21:45 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_types.TestTypesAndAnnotation-20210414151853.xml
Apr 14 15:21:45 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_typing.TestTyping-20210414151853.xml
Apr 14 15:21:45 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_unsupported_ops.TestUnsupportedOps-20210414151853.xml
Apr 14 15:21:45 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_warn.TestWarn-20210414151853.xml
Apr 14 15:21:45 Generated XML report: test-reports/python-unittest/test_jit_legacy/TEST-jit.test_with.TestWith-20210414151853.xml
Apr 14 15:21:46 Traceback (most recent call last):
Apr 14 15:21:46   File "test/run_test.py", line 1101, in <module>
Apr 14 15:21:46     main()
Apr 14 15:21:46   File "test/run_test.py", line 1080, in main
Apr 14 15:21:46     raise RuntimeError(err_message)
Apr 14 15:21:46 RuntimeError: test_jit_legacy failed!
Apr 14 15:21:46 + cleanup
Apr 14 15:21:46 + retcode=1
Apr 14 15:21:46 + set +x
Apr 14 15:21:46 =================== sccache compilation log ===================
Apr 14 15:21:46 =========== If your build fails, please take a look at the log above for possible reasons ===========
Apr 14 15:21:46 Compile requests                     17
Apr 14 15:21:46 Compile requests executed             0
Apr 14 15:21:46 Cache hits                            0
Apr 14 15:21:46 Cache misses                          0
Apr 14 15:21:46 Cache timeouts                        0

See CircleCI build pytorch_linux_bionic_py3_8_gcc9_coverage_test1 (15/15)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Apr 14 15:19:45 NameError: name 'fn' is not defined
Apr 14 15:19:45   File "test_ops.py", line 209, in test_inplace_gradgrad
Apr 14 15:19:45     self._gradgrad_test_helper(device, dtype, op, self._get_safe_inplace(op.get_inplace()))
Apr 14 15:19:45   File "test_ops.py", line 163, in _gradgrad_test_helper
Apr 14 15:19:45     return self._check_helper(device, dtype, op, variant, 'gradgradcheck')
Apr 14 15:19:45   File "test_ops.py", line 146, in _check_helper
Apr 14 15:19:45     self.assertTrue(gradgradcheck(fn, gradcheck_args,
Apr 14 15:19:45   File "/opt/conda/lib/python3.8/site-packages/torch/autograd/gradcheck.py", line 951, in gradgradcheck
Apr 14 15:19:45     return gradcheck(new_func, tupled_inputs + tupled_grad_outputs, eps, atol, rtol, raise_exception,
Apr 14 15:19:45   File "/opt/conda/lib/python3.8/site-packages/torch/autograd/gradcheck.py", line 836, in gradcheck
Apr 14 15:19:45     fw_analytical = get_analytical_jacobian_fw(fn, tupled_inputs, o)
Apr 14 15:19:45 NameError: name 'fn' is not defined
Apr 14 15:19:45 
Apr 14 15:19:45 ----------------------------------------------------------------------
Apr 14 15:19:45 Ran 4827 tests in 537.110s
Apr 14 15:19:45 
Apr 14 15:19:45 FAILED (errors=675, skipped=586)
Apr 14 15:19:45 
Apr 14 15:19:45 Generating XML reports...
Apr 14 15:19:45 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestCommonCPU-20210414151038.xml
Apr 14 15:19:45 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestGradientsCPU-20210414151038.xml
Apr 14 15:19:45 Generated XML report: test-reports/python-unittest/test_ops/TEST-TestOpInfoCPU-20210414151038.xml

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

albanD added a commit that referenced this pull request Dec 9, 2020
This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 9, 2020
This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 9, 2020
@zou3519 zou3519 self-requested a review December 10, 2020 15:36
This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 10, 2020
This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 11, 2020
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and minor comments but this looks pretty reasonable to me

pass

def _assertGradAndGradgradChecks(test_case, apply_fn, inputs):
def _assertGradAndGradgradChecks(test_case, apply_fn, inputs, check_forward=True):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will merge-conflict with #49120 but we can figure out what order we want them to go in

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ref. The merge conflict should be fairly easy to handle indeed.

RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 14, 2020
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
albanD added a commit that referenced this pull request Dec 14, 2020
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).



[ghstack-poisoned]
Comment on lines +465 to +469
for j, (a, n) in enumerate(zip(fw_analytical, numerical)):
if a.numel() != 0 or n.numel() != 0:
if not torch.allclose(a, n, rtol, atol):
return fail_test('Jacobian mismatch for output %d with respect to input %d,\n'
'numerical:%s\nforward analytical:%s\n' % (i, j, n, a))
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: continues can reduce the indentation (and make that first condition a little easier to read), but it probably comes down to personal preference.

if a.numel() == 0 and n.numel() == 0:
    continue
if torch.allclose(a, n, rtol, atol):
    continue
return fail_test(...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if a.numel() == 0 and n.numel() == 0, shouldn't we check that the shapes of the tensors are the same?

the second derivative.
check_undefined_grad (bool, options): if True, check if undefined output grads
are supported and treated as zeros
check_forward(bool, options): if True, check the forward mode AD gradient
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options -> optional (and we should state the default)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasted the options from the one above... But I think you fixed this one in master? I'll update!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR got reverted haha. I'll re-submit it later today

exactly (default, 0.0) or be within this tolerance.
check_undefined_grad (bool, options): if True, check if undefined output grads
are supported and treated as zeros, for ``Tensor`` outputs.
check_forward (bool, optional): if True, check the forward mode AD gradient
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should state the default (False)

Comment on lines +5562 to +5565
# break both forward and backward mode links
out = a.detach()
out, _ = fwAD.unpack_dual(out)
return out
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_jvp_err_check_strict doesn't call jvp with fw_mode=True, so the unpack_dual line here doesn't actually do anything meaningful, right?

On a related note, it would be good to update all of the jvp tests to test with both fw_mode=True and fw_mode=False for comprehensiveness. I see the following functions:

  • test_jvp_output
  • test_jvp_scalar
  • test_jvp_err_check
  • test_jvp_err_check_strict
  • test_jvp_create_graph (has already been updated to test fw_mode=True)

Comment on lines 5660 to +5666
self.assertIsNotNone(res[0].grad_fn)
self.assertIsNotNone(res[1].grad_fn)

gradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True), (inputs, v))
gradgradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True), (inputs, v))
res = autogradF.jvp(reducer, inputs, v, create_graph=True, fw_mode=False)
self._assert_same_struct(res[1], res[0])
self.assertIsNotNone(res[0].grad_fn)
self.assertIsNotNone(res[1].grad_fn)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused -- isn't fw_mode=False the default right now?

Also nit:

for fw_mode in [True, False]:
        res = autogradF.jvp(reducer, inputs, v, create_graph=True, fw_mode=False)       
        self._assert_same_struct(res[1], res[0])
        self.assertIsNotNone(res[0].grad_fn)
        self.assertIsNotNone(res[1].grad_fn)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, this is left from an older version. My bad!

Comment on lines +5668 to +5672
# check_forward=False here as nested forward is not supported yet
gradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True), (inputs, v), check_forward=False)
gradgradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True), (inputs, v), check_forward=False)
gradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True, fw_mode=False), (inputs, v))
gradgradcheck(lambda inp, v: autogradF.jvp(reducer, inp, v, create_graph=True, fw_mode=False), (inputs, v))
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto -- isn't fw_mode=False the default? Am I missing an override somewhere?

Copy link
Copy Markdown
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in the gradcheck and jvp all looks fine to me. I have some high-level comments:

  1. I would have probably separated this PR into 2 pieces: one that updates gradcheck to check forward mode, and another that turns on forward mode AD in the jvp api, but it's OK to leave it as is since as the reviewer I figured out which tests correspond to which of these changes.
  2. API bikeshedding: in the APIs, check_forward or fw_mode can be ambiguous, especially when the user is familiar with terminology for "NN module forward pass". Naming it "check_forward_mode_ad" is longer but removes the ambiguity.
  3. We should extend all of the jvp tests to test fw_mode on True and False (I think only some were updated).

albanD added a commit to albanD/pytorch that referenced this pull request Jan 20, 2021
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]

return jacobian, reentrant, correct_grad_sizes, correct_grad_types

def get_analytical_jacobian_fw(fn, input, output):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test the correctness of forward mode AD computing the whole Jacobian using finite differences and "analytical" is not needed. It's enough to compute a directional derivative for a random direction (Jacobian-vector product for a random tangent vector)

v = ... # random vector like input
analytical_vjp = pytorch_vjp(func, input, v)
numerical_vjp = finite_differences_vjp(func, input, v)
torch.allclose(analytical_vjp, numerical_vjp)
def finite_differences_vjp(func, inp, v):
"""Jacobian of `func` at `inp` multiplied by `v`"""
    # or using any other more accurate finite difference scheme
    return (func(inp + eps * v) - func(inp)) / (eps * norm(v))

So approximately computing JVP by finite difference takes only two function calls. Avoiding computing the whole Jacobian would speed up testing a lot.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, That is also mostly true as well for backward mode.
The point here is more that having the full Jacobian is much more useful as an error message :)

A fast version of gradcheck that uses that strategy you're talking about is in the pipe though and would also be applied to forward AD. But the full Jacobian version will still be kept to ensure good error messages in gradcheck.

RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
albanD added 2 commits March 26, 2021 17:02
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
@albanD albanD requested a review from wayi1 as a code owner March 29, 2021 14:21
albanD added a commit to albanD/pytorch that referenced this pull request Mar 29, 2021
albanD added 2 commits April 13, 2021 19:10
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
albanD added a commit to albanD/pytorch that referenced this pull request Apr 14, 2021
RFC: pytorch/rfcs#11

This PR adds the option to check forward grad using gradcheck. The current logic is:
- Forward grad is always checked
- If the forward evaluation fails because an op is not implemented, the test is silently passing

The goal is to make sure that all formulas that are added are properly tested without having to add a new test for each op.

The final logic after the next PR that adds the remaining formulas is going to be:
- Forward grad is always checked
- Failure with not implemented op is an actual failure
- Users should set `check_forward=False` if they explicitly don't want to test forward grads (which should not be the case internally).

Differential Revision: [D25607502](https://our.internmc.facebook.com/intern/diff/D25607502)

[ghstack-poisoned]
@albanD
Copy link
Copy Markdown
Collaborator Author

albanD commented May 6, 2021

This is being replaced by #57633

@albanD albanD closed this May 6, 2021
@facebook-github-bot facebook-github-bot deleted the gh/albanD/67/head branch June 6, 2021 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants