Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in tests with TF #195

Closed
gomezzz opened this issue Dec 6, 2023 · 4 comments · Fixed by #197
Closed

Regression in tests with TF #195

gomezzz opened this issue Dec 6, 2023 · 4 comments · Fixed by #197
Labels
bug Something isn't working tests Related to the tests

Comments

@gomezzz
Copy link
Collaborator

gomezzz commented Dec 6, 2023

Issue

Problem Description

Boole test fails with

 =========================== short test summary info ============================
FAILED boole_test.py::test_integrate_tensorflow - tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: in user code:

    File "/home/runner/work/torchquad/torchquad/torchquad/tests/../integration/grid_integrator.py", line 131, in calculate_grid  *
        grid = IntegrationGrid(
    File "/home/runner/work/torchquad/torchquad/torchquad/tests/../integration/integration_grid.py", line 44, in __init__  **
        self._check_inputs(N, integration_domain, disable_integration_domain_check)
    File "/home/runner/work/torchquad/torchquad/torchquad/tests/../integration/integration_grid.py", line 114, in _check_inputs
        dim = _check_integration_domain(integration_domain)
    File "/home/runner/work/torchquad/torchquad/torchquad/tests/../integration/utils.py", line 209, in _check_integration_domain
        if boundaries_are_invalid:

OperatorNotAllowedInGraphError: Using a symbolic `tf.Tensor` as a Python `bool` is not allowed. You can attempt the following resolutions to the problem: If you are running in Graph mode, use Eager execution mode or decorate this function with @tf.function. If you are using AutoGraph, you can try decorating this function with @tf.function. If that does not work, then you may be using an unsupported feature or your source code may not be visible to AutoGraph. See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/autograph/g3doc/reference/limitations.md#access-to-source-code for more information.
============= 1 failed, 51 passed, 75 warnings in 78.24s (0:01:18) =============
Error: Process completed with exit code 1.

Expected Behavior

Test passing :)

What Needs to be Done

Not quite sure, @FHof do you have an idea maybe? Decorating the entire is probably not possible given that requires tf install?

How Can It Be Tested or Reproduced

Running boole test with TF.

@gomezzz gomezzz added bug Something isn't working tests Related to the tests labels Dec 6, 2023
@FHof
Copy link
Collaborator

FHof commented Dec 8, 2023

It fails in _check_integration_domain, which validates that the user has passed a valid integration domain.
Checking that the domain has a positive size in each dimension does not work with trace compilation, so the check is disabled in this case.
To determine if the code is currently compiled, the type of boundaries_are_invalid is investigated; if it is (before TensorFlow 2.14.0) tf.Tensor and not tf.Variable or something different, the code is currently being compiled.
If I remember correctly, I have implemented it this way because I could not find a clean way to check if the code is currently being compiled or not.

According to the CI log, the test has worked with TensorFlow 2.13.1 and now it fails with TensorFlow 2.14.0.
It fails now because with a recent TensorFlow version, the type is tf.SymbolicTensor and not tf.Tensor.
This breaking change is mentioned in TensorFlow's release notes.

I suggest to abstract away the check if code is currently compiled into a helper function.
For the TensorFlow backend, the function could use tf.is_symbolic_tensor for TensorFlow >= 2.13.0 and the check if the type is tf.Tensor for older TensorFlow versions.

@FHof
Copy link
Collaborator

FHof commented Dec 25, 2023

I have implemented the helper function in #197

@gomezzz
Copy link
Collaborator Author

gomezzz commented Dec 29, 2023

Thank you for the help! I appreciate it. Would probably take me forever to understand the cross-module wizardry that is happening now :D

@FHof
Copy link
Collaborator

FHof commented Jan 1, 2024

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests Related to the tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants