CompositeLikelihood subsets have data-dependent shapes and cannot compile under JAX
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
The problem is in CompositeLikelihood, which selects each row's sub-likelihood with nonzero(group == k), producing data-dependent shapes that JAX cannot compile. Start by reproducing the failure: build a model using CompositeLikelihood and compile it with mode="JAX". The issue leaves the fix open, so agreeing on an approach with the maintainers comes first. Done means the model compiles under JAX and its predictions match the C and Numba backends.
Written by the indexing model from the issue text.
Description
CompositeLikelihood (#42, being ported onto the likelihood-graph design from #50) picks each observation's sub-likelihood from group labels computed from the inputs, e.g. group=X[:, kind_col]. Each evaluation selects the rows of group k with nonzero(group == k), whose length depends on the data. The C and Numba backends handle this, but JAX needs static shapes, so a model using CompositeLikelihood will not compile with mode="JAX".
A possible fix is to evaluate every sub-likelihood on every row and keep each row's own term with switch(group == k, value_k, 0). Shapes stay static, at K times the work. Rows outside a sub-likelihood's support can produce inf or NaN values whose gradients become NaN even where masked, so the inputs of masked rows need to be replaced with safe values before evaluation (the "double where" pattern).
This is just a guess at a fix. Numba works fine. Open to other options for fixing this. Only hits someone doing prediction with a CompositeLilkelihood using JAX.
- Dominant language
- Jupyter Notebook
- Stars
- 16
- Forks
- 5
- Avg merge
- 2d 49m
- Merged PRs (30d)
- 6
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pymc-devs/ptgp
-
Expose and document VGP variational parameters for fit diagnosticsPossibly taken @bwengals claimed this 58 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Add VGP: variational Gaussian inference for non-Gaussian likelihoods without inducing pointsPossibly taken @bwengals claimed this 156 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
pymc
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timePossibly taken @PabloRoque claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
pymc-devs/pymc-extras#839 ·
Maintainers usually reply within 1 day
-
[Bug]: MLX text downloads omit the requested Hub token and cache directoryPossibly taken @abhijithneilabraham claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/vllm-metal#1423 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
CyberTimon/RapidRAW#2303 ·
Maintainers usually reply within 1 day
-
area:asr good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
dmunasingha/lingo-overlay#13 ·
-
wave-followup
Difficulty 2/5 1-3 hours Newbie friendliness 79/100