VNT: VarInfo mop-up

Aperta
#1,201 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

  • #1468 di @yebai — chiusa senza merge

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
julia

Direzione di ricerca

Inizia dallo script di benchmarking collegato da PR #1183 ed esamina l’implementazione attuale di VarInfo e la suite di benchmark. Determina quali casi di benchmark possono essere incorporati, quindi valuta gli elementi di vettorializzazione e pulizia ancora non spuntati. Il lavoro è completo quando i benchmark selezionati sono integrati e qualsiasi ambito rimanente è stato risolto o suddiviso in issue mirate.

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

Descrizione

data-structures enhancement

Due to time constraints on my part, and to avoid ballooning the PR, we are merging #1183 into its base branch (though not breaking) even though some issues remain. Listing those issues here:

  • unflatten!! and link!! remain surprisingly slow for models that have IndexLenses. I spent an hour on this but failed to understand why. I tried improving type stability within those functions by getting rid of some closures, and I also improved extract_priors that link!! uses, but they weren't the culprit. I think this warrants more careful profiling. (Edit: Both functions are significantly faster, often by over 10x.)
  • merge could be optimised to not revert to Linked=nothing so easily. This probably warrants writing a function to check the link status of all variables and use that to set Linked. (A bit like concretise_eltype in a way.)
  • Try removing all or some of the @inbounds annotations and see how they affect performance. See https://github.com/TuringLang/DynamicPPL.jl/pull/1183#issuecomment-3755257644.
  • keys could be made it faster. Not a priority. (Edit: keys is 2-10x faster than when this issue was written.)
  • subset could be made faster, see the comment in it. It's already faster than the old version in most cases though, so not a priority. (Edit: subset is 1-2x faster than when this issue was written.)
  • See the benchmarking script I wrote and see if some of it could feed into our benchmark suite.
  • Check that AD performance is fine. I've been benchmarking primal evals so far. I don't expect anything to go wrong there, but should do a quick check.
  • Reimplement Base.rand(::Model) using a VAIMAcc, and make it return a VNT. That will allow removing values_as(::VarInfo, ::NamedTuple), which shouldn't exist.
  • Once the performance optimisations are all done, add a note in HISTORY.md for what's changed performance-wise. There's a placeholder in there already.

There are also bigger issues that might not make it to this release, and probably deserve their own issues:

  • Stop vectorising all values in VarInfo, now that the backend storage no longer requires it.
  • Stop storing transform in VarInfo. We almost always pull the transform from the distribution in tilde_assume!! anyway, because the stored transform may be out of date. Safer to not even store it, and makes type stability easier because linking doesn't have to change the type of TransformedValue anymore.
  • The above will also allow to get rid of some dangerous functions like unflatten!! and values_as(::VarInfo, ::Colon).
  • Start using shadow arrays, see #1194
  • Reimplement StaticTransformation. It was a bit broken/risky, and now it's broken/risky in a slightly different way. See comments in the function.
Lingua principale
Julia
Stelle
291
Fork
43
Merge medio
1g 23h
PR unite (30g)
15

Preparare l'ambiente

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 TuringLang/DynamicPPL.jl

Tutte le issue di TuringLang/DynamicPPL.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.