probcomp / Gen.jl

A general-purpose probabilistic programming system with programmable inference
https://gen.dev
Apache License 2.0
1.79k stars 160 forks source link

[Proposal] Adding an optional serialization dependency. #519

Open limarta opened 7 months ago

limarta commented 7 months ago

GenSerialization.jl serves to serialize the common trace types offered by Gen.

Why? Direct serialization using Julia's native serialize function does not properly save ephemeral (e.g. generative function pointers) as pointed out in #129. Users who intend to save out traces for long term storage will necessarily restart the Julia runtime, so there is no guarantee that runtime data will properly be read back in. Given a saved out trace, there are two ways to read data back in. The first requires the generative function to reconstruct the function pointers, and #369 takes a similar strategy and implicitly invokes the generative function while reading. The second amortizes the generative function call over calls to the GFI such as update and regenerate. In the package, we distinguish the two by realize and deserialize respectively.

Goals:

Caveats:

WIP