CompositeLikelihood subsets have data-dependent shapes and cannot compile under JAX

Aperta
#67 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Jupyter Notebook
Stelle
15
Fork
5
Merge medio
2g 10h
PR unite (30g)
5

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pymc-devs/ptgp

Tutte le issue di pymc-devs/ptgp

Issue simili

Altre issue su Machine Learning

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.