Add compile-time options to change default LogProbType#1328
Merged
penelopeysm merged 11 commits intomainfrom Mar 24, 2026
Merged
Add compile-time options to change default LogProbType#1328penelopeysm merged 11 commits intomainfrom
LogProbType#1328penelopeysm merged 11 commits intomainfrom
Conversation
Contributor
Benchmark Report
Computer InformationBenchmark Results |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1328 +/- ##
==========================================
- Coverage 78.26% 77.93% -0.34%
==========================================
Files 50 50
Lines 3566 3585 +19
==========================================
+ Hits 2791 2794 +3
- Misses 775 791 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment was marked as outdated.
This comment was marked as outdated.
Closed
Contributor
|
DynamicPPL.jl documentation for PR #1328 is available at: |
LogProbType
penelopeysm
added a commit
to TuringLang/Turing.jl
that referenced
this pull request
Mar 26, 2026
…-export `DynamicPPL.set_logprob_type!` (#2794) Closes #2739. As a nice by-product of using `rand(ldf)` rather than `vi[:]`, we also avoid accidentally promoting Float32 to Float64. This means that (together with TuringLang/DynamicPPL.jl#1328 and tpapp/DynamicHMC.jl#199) one can do ```julia julia> using DynamicPPL; DynamicPPL.set_logprob_type!(Float32) ┌ Info: DynamicPPL's log probability type has been set to Float32. └ Please note you will need to restart your Julia session for this change to take effect. ``` and then after restarting ```julia julia> using Turing, FlexiChains, DynamicHMC julia> @model function f() x ~ Normal(0.0f0, 1.0f0) end f (generic function with 2 methods) julia> chn = sample(f(), externalsampler(DynamicHMC.NUTS()), 100; chain_type=VNChain) Sampling 100%|████████████████████████████████████████████| Time: 0:00:02 FlexiChain (100 iterations, 1 chain) ↓ iter=1:100 | → chain=1:1 Parameter type VarName Parameters x Extra keys :logprior, :loglikelihood, :logjoint julia> eltype(chn[@varname(x)]) Float32 julia> eltype(chn[:logjoint]) Float32 ``` (Previously, the values of `x` would be Float32, but logjoint would be Float64. And if you used MCMCChains, everything would be Float64.)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this PR:
Prior to this PR,
logjointandLogDensityProblems.logdensitywould return Float64 instead. See TuringLang/Turing.jl#2212.