Skip to content

Conversation

WardBrian
Copy link
Collaborator

This was brought up by @bgoodri in the Stan meeting a couple weeks ago, and should hopefully be helpful for our own testing.

It adds a new target, examples/stan_cli that can run BridgeStan models. Unlike the pre-existing example that uses bridgestan, this only runs adaptive WALNUTS, and lets you customize all the current tuning parameters. I added CLI11 for this target to facilitate that.

Here's the help output

$ ./examples/stan_cli --help

Run WALNUTs on a Stan model 


./examples/stan_cli [OPTIONS] model [data]


POSITIONALS:
  model TEXT:FILE REQUIRED    Path to the Stan model library 
  data TEXT:FILE              Path to the Stan model data (optional) 

OPTIONS:
  -h,     --help              Print this help message and exit 
          --seed UINT [1823896191]  
                              Random seed 
          --warmup INT [1000]  
                              Number of warmup iterations 
          --samples INT [1000]  
                              Number of samples to draw 
          --max-depth INT [10]  
                              Maximum depth for NUTS trajectory doublings 
          --max-step-depth INT [8]  
                              Maximum depth for the step size adaptation 
          --max-error FLOAT [0.5]  
                              Maximum error allowed in joint densities 
          --init FLOAT [2]    Range [-init,init] for the parameters initial values 
          --mass-init-count FLOAT [1.1]  
                              Initial count for the mass matrix adaptation 
          --mass-iteration-offset FLOAT [1.1]  
                              Offset for the mass matrix adaptation iterations 
          --mass-additive-smoothing FLOAT [0.1]  
                              Additive smoothing for the mass matrix adaptation 
          --step-size-init FLOAT [0.5]  
                              Initial step size for the step size adaptation 
          --step-accept-rate-target FLOAT [0.666667]  
                              Target acceptance rate for the step size adaptation 
          --step-iteration-offset FLOAT [2]  
                              Offset for the step size adaptation iterations 
          --step-learning-rate FLOAT [0.95]  
                              Learning rate for the step size adaptation 
          --step-decay-rate FLOAT [0.05]  
                              Decay rate for the step size adaptation 
          --output TEXT:PATH(non-existing) 
                              Output file for the draws 

Copy link
Collaborator

@bob-carpenter bob-carpenter left a comment

Choose a reason for hiding this comment

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

Now that you tracked down where the NaN issue was coming from, this looks good to go. I didn't extensively test all the input options were getting passed correctly.

@bob-carpenter bob-carpenter merged commit 618df14 into main Sep 25, 2025
4 checks passed
@WardBrian WardBrian deleted the run-stan-cli branch September 25, 2025 18:57
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.

2 participants