Exclude transformed variables from trace#298
Exclude transformed variables from trace#298fonnesbeck wants to merge 9 commits intopymc-devs:mainfrom
Conversation
unconstrained_parameter coordinate variable needed to be updating; since shape_info no longer contains transformed names, that broke store_unconstrained=True.
ccaee4f to
8aada92
Compare
|
Not a blocker but just to have on your radar is this PR: pymc-devs/pymc#7975 Idea is to be able to transform the labels of dims using the model machinery, so we can label this unconstrained_posterior group. It's a bit of a bummer we lose all the label info currently. |
1051f30 to
a8dd5ca
Compare
OK, so the idea is to use |
|
For now I think we do nothing, I just wanted you to be aware of the issue in case you were interested/motivated to take it over the finish line. I did a bunch of hack stuff here to get labels on the find_MAP posterior, it's a lot of useless gymnastics but the payoff is nice. I do not suggest using that code, just saying it's an issue we have in a few places now. |
|
That you! Looks good, only one small nitpick: With the normalizing flows, we also have transformed vectors (the parameter space transformed by a flow), so we should not use that word for the constrain/unconstrain distinction in nutpie. |
|
@fonnesbeck do you plan to have an |
|
Not out of scope if we want it. Forgot that we have it in the zarr backend now. |
|
I think that would be great! |
|
See what you think of this. Tries to mirror PyMC's ZarrTrace convention. I've tried to make this as minimally-invasive as possible, so everything's on the Python side (no Rust). Also dropped the old flat unconstrained_draw vector + unconstrained_parameter coord. |
|
Looks good except for dropping the unconstrained vector. I use this all the time, and would really miss it. |
|
Do you mind them being saved with the same keyword argument? i.e. |
|
Yes, that sounds good. |
|
@aseyboldt OK, just uses |
|
I guess I should have seen this sooner, but can we simplify this by just storing the names of the variables that are unconstrained during compilation, and then just sort them into a new group at the very and of the arviz conversion? |
|
@aseyboldt OK, unconstrained_posterior group construction now has a simpler design: at compile time we now store only the names of reparameterized value vars; they flow through the trace as ordinary arrow columns and get sorted at the end of _arrow_to_arviz. |
Skip transformed names when building the expand function output and shape_info.
Following from this, there are changes in the construction of the
unconstrained_parametercoordinate. Since shape_info no longer contains transformed names, that broke store_unconstrained=True. Here,_make_functionsnow also returns(joined_names, joined_shapes)— the full unconstrained parameter space. _prepare_dims_and_coords uses this directly to build the coordinate, decoupling it from shape_info.