-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from probcomp/ian/serialization
Add serialization for Gen Dynamic DSL traces and some combinators
- Loading branch information
Showing
36 changed files
with
2,097 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.0' | ||
- '1.9' | ||
- '1.10' | ||
- 'nightly' | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
# GenSerialization | ||
# GenSerialization.jl | ||
|
||
[![Build Status](https://github.com/limarta/GenSerialization.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/limarta/GenSerialization.jl/actions/workflows/CI.yml?query=branch%3Amain) | ||
WIP tool to serialize Gen.jl traces using Julia's `serialization` library. Gen.jl traces often contain ephemeral data related to the generative model (a function), and this script decouples their dependency. Both traced and untraced randomness are considered. | ||
|
||
## Installation | ||
In the package manager, run | ||
``` | ||
add https://github.com/probcomp/GenSerialization.jl.git | ||
``` | ||
|
||
## Usage | ||
See the example for a typical use case. The general workflow is as follows: | ||
1. Produce traces from a generative function and then call `serialize`. | ||
```julia | ||
using Gen | ||
using GenSerialization | ||
|
||
@gen function model(p) | ||
x ~ bernoulli(p) | ||
end | ||
|
||
trace = simulate(model, (0.2)) | ||
serialize("coin_flip.gen", trace) | ||
``` | ||
|
||
2. Read in a trace by passing in the generative function: | ||
```julia | ||
saved_trace = deserialize("coin_flip.gen", model) | ||
``` | ||
|
||
## Warnings | ||
- Portability hasn't been tested. For example, machines with different endianness may fail to deserialize a given file. | ||
- The generative function is dropped. | ||
- `Serialization.jl` is used as the backend, so this package runs into similar pitfalls. For example, if your model samples *functions*, then unfortunately there are no guarantees that serialization will work properly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Gen = "ea4f424c-a589-11e8-07c0-fd5c91b9da4a" | ||
GenSerialization = "21e319bb-9f6a-4cc8-b556-663507cd964d" | ||
|
||
[compat] | ||
Documenter = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-17T09:43:45","documenter_version":"1.3.0"}} |
Oops, something went wrong.