Skip to content

Refactor HMC initialisation code#2567

Merged
penelopeysm merged 1 commit into
mainfrom
py/refactor-nuts-init
May 29, 2025
Merged

Refactor HMC initialisation code#2567
penelopeysm merged 1 commit into
mainfrom
py/refactor-nuts-init

Conversation

@penelopeysm

@penelopeysm penelopeysm commented May 28, 2025

Copy link
Copy Markdown
Member

I'm really wary of #2566 becoming very big, so I'm trying to break off smaller bits.

This is a really basic bit of refactoring that I think just makes things easier to read.

Anyway, I've tested before and after with

using Turing, Random
@model f() = x ~ Normal()
sample(Xoshiro(468), f(), NUTS(), 1000)

and the exact numerical result is unchanged, so I'm pretty sure that there isn't actually any code change — hence the lack of a version bump.

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

Iterations        = 501:1:1500
Number of chains  = 1
Samples per chain = 1000
Wall duration     = 4.59 seconds
Compute duration  = 4.59 seconds
parameters        = x
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   Float64   Float64   Float64    Float64    Float64   Float64       Float64

           x   -0.0338    0.9883    0.0494   396.8876   699.6500    1.0029       86.5433

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

           x   -1.9956   -0.6683   -0.0578    0.6140    1.9267

@github-actions

Copy link
Copy Markdown
Contributor

Turing.jl documentation for PR #2567 is available at:
https://TuringLang.github.io/Turing.jl/previews/PR2567/

@codecov

codecov Bot commented May 28, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.86%. Comparing base (411a341) to head (39ad15e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/mcmc/hmc.jl 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2567      +/-   ##
==========================================
- Coverage   85.92%   85.86%   -0.07%     
==========================================
  Files          21       21              
  Lines        1428     1429       +1     
==========================================
  Hits         1227     1227              
- Misses        201      202       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@penelopeysm penelopeysm requested a review from mhauru May 28, 2025 18:06
@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 15307178307

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 85.924%

Totals Coverage Status
Change from base Build 15285321138: 0.0%
Covered Lines: 1227
Relevant Lines: 1428

💛 - Coveralls

@mhauru mhauru left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@penelopeysm penelopeysm merged commit dea5d19 into main May 29, 2025
42 of 48 checks passed
@penelopeysm penelopeysm deleted the py/refactor-nuts-init branch May 29, 2025 12:50
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

Successfully merging this pull request may close these issues.

3 participants