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

Chains internals shouldn't use (undocumented) reserved names #469

Open
penelopeysm opened this issue Jan 29, 2025 · 0 comments
Open

Chains internals shouldn't use (undocumented) reserved names #469

penelopeysm opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@penelopeysm
Copy link
Member

penelopeysm commented Jan 29, 2025

julia> using Turing

julia> @model f() = lp ~ Normal()
f (generic function with 2 methods)

julia> sample(f(), NUTS(), 100)
┌ Info: Found initial step size
└   ϵ = 1.6125
Sampling 100%|████████████████████████████████████████████████████████████████████| Time: 0:00:03
Chains MCMC chain (100×13×1 Array{Float64, 3}):

Iterations        = 51:1:150
Number of chains  = 1
Samples per chain = 100
Wall duration     = 4.45 seconds
Compute duration  = 4.45 seconds
parameters        =
internals         = lp, n_steps, is_accept, acceptance_rate, log_density, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size

Summary Statistics
  parameters   mean   std      mcse   ess_bulk   ess_tail      rhat   ess_per_sec
      Symbol    Any   Any   Float64    Float64    Float64   Float64       Float64


Quantiles
  parameters   2.5%   25.0%   50.0%   75.0%   97.5%
      Symbol    Any     Any     Any     Any     Any

We can't use lp as a parameter name because it's one of the internal symbols.

I didn't check the other internals but I assume similar errors would occur.

I suppose that here lp is being provided to MCMCChains by an upstream caller (something in Turing itself probably), but in any case internals + parameters should be kept in strictly separate spaces - a parameter lp and an internal lp have different meanings.

Edit: Turns out that chn[:lp] still gives you the parameter values, so the problem is technically that the logprobs are no longer accessible, plus the output display is wrong, plus the grouping of lp into internals is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants