pytorch - 💡(How to fix) Fix DISABLED test_autograd_function_no_setup_context_transform_grad_cpu (__main__.TestComposabilityCPU) [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#180634Fetched 2026-04-17 08:25:52
View on GitHub
Comments
2
Participants
1
Timeline
27
Reactions
0
Participants
Timeline (top)
mentioned ×10subscribed ×10labeled ×5commented ×2

Error Message

torch._dynamo.exc.TorchRuntimeError: RuntimeError when making fake tensor call Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value= FakeTensor(..., size=(3,)) ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ') Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the torch.compile call, or by using torch.compiler.set_stance("force_eager").

Developer debug context:

For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code: File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl results = grad_and_value_impl(func, argnums, has_aux, args, kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn return f(*args, **kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl output = func(*args, **kwargs) File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3780, in test_autograd_function_no_setup_context class MySin(torch.autograd.Function): File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3780 with self.assertRaisesRegex(RuntimeError, "must override the setup_context"): File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3793 with self.assertRaisesRegex(RuntimeError, "must override the setup_context"): ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 285, in exit self._raiseFailure('"{}" does not match "{}"'.format( ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected_regex.pattern, str(exc_value))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 209, in _raiseFailure raise self.test_case.failureException(msg) AssertionError: "must override the setup_context" does not match "RuntimeError when making fake tensor call Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value= FakeTensor(..., size=(3,)) ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ') Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the torch.compile call, or by using torch.compiler.set_stance("force_eager").

Developer debug context:

For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code: File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl results = grad_and_value_impl(func, argnums, has_aux, args, kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn return f(*args, **kwargs) File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl output = func(*args, **kwargs) File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo" "

To execute this test, run the following from the base repo dir: PYTORCH_TEST_WITH_DYNAMO=1 python test/functorch/test_eager_transforms.py TestComposabilityCPU.test_autograd_function_no_setup_context_transform_grad_cpu

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.

Code Example

torch._dynamo.exc.TorchRuntimeError: RuntimeError when making fake tensor call
  Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value=
        FakeTensor(..., size=(3,))
    ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ')
  Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the `torch.compile` call, or by using `torch.compiler.set_stance("force_eager")`. 

  Developer debug context: 

 For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper
    return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl
    results = grad_and_value_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn
    return f(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl
    output = func(*args, **kwargs)
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward
    return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3780, in test_autograd_function_no_setup_context
    class MySin(torch.autograd.Function):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3780
    with self.assertRaisesRegex(RuntimeError, "must override the setup_context"):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3793
    with self.assertRaisesRegex(RuntimeError, "must override the setup_context"):
         ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 285, in __exit__
    self._raiseFailure('"{}" does not match "{}"'.format(
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             expected_regex.pattern, str(exc_value)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 209, in _raiseFailure
    raise self.test_case.failureException(msg)
AssertionError: "must override the setup_context" does not match "RuntimeError when making fake tensor call
  Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value=
        FakeTensor(..., size=(3,))
    ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ')
  Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the `torch.compile` call, or by using `torch.compiler.set_stance("force_eager")`. 

  Developer debug context: 

 For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper
    return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl
    results = grad_and_value_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn
    return f(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl
    output = func(*args, **kwargs)
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward
    return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
"

To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/functorch/test_eager_transforms.py TestComposabilityCPU.test_autograd_function_no_setup_context_transform_grad_cpu

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

Platforms: dynamo

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 5 workflow(s) with 5 failures and 5 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_autograd_function_no_setup_context_transform_grad_cpu
  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>
torch._dynamo.exc.TorchRuntimeError: RuntimeError when making fake tensor call
  Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value=
        FakeTensor(..., size=(3,))
    ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ')
  Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the `torch.compile` call, or by using `torch.compiler.set_stance("force_eager")`. 

  Developer debug context: 

 For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper
    return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl
    results = grad_and_value_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn
    return f(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl
    output = func(*args, **kwargs)
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward
    return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3780, in test_autograd_function_no_setup_context
    class MySin(torch.autograd.Function):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3780
    with self.assertRaisesRegex(RuntimeError, "must override the setup_context"):
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3793, in torch_dynamo_resume_in_test_autograd_function_no_setup_context_at_3793
    with self.assertRaisesRegex(RuntimeError, "must override the setup_context"):
         ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 285, in __exit__
    self._raiseFailure('"{}" does not match "{}"'.format(
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             expected_regex.pattern, str(exc_value)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/py_3.14/lib/python3.14t/unittest/case.py", line 209, in _raiseFailure
    raise self.test_case.failureException(msg)
AssertionError: "must override the setup_context" does not match "RuntimeError when making fake tensor call
  Explanation: Dynamo failed to run FX node with fake tensors: call_method sin(*(GradTrackingTensor(lvl=1, value=
        FakeTensor(..., size=(3,))
    ),), **{}): got RuntimeError('tls_on_entry.has_value() INTERNAL ASSERT FAILED at "/var/lib/jenkins/workspace/aten/src/ATen/core/PythonFallbackKernel.cpp":53, please report a bug to PyTorch. ')
  Hint: Your code may result in an error when running in eager. Please double check that your code doesn't contain a similar error when actually running eager/uncompiled. You can do this by removing the `torch.compile` call, or by using `torch.compiler.set_stance("force_eager")`. 

  Developer debug context: 

 For more details about this graph break, please visit: https://meta-pytorch.github.io/compile-graph-break-site/gb/gb4315.html

from user code:
   File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/apis.py", line 433, in wrapper
    return eager_transforms.grad_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1533, in grad_impl
    results = grad_and_value_impl(func, argnums, has_aux, args, kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/vmap.py", line 56, in fn
    return f(*args, **kwargs)
  File "/opt/conda/envs/py_3.14/lib/python3.14t/site-packages/torch/_functorch/eager_transforms.py", line 1484, in grad_and_value_impl
    output = func(*args, **kwargs)
  File "/var/lib/jenkins/workspace/test/functorch/test_eager_transforms.py", line 3784, in forward
    return x.sin()

Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
"

To execute this test, run the following from the base repo dir:
    PYTORCH_TEST_WITH_DYNAMO=1 python test/functorch/test_eager_transforms.py TestComposabilityCPU.test_autograd_function_no_setup_context_transform_grad_cpu

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

Test file path: functorch/test_eager_transforms.py

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

cc @chauhang @penguinwu @Chillee @samdow @kshitij12345

extent analysis

TL;DR

The most likely fix for the failing test is to modify the test to handle the RuntimeError exception correctly, possibly by overriding the setup_context method or by using torch.compiler.set_stance("force_eager").

Guidance

  • Review the test code in functorch/test_eager_transforms.py to ensure it correctly handles the RuntimeError exception.
  • Consider overriding the setup_context method in the MySin class to fix the error.
  • Try using torch.compiler.set_stance("force_eager") to run the test in eager mode and see if the error persists.
  • Check the PyTorch documentation and the provided links for more information on debugging and fixing the issue.
  • Run the test with TORCHDYNAMO_VERBOSE=1 and TORCH_LOGS="+dynamo" to get more detailed error messages and internal stack traces.

Example

# Example of using torch.compiler.set_stance("force_eager")
import torch
torch.compiler.set_stance("force_eager")

Notes

The error message suggests that the test is failing due to a RuntimeError exception when running in compiled mode. The provided links and documentation may help in debugging and fixing the issue. However, without more information about the test code and the expected behavior, it is difficult to provide a more specific solution.

Recommendation

Apply the workaround by using torch.compiler.set_stance("force_eager") to run the test in eager mode, as this may help to identify and fix the underlying issue.

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