pytorch - 💡(How to fix) Fix DISABLED test_jacrev_two_tensors_argnums (__main__.FuncTorchHigherOrderOpTestsWithCompiledAutograd) [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#180264Fetched 2026-04-15 06:18:58
View on GitHub
Comments
2
Participants
1
Timeline
44
Reactions
0
Participants
Assignees
Timeline (top)
mentioned ×18subscribed ×18labeled ×5commented ×2

Error Message

Traceback (most recent call last): File "/var/lib/jenkins/workspace/test/dynamo/test_higher_order_ops.py", line 4136, in test_jacrev_two_tensors_argnums self.assertExpectedInline( File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/internal/common_utils.py", line 3387, in assertExpectedInline return super().assertExpectedInline(actual if isinstance(actual, str) else str(actual), expect, skip + 1) File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/init.py", line 413, in assertExpectedInline assert_expected_inline( File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/init.py", line 378, in assert_expected_inline assert_eq(expect, actual, msg=help_text) File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/init.py", line 450, in assertMultiLineEqualMaybeCppStack self.assertMultiLineEqual(expect, actual, *args, **kwargs) File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 1226, in assertMultiLineEqual self.fail(self.formatMessage(msg, standardMsg)) File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 675, in fail raise self.failureException(msg) AssertionError: 'clas1606 chars)\n cumsum: "i64[1]" = tensor.cums[1693 chars],)\n' != 'clas1606 chars, device = device(type='cpu'))\n [1730 chars],)\n' class GraphModule(torch.nn.Module): def forward(self, L_x: "f32[4, 3]", L_y: "f32[3, 4]"): l_x_ = L_x_ l_y_ = L_y_

      _saved_tensors_hooks_disable = torch._C._autograd._saved_tensors_hooks_disable("torch.func.{grad, vjp, jacrev, hessian} don't yet support saved tensor hooks. Please open an issue with your use case.");  _saved_tensors_hooks_disable = None
      _grad_increment_nesting = torch._C._functorch._grad_increment_nesting();  _grad_increment_nesting = None

      _wrap_for_grad: "f32[4, 3]" = torch._C._functorch._wrap_for_grad(l_x_, 1);  l_x_ = _wrap_for_grad = None
      diff_primals: "f32[3, 4]" = torch._C._functorch._wrap_for_grad(l_y_, 1);  l_y_ = None

      set_inplace_requires_grad_allowed = torch._C._functorch.set_inplace_requires_grad_allowed(True);  set_inplace_requires_grad_allowed = None

      _set_tensor_requires_grad: "f32[3, 4]" = torch._functorch.eager_transforms._set_tensor_requires_grad(diff_primals);  _set_tensor_requires_grad = None

      set_inplace_requires_grad_allowed_1 = torch._C._functorch.set_inplace_requires_grad_allowed(False);  set_inplace_requires_grad_allowed_1 = None

      primals_out: "f32[3, 4]" = diff_primals.sin()

      results: "f32[3, 4]" = torch._C._functorch._unwrap_for_grad(primals_out, 1)

      _grad_decrement_nesting = torch._C._functorch._grad_decrement_nesting();  _grad_decrement_nesting = None
      _saved_tensors_hooks_enable = torch._C._autograd._saved_tensors_hooks_enable();  _saved_tensors_hooks_enable = None
  •     tensor: "i64[1]" = torch.tensor((12,))
  •     tensor: "i64[1]" = torch.tensor((12,), device = device(type='cpu'))

? +++++++++++++++++++++++++++++ cumsum: "i64[1]" = tensor.cumsum(dim = 0); tensor = None getitem: "i64[0]" = cumsum[slice(None, -1, None)]; cumsum = None neg: "i64[0]" = getitem.neg(); getitem = None unbind = neg.unbind(); neg = unbind = None

      chunk: "f32[12, 12]" = results.new_zeros(12, 12);  results = None

- diagonal: "f32[12]" = chunk.diagonal(0) fill_: "f32[12]" = diagonal.fill_(1); diagonal = fill_ = None

      basis: "f32[12, 3, 4]" = chunk.view(12, 3, 4);  chunk = None

      lazy_load_decompositions = torch._functorch.predispatch.lazy_load_decompositions();  lazy_load_decompositions = None

      _vmap_increment_nesting = torch._functorch.predispatch._vmap_increment_nesting(12, 'error');  _vmap_increment_nesting = None

      _add_batch_dim: "f32[3, 4]" = torch._functorch.predispatch._add_batch_dim(basis, 0, 1);  basis = None

      _autograd_grad = torch._functorch.eager_transforms._autograd_grad([primals_out], [diff_primals], [_add_batch_dim], retain_graph = True, create_graph = True);  primals_out = diff_primals = _add_batch_dim = None
      batched_outputs: "f32[3, 4]" = _autograd_grad[0];  _autograd_grad = None

      chunked_result: "f32[12, 3, 4]" = torch._functorch.predispatch._remove_batch_dim(batched_outputs, 1, 12, 0);  batched_outputs = None

      _vmap_decrement_nesting = torch._functorch.predispatch._vmap_decrement_nesting();  _vmap_decrement_nesting = None
  •     split = chunked_result.split((12,), dim = 0);  chunked_result = None

? ^^^^^^^

  •     split = torch.Tensor.split(chunked_result, (12,), dim = 0);  chunked_result = None

? +++++++++++++++++++ ^^ split_1: "f32[12, 3, 4]" = split[0]; split = None

      output_input: "f32[3, 4, 3, 4]" = split_1.view((3, 4, 3, 4));  split_1 = None
      return (output_input,)

: To accept the new output, re-run test with envvar EXPECTTEST_ACCEPT=1 (we recommend staging/committing your changes before doing this)

To execute this test, run the following from the base repo dir: python test/dynamo/test_higher_order_ops.py FuncTorchHigherOrderOpTestsWithCompiledAutograd.test_jacrev_two_tensors_argnums

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0

Root Cause

This test was disabled because it is failing in CI. See recent examples and the most recent trunk workflow logs.

Fix Action

Fix / Workaround

lazy_load_decompositions = torch._functorch.predispatch.lazy_load_decompositions(); lazy_load_decompositions = None

_vmap_increment_nesting = torch._functorch.predispatch._vmap_increment_nesting(12, 'error'); _vmap_increment_nesting = None

_add_batch_dim: "f32[3, 4]" = torch._functorch.predispatch._add_batch_dim(basis, 0, 1); basis = None

Code Example

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/dynamo/test_higher_order_ops.py", line 4136, in test_jacrev_two_tensors_argnums
    self.assertExpectedInline(
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 3387, in assertExpectedInline
    return super().assertExpectedInline(actual if isinstance(actual, str) else str(actual), expect, skip + 1)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 413, in assertExpectedInline
    assert_expected_inline(
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 378, in assert_expected_inline
    assert_eq(expect, actual, msg=help_text)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 450, in assertMultiLineEqualMaybeCppStack
    self.assertMultiLineEqual(expect, actual, *args, **kwargs)
  File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 1226, in assertMultiLineEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 675, in fail
    raise self.failureException(msg)
AssertionError: 'clas[1606 chars](12,))\n        cumsum: "i64[1]" = tensor.cums[1693 chars],)\n' != 'clas[1606 chars](12,), device = device(type=\'cpu\'))\n       [1730 chars],)\n'
  class GraphModule(torch.nn.Module):
      def forward(self, L_x_: "f32[4, 3]", L_y_: "f32[3, 4]"):
          l_x_ = L_x_
          l_y_ = L_y_
  
          _saved_tensors_hooks_disable = torch._C._autograd._saved_tensors_hooks_disable("torch.func.{grad, vjp, jacrev, hessian} don't yet support saved tensor hooks. Please open an issue with your use case.");  _saved_tensors_hooks_disable = None
          _grad_increment_nesting = torch._C._functorch._grad_increment_nesting();  _grad_increment_nesting = None
  
          _wrap_for_grad: "f32[4, 3]" = torch._C._functorch._wrap_for_grad(l_x_, 1);  l_x_ = _wrap_for_grad = None
          diff_primals: "f32[3, 4]" = torch._C._functorch._wrap_for_grad(l_y_, 1);  l_y_ = None
  
          set_inplace_requires_grad_allowed = torch._C._functorch.set_inplace_requires_grad_allowed(True);  set_inplace_requires_grad_allowed = None
  
          _set_tensor_requires_grad: "f32[3, 4]" = torch._functorch.eager_transforms._set_tensor_requires_grad(diff_primals);  _set_tensor_requires_grad = None
  
          set_inplace_requires_grad_allowed_1 = torch._C._functorch.set_inplace_requires_grad_allowed(False);  set_inplace_requires_grad_allowed_1 = None
  
          primals_out: "f32[3, 4]" = diff_primals.sin()
  
          results: "f32[3, 4]" = torch._C._functorch._unwrap_for_grad(primals_out, 1)
  
          _grad_decrement_nesting = torch._C._functorch._grad_decrement_nesting();  _grad_decrement_nesting = None
          _saved_tensors_hooks_enable = torch._C._autograd._saved_tensors_hooks_enable();  _saved_tensors_hooks_enable = None
  
-         tensor: "i64[1]" = torch.tensor((12,))
+         tensor: "i64[1]" = torch.tensor((12,), device = device(type='cpu'))
?                                              +++++++++++++++++++++++++++++
          cumsum: "i64[1]" = tensor.cumsum(dim = 0);  tensor = None
          getitem: "i64[0]" = cumsum[slice(None, -1, None)];  cumsum = None
          neg: "i64[0]" = getitem.neg();  getitem = None
          unbind = neg.unbind();  neg = unbind = None
- 
          chunk: "f32[12, 12]" = results.new_zeros(12, 12);  results = None
- 
          diagonal: "f32[12]" = chunk.diagonal(0)
          fill_: "f32[12]" = diagonal.fill_(1);  diagonal = fill_ = None
- 
          basis: "f32[12, 3, 4]" = chunk.view(12, 3, 4);  chunk = None
  
          lazy_load_decompositions = torch._functorch.predispatch.lazy_load_decompositions();  lazy_load_decompositions = None
  
          _vmap_increment_nesting = torch._functorch.predispatch._vmap_increment_nesting(12, 'error');  _vmap_increment_nesting = None
  
          _add_batch_dim: "f32[3, 4]" = torch._functorch.predispatch._add_batch_dim(basis, 0, 1);  basis = None
  
          _autograd_grad = torch._functorch.eager_transforms._autograd_grad([primals_out], [diff_primals], [_add_batch_dim], retain_graph = True, create_graph = True);  primals_out = diff_primals = _add_batch_dim = None
          batched_outputs: "f32[3, 4]" = _autograd_grad[0];  _autograd_grad = None
  
          chunked_result: "f32[12, 3, 4]" = torch._functorch.predispatch._remove_batch_dim(batched_outputs, 1, 12, 0);  batched_outputs = None
  
          _vmap_decrement_nesting = torch._functorch.predispatch._vmap_decrement_nesting();  _vmap_decrement_nesting = None
  
-         split = chunked_result.split((12,), dim = 0);  chunked_result = None
?                               ^^^^^^^
+         split = torch.Tensor.split(chunked_result, (12,), dim = 0);  chunked_result = None
?                 +++++++++++++++++++              ^^
          split_1: "f32[12, 3, 4]" = split[0];  split = None
- 
          output_input: "f32[3, 4, 3, 4]" = split_1.view((3, 4, 3, 4));  split_1 = None
          return (output_input,)
 : To accept the new output, re-run test with envvar EXPECTTEST_ACCEPT=1 (we recommend staging/committing your changes before doing this)

To execute this test, run the following from the base repo dir:
    python test/dynamo/test_higher_order_ops.py FuncTorchHigherOrderOpTestsWithCompiledAutograd.test_jacrev_two_tensors_argnums

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
RAW_BUFFERClick to expand / collapse

Platforms: linux, slow

This test was disabled because it is failing in CI. See recent examples and the most recent trunk workflow logs.

Over the past 6 hours, it has been determined flaky in 45 workflow(s) with 90 failures and 45 successes.

Debugging instructions (after clicking on the recent samples link): DO NOT ASSUME THINGS ARE OKAY IF THE CI IS GREEN. We now shield flaky tests from developers so CI will thus be green but it will be harder to parse the logs. To find relevant log snippets:

  1. Click on the workflow logs linked above
  2. Click on the Test step of the job so that it is expanded. Otherwise, the grepping will not work.
  3. Grep for test_jacrev_two_tensors_argnums
  4. There should be several instances run (as flaky tests are rerun in CI) from which you can study the logs.
<details><summary>Sample error message</summary>
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/dynamo/test_higher_order_ops.py", line 4136, in test_jacrev_two_tensors_argnums
    self.assertExpectedInline(
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py", line 3387, in assertExpectedInline
    return super().assertExpectedInline(actual if isinstance(actual, str) else str(actual), expect, skip + 1)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 413, in assertExpectedInline
    assert_expected_inline(
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 378, in assert_expected_inline
    assert_eq(expect, actual, msg=help_text)
  File "/opt/conda/envs/py_3.10/lib/python3.10/site-packages/expecttest/__init__.py", line 450, in assertMultiLineEqualMaybeCppStack
    self.assertMultiLineEqual(expect, actual, *args, **kwargs)
  File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 1226, in assertMultiLineEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/opt/conda/envs/py_3.10/lib/python3.10/unittest/case.py", line 675, in fail
    raise self.failureException(msg)
AssertionError: 'clas[1606 chars](12,))\n        cumsum: "i64[1]" = tensor.cums[1693 chars],)\n' != 'clas[1606 chars](12,), device = device(type=\'cpu\'))\n       [1730 chars],)\n'
  class GraphModule(torch.nn.Module):
      def forward(self, L_x_: "f32[4, 3]", L_y_: "f32[3, 4]"):
          l_x_ = L_x_
          l_y_ = L_y_
  
          _saved_tensors_hooks_disable = torch._C._autograd._saved_tensors_hooks_disable("torch.func.{grad, vjp, jacrev, hessian} don't yet support saved tensor hooks. Please open an issue with your use case.");  _saved_tensors_hooks_disable = None
          _grad_increment_nesting = torch._C._functorch._grad_increment_nesting();  _grad_increment_nesting = None
  
          _wrap_for_grad: "f32[4, 3]" = torch._C._functorch._wrap_for_grad(l_x_, 1);  l_x_ = _wrap_for_grad = None
          diff_primals: "f32[3, 4]" = torch._C._functorch._wrap_for_grad(l_y_, 1);  l_y_ = None
  
          set_inplace_requires_grad_allowed = torch._C._functorch.set_inplace_requires_grad_allowed(True);  set_inplace_requires_grad_allowed = None
  
          _set_tensor_requires_grad: "f32[3, 4]" = torch._functorch.eager_transforms._set_tensor_requires_grad(diff_primals);  _set_tensor_requires_grad = None
  
          set_inplace_requires_grad_allowed_1 = torch._C._functorch.set_inplace_requires_grad_allowed(False);  set_inplace_requires_grad_allowed_1 = None
  
          primals_out: "f32[3, 4]" = diff_primals.sin()
  
          results: "f32[3, 4]" = torch._C._functorch._unwrap_for_grad(primals_out, 1)
  
          _grad_decrement_nesting = torch._C._functorch._grad_decrement_nesting();  _grad_decrement_nesting = None
          _saved_tensors_hooks_enable = torch._C._autograd._saved_tensors_hooks_enable();  _saved_tensors_hooks_enable = None
  
-         tensor: "i64[1]" = torch.tensor((12,))
+         tensor: "i64[1]" = torch.tensor((12,), device = device(type='cpu'))
?                                              +++++++++++++++++++++++++++++
          cumsum: "i64[1]" = tensor.cumsum(dim = 0);  tensor = None
          getitem: "i64[0]" = cumsum[slice(None, -1, None)];  cumsum = None
          neg: "i64[0]" = getitem.neg();  getitem = None
          unbind = neg.unbind();  neg = unbind = None
- 
          chunk: "f32[12, 12]" = results.new_zeros(12, 12);  results = None
- 
          diagonal: "f32[12]" = chunk.diagonal(0)
          fill_: "f32[12]" = diagonal.fill_(1);  diagonal = fill_ = None
- 
          basis: "f32[12, 3, 4]" = chunk.view(12, 3, 4);  chunk = None
  
          lazy_load_decompositions = torch._functorch.predispatch.lazy_load_decompositions();  lazy_load_decompositions = None
  
          _vmap_increment_nesting = torch._functorch.predispatch._vmap_increment_nesting(12, 'error');  _vmap_increment_nesting = None
  
          _add_batch_dim: "f32[3, 4]" = torch._functorch.predispatch._add_batch_dim(basis, 0, 1);  basis = None
  
          _autograd_grad = torch._functorch.eager_transforms._autograd_grad([primals_out], [diff_primals], [_add_batch_dim], retain_graph = True, create_graph = True);  primals_out = diff_primals = _add_batch_dim = None
          batched_outputs: "f32[3, 4]" = _autograd_grad[0];  _autograd_grad = None
  
          chunked_result: "f32[12, 3, 4]" = torch._functorch.predispatch._remove_batch_dim(batched_outputs, 1, 12, 0);  batched_outputs = None
  
          _vmap_decrement_nesting = torch._functorch.predispatch._vmap_decrement_nesting();  _vmap_decrement_nesting = None
  
-         split = chunked_result.split((12,), dim = 0);  chunked_result = None
?                               ^^^^^^^
+         split = torch.Tensor.split(chunked_result, (12,), dim = 0);  chunked_result = None
?                 +++++++++++++++++++              ^^
          split_1: "f32[12, 3, 4]" = split[0];  split = None
- 
          output_input: "f32[3, 4, 3, 4]" = split_1.view((3, 4, 3, 4));  split_1 = None
          return (output_input,)
 : To accept the new output, re-run test with envvar EXPECTTEST_ACCEPT=1 (we recommend staging/committing your changes before doing this)

To execute this test, run the following from the base repo dir:
    python test/dynamo/test_higher_order_ops.py FuncTorchHigherOrderOpTestsWithCompiledAutograd.test_jacrev_two_tensors_argnums

This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
</details>

Test file path: inductor/test_compiled_autograd.py

For all disabled tests (by GitHub issue), see https://hud.pytorch.org/disabled.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

extent analysis

TL;DR

The most likely fix for the failing test is to update the tensor creation to include the device specification, as indicated by the error message.

Guidance

  • Review the error message and the provided code snippet to understand the failure point, specifically the difference in tensor creation with and without device specification.
  • Investigate why the test is failing on the CI environment but not locally, considering factors like environment variables, dependencies, or hardware differences.
  • To mitigate the issue, try running the test with the EXPECTTEST_ACCEPT=1 environment variable to accept the new output, but ensure to stage and commit changes before doing so.
  • Verify the fix by re-running the test and checking the output for any discrepancies.

Example

No explicit code example is provided due to the complexity of the issue and the need for a thorough understanding of the PyTorch framework and the specific test case.

Notes

The provided information lacks specific details about the environment, dependencies, or potential conflicts that might be causing the test to fail. Further investigation into the CI environment, test setup, and PyTorch version is necessary to determine the root cause.

Recommendation

Apply the workaround by accepting the new output with EXPECTTEST_ACCEPT=1 and then investigate the cause of the discrepancy in tensor creation to apply a permanent fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING