-
Notifications
You must be signed in to change notification settings - Fork 52
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
Implementing Numpy and JAX substrates using exoplanet-core #132
base: main
Are you sure you want to change the base?
Conversation
There was some discussion on Twitter and elsewhere about the interface for this change. Here's my summary: My original proposal: import exoplanet.pymc as xo
# and
import exoplanet.jax as xo
# and
import exoplanet.numpy as xo was met with some criticism because it seems like exoplanet now exports, for example,
Some other options include:
Finally, there was also some words of warning from @twiecki that supporting multiple backends might not be worth it, but this isn't quite the whole story here because of the general design of It's also worth noting that there are plans to migrate PyMC to a JAX backend which means that it was going to be necessary to implement JAX-compatible XLA ops for all of the exoplanet code anyways. My proposed APII think that, in the short term, PyMC (perhaps implicitly with JAX used behind the scenes) will still be the primary interface, so I think that supporting import exoplanet.substrates.jax as xo or the word import exoplanet.interfaces.jax as xo since the goal is not quite the same as TFP's substrates. This still has the issue that it's strange to export modules called |
I don't see Re your "other option 2": do these interfaces only need to be accessed inside a with lib.Model() as model:
xo = exoplanet.api(model)
... You could maybe offer a convenience wrapper to save a line with exoplanet.Model(lib) as (xo, model):
... |
Looks like a great proposal but I guess I would still ask what the benefit to the user is, or whether you've gotten requests from users for this. Bambi supported stan and pymc3 because the authors thought it would be good to let the user switch between them but it really made no difference, you still specified your model in the same way and got the same answers. A lot of developer and code complexity was spent on it which could have been spent on improving UX, adding features, documentation etc. Now there were 2 areas of bugs and things to support, all new features needed to be implemented for both backends, so dev velocity was severely negatively affected. So while it might be cool, I would still think carefully about the cost-benefit-tradeoff. |
@jedbrown: Good point about namespaces! I'll think a little more about that part. For PyMC, your proposed model context interface would work, but it's definitely trickier in other cases. For example, numpyro and emcee, two use cases that I want to support, both use different model syntax. But the @twiecki: I totally agree that it's not obvious and that it's important to do the cost-benefit analysis! I do get lots of requests for the numpy API because there are lots of use cases where the Theano dependency and model compilation overhead are not beneficial. In fact, I'd already implemented a subset of the API bypassing Theano/PyMC entirely. As for JAX, that's just for me so far, but (in my opinion) I'm my most important customer so I think it's worth it for now :D. I think I'm going to push forward with this while making sure that I market the PyMC interface as the stable one. As I said, the JAX ops are necessary (and I'm already getting some nice benefits out of them, more soon!) but a full API implementation is just the cherry on top so I agree that I should be careful about promising too much! Thanks, both, for the feedback! |
@dfm Sounds good 👍, excited for the JAX backend! |
This is a big one and it'll be nice when it's finished!
To do: