Should support for TensorFlow be dropped given its library anti-patterns? #1595
Replies: 8 comments 15 replies
-
I don't have direct experience with TensorFlow, but if what you say is true, that's a good thing to know and to be wary of in other HEP projects. I remember that zfit once relied heavily on TensorFlow, but I don't know if it still does. @jonas-eschle, what is your take on the usability of TensorFlow as a library, for HEP? Is it getting more application-like than library-like? |
Beta Was this translation helpful? Give feedback.
-
A current example for the consequences of the restrictive dependency pinning in pip install black tensorflow tensorflow-probability will first install import tensorflow, tensorflow_probability will fail with
This combination of packages comes up for example with |
Beta Was this translation helpful? Give feedback.
-
Hey, that is indeed a good discussion and a thought worth. We do in zfit still mainly rely on TensorFlow, however, it is also compatible with other libraries (because we use TF and not e.g. JAX). Let me elaborate, it's a somewhat love-hate relationship with TF having a few (annoying) drawbacks but, AFAIU, TF still being the most powerful library for computations in HEP. First, comparing to alternatives, we can neglect numba (as having a quite different concept of compiling, not tracing) and looking at jit-traceable, autograd supporting libraries (JAX, torch,...). About the performance and graph: I had a brief look at it and it seems (AFAI see) that pyhf does not really jit TF? Since TF 2 the computational model completely changed. It's not a graph anymore (technically, but implementation detail) but a jittable library like JAX. Like jax, it actually supports XLA. I think in pyhf this is always eager, no jitting, and also no xla therefore ( I did a preliminary test using the benchmarks and TF is exactly at the same speed as JAX and torch. Now for TensorFlow: Disadvantages:
Mixed:
Advantages, mainly compared to JAX:
Advantages, mainly compared to PyTorch:
Conclusion TF for HEP TF is not the perfect library for HEP, indeed. But it seems to me still the most capable library around, with advantages (such as unknown shape handling) that are crucial. I hope and assume that JAX one day will be superior. The current disadvantages are mostly of package technical nature. Given also it's recent switch to a completely new model, the whole package seems to be stabilizing. But yes, it's big and feels somewhat intrusive. This is why I think it's still very capable for HEP in general, including zfit. TF for pyhf The packaging can really increase the burden for no reason. I think that a swappable backend is nice, but more of an implementation detail (it means a library needs to restrict itself to the subset of all common features, effectively removing features). The more important aspect to me seems to be interoperable with the rest. And as pyhf has the advantage of needing only this subset, having static shapes, I think this is very reasonable. I would suggest to go along the lines @matthewfeickert proposed:
So summarized, I think TF is still the most capable library around for speedy computations, but big and slow moving. I would keep it in general, but not at the cost of not being able to install other packages |
Beta Was this translation helpful? Give feedback.
-
Currently working on untentangling this mess but progress is unfortunately slow (devinfra team severely reduced, cleaning up the mess not being considered a promotion worthy project, so very few takers for these; then issues with internal Google monorepo + single versioning policy) |
Beta Was this translation helpful? Give feedback.
-
TF should now have a better setup.py |
Beta Was this translation helpful? Give feedback.
-
Similar problematic behavior is unfortunately continuing with tensorflow/probability#1723 |
Beta Was this translation helpful? Give feedback.
-
TensorFlow |
Beta Was this translation helpful? Give feedback.
-
c.f. tensorflow/probability#1795 and PR #2452. A reminder that |
Beta Was this translation helpful? Give feedback.
-
TensorFlow is continually becoming a burden to support and is arguably slowing down project development given library development anti-patterns like tensorflow/tensorflow#40789 and tensorflow/tensorflow#51743 where dependencies are being pinned down to the patch level. At this point, TensorFlow is not a Python library — it is a Python application that you have to build your project around. That's fine, but it means that we can't effectively treat
pyhf
as a Python library then if we want to provide support across all backends.I see two ways forward:
pyhf
releasev0.7.0
.backends
extra and keep it as atensorflow
extratensorflow
extra in a fully different workflow and say that we will support a particular minor release of TensorFlow and TensorFlow Probability for a particular release cycle ofpyhf
.TensorFlow is already the slowest backend that
pyhf
has and it is probably because we haven't optimizedpyhf
around its graph options. My guess is that no on usingpyhf
is actually using the TensorFlow backend anyway and is using JAX instead. I'm not sure that given the goals of use thatpyhf
has in terms of particle physics if there is any advantage to continuing support for TensorFlow. My inclination is to drop it, but I'm curious what others think.cc @lukasheinrich @kratsg @alexander-held @jpivarski @henryiii @eduardo-rodrigues
Beta Was this translation helpful? Give feedback.
All reactions