Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate of Static Gen Fn using StaticAssmt yields incorrect behavior #442

Open
georgematheos opened this issue Dec 7, 2021 · 0 comments

Comments

@georgematheos
Copy link
Contributor

georgematheos commented Dec 7, 2021

Here is a MWE to illustrate the bug:

julia> using Gen
julia> @gen (static) function foo()
           {:x => :y} ~ normal(0, 1)
       end
var"##StaticGenFunction_foo#269"(Dict{Symbol, Any}(), Dict{Symbol, Any}())

julia> @load_generated_functions()

julia> tr, _ = generate(foo, (), choicemap((:x => :y, 1.0)));

julia> get_choices(tr)
│
└── :x
    │
    └── :y : 1.0


julia> tr2, _ = generate(foo, (), get_choices(tr));

julia> get_choices(tr2)
│
└── :x
    │
    └── :y : -0.4208570938873921

The choicemap of tr2 should be the same as that of tr, but it is not.

I have not investigated carefully where the bug comes in. I have not checked whether having the nested address is necessary for the bug to occur (but I suspect that it is).

Note that the use of the static-assignment choicemap is necessary. If instead the constraints are a DynamicChoiceMap, no bug occurs:

julia> tr3, _ = generate(foo, (), DynamicChoiceMap(get_choices(tr)));

julia> get_choices(tr3)
│
└── :x
    │
    └── :y : 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant