Skip to content

Tensorflow Probability fatally crashes with Jax 0.7 #1994

Closed

Description

@NeilGirdhar
.venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/ops.py:681
  /home/neil/src/efax/.venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/ops.py:681: DeprecationWarning: jax.interpreters.xla.pytype_aval_mappings is deprecated.

Activity

  1. NeilGirdhar commented on Apr 17, 2025

    @NeilGirdhar
    ContributorAuthor

    @jakevdp Would it be better to skip this code entirely when Jax's version >= 0.5?

  2. jakevdp commented on Apr 17, 2025

    @jakevdp
    Contributor

    Yes, you should probably skip. As of 0.5.0, jax.interpreters.xla.pytype_aval_mappings and jax.core.pytype_aval_mappings point to the same object, though the first reference is deprecated. Eventually the first reference will be removed and only jax.core.pytype_aval_mappings will remain.

  3. NeilGirdhar commented on Apr 18, 2025

    @NeilGirdhar
    ContributorAuthor

    Got it, just wanted to eliminate the warning.

  4. NeilGirdhar commented on Jul 22, 2025

    @NeilGirdhar
    ContributorAuthor

    This is just crashing now:

    .venv/lib/python3.13/site-packages/efax/_src/tools.py:84: in <module>
        iv_ratio = tfp.math.bessel_iv_ratio
                   ^^^^^^^^
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/lazy_loader.py:56: in __getattr__
        module = self._load()
                 ^^^^^^^^^^^^
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/lazy_loader.py:43: in _load
        module = importlib.import_module(self.__name__)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    .venv/lib/python3.13/site-packages/tensorflow_probability/substrates/jax/__init__.py:42: in <module>
        from tensorflow_probability.substrates.jax import bijectors
    .venv/lib/python3.13/site-packages/tensorflow_probability/substrates/jax/bijectors/__init__.py:19: in <module>
        from tensorflow_probability.substrates.jax.bijectors.absolute_value import AbsoluteValue
    .venv/lib/python3.13/site-packages/tensorflow_probability/substrates/jax/bijectors/absolute_value.py:17: in <module>
        from tensorflow_probability.python.internal.backend.jax.compat import v2 as tf
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/__init__.py:19: in <module>
        from tensorflow_probability.python.internal.backend.jax import compat
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/compat.py:17: in <module>
        from tensorflow_probability.python.internal.backend.jax import v1
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/v1.py:23: in <module>
        from tensorflow_probability.python.internal.backend.jax import linalg_impl
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/linalg_impl.py:23: in <module>
        from tensorflow_probability.python.internal.backend.jax import ops
    .venv/lib/python3.13/site-packages/tensorflow_probability/python/internal/backend/jax/ops.py:681: in <module>
        jax.interpreters.xla.pytype_aval_mappings[onp.ndarray])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    .venv/lib/python3.13/site-packages/jax/_src/deprecations.py:54: in getattr
        raise AttributeError(message)
    E   AttributeError: jax.interpreters.xla.pytype_aval_mappings was deprecated in JAX v0.5.0 and removed in JAX v0.7.0. jax.core.pytype_aval_mappings can be used as a replacement in most cases.
    

    Can we please change the code from an attribute check to a Jax version check?

      if hasattr(jax.interpreters.xla, 'pytype_aval_mappings'):
        # Deprecated in JAX v0.5.0
        jax.interpreters.xla.pytype_aval_mappings[NumpyVariable] = (
            jax.interpreters.xla.pytype_aval_mappings[onp.ndarray])
      jax.core.pytype_aval_mappings[NumpyVariable] = (
          jax.core.pytype_aval_mappings[onp.ndarray])

    Also, given that the package is effectively incompatible with latest Jax, could we get another release too?

  5. jakevdp commented on Jul 22, 2025

    @jakevdp
    Contributor

    I'm confused as to how this error is arising: with JAX v0.7.0 locally I see this:

    >>> import jax
    >>> hasattr(jax.interpreters.xla, 'pytype_aval_mappings')
    False

    Why is the if statement evaluating to True in your case?

  6. NeilGirdhar commented on Jul 23, 2025

    @NeilGirdhar
    ContributorAuthor

    It's also False for me. You can test out my exact setup by pulling NeilGirdhar/efax, then doing uv lock -U and uv sync. Then the error turns up with pytest.

  7. jakevdp commented on Jul 23, 2025

    @jakevdp
    Contributor

    Alright, hopefully the TFP maintainers can sort this out. From the JAX point of view, things are behaving as expected (the deprecated symbol raised a DeprecationWarning starting in v0.5, and now raises an AttributeError starting in v0.7).

  8. changed the title [-]jax.interpreters.xla.pytype_aval_mappings is deprecated[/-] [+]Tensorflow Probability fatally crashes with Jax 0.7[/+] on Jul 23, 2025
  9. NeilGirdhar commented on Jul 23, 2025

    @NeilGirdhar
    ContributorAuthor

    @SiegeLordEx Can you take a look at this? Tensorflow Probability seemst to be broken.

  10. jburnim commented on Jul 23, 2025

    @jburnim
    Member

    What versions of TFP and JAX are you using?

  11. jakevdp commented on Jul 23, 2025

    @jakevdp
    Contributor

    Oh I see: the hasattr(jax.interpreters.xla, 'pytype_aval_mappings') check is in at HEAD, but is not part of the most recent release (v0.25.0, released November 2024). Fixing this will require a new TFP release.

    @jburnim I can reproduce this with JAX v0.7.0 and TFP v0.25.0:

    import jax
    import tensorflow_probability
    print(f"{jax.__version__=}")
    print(f"{tensorflow_probability.__version__=}")
    jax.__version__='0.7.0'
    tensorflow_probability.__version__='0.25.0'
    
    from tensorflow_probability.substrates import jax as tfp
    tfp.math
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    [/tmp/ipython-input-7-2785852718.py](https://localhost:8080/#) in <cell line: 0>()
          1 from tensorflow_probability.substrates import jax as tfp
    ----> 2 tfp.math
    
    ...
    
    [/usr/local/lib/python3.11/dist-packages/jax/_src/deprecations.py](https://localhost:8080/#) in getattr(name)
         52       message, fn = deprecations[name]
         53       if fn is None:  # Is the deprecation accelerated?
    ---> 54         raise AttributeError(message)
         55       warnings.warn(message, DeprecationWarning, stacklevel=2)
         56       return fn
    
    AttributeError: jax.interpreters.xla.pytype_aval_mappings was deprecated in JAX v0.5.0 and removed in JAX v0.7.0. jax.core.pytype_aval_mappings can be used as a replacement in most cases.

    Using tfp-nightly, the error does not occur.

  12. jburnim commented on Jul 23, 2025

    @jburnim
    Member

    Someone from the TensorFlow Probability team can confirm, but I think everything is working as expected here.

    TFP 0.25.0 is intended to work with JAX 0.4.35 -- see https://github.com/tensorflow/probability/releases/tag/v0.25.0 . Stable releases of TFP often work with later releases of JAX, but this is not guaranteed.

    TFP nightly is intended to work with the latest JAX release.

  13. NeilGirdhar commented on Jul 23, 2025

    @NeilGirdhar
    ContributorAuthor

    @jburnim Thanks for explaining! It’s a bit tough for users right now having to choose between older JAX versions or unstable TFP nightlies. Since dependency tools (like uv) don’t handle this automatically, it means extra hassle and manual work. A stable TFP release that supports the latest JAX would really make things easier and help everyone keep up without headaches 😄

  14. NeilGirdhar commented on Jul 23, 2025

    @NeilGirdhar
    ContributorAuthor

    @jakevdp Sorry for the basic question, but how do you use tfp-nightly?

    ❯ uv pip freeze | rg tfp-nightly
    tfp-nightly==0.26.0.dev20250723
    ❯ python
    Python 3.13.5 (main, Jun 12 2025, 12:40:22) [Clang 20.1.4 ] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow_probability
    Traceback (most recent call last):
      File "<python-input-0>", line 1, in <module>
        import tensorflow_probability
    ModuleNotFoundError: No module named 'tensorflow_probability'
    ❯ batcat .venv/lib/python3.13/site-packages/tfp_nightly-0.26.0.dev20250723.dist-info/top_level.txt 
    ───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
           │ File: .venv/lib/python3.13/site-packages/tfp_nightly-0.26.0.dev20250723.dist-info/top_level.txt
    ───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       1   │ tensorflow_probability
    ───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    
  15. jakevdp commented on Jul 23, 2025

    @jakevdp
    Contributor

    I did pip install tfp-nightly and then import tensorflow_probability.

  16. jobrachem commented on Jul 28, 2025

    @jobrachem

    Is there a timeline for the next tfp release that will include the fix for this issue?

  17. csuter commented on Jul 28, 2025

    @csuter
    Member

    For TFP on JAX I would strongly advise using tfp-nightly. It's tested continuously against the latest JAX, and you can pin to a particular date's release if you need your dependencies to remain fixed.

    The stable-vs-nightly distinction in TFP has grown anachronistic, at least as far as JAX users are concerned. Historically "stable" versioning has been tied to TF releases, which are immaterial to JAXers. I would suggest picking a nightly build, pinning to it, and updating that as you see fit, perhaps as new JAX builds are published.

  18. jobrachem commented on Jul 29, 2025

    @jobrachem

    Thank you @csuter ! We will try that approach.

  19. csuter commented on Jul 29, 2025

    @csuter
    Member

    Thanks, @jobrachem. Please do let us know if you have any trouble.

  20. added a commit that references this issue on Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions