stan-dev / stan-dev/cmdstanr

[FR] Use new num_chains arg in cmdstan for hmc, fixed params, and generated quantities

Open
#534 16 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
R
Stars
160
Forks
69
Avg merge
1d 19h
Merged PRs (30d)
15

Description

Is your feature request related to a problem? Please describe.

So once https://github.com/stan-dev/cmdstan/pull/987 goes into cmdstan, as long as the user compiled with threading on then we should be able to run multiple chains within one Stan program by specifying num_chains inside of the sample argument!

Describe the solution you'd like

Is there a reasonable line for cmdstanr to check if the method is hmc with dense or diag_e inverse metric and then when the user specifies parallel chains, internally cmdstanr passes those as command args to cmdstan instead of using R level parallelism? This should save folks a lot of memory and likewise give a nice little speed bump.

This would also have to wait / check that cmdstanr is at least greater than version 2.27 and has compiled with threading on

Describe alternatives you've considered

I'm not familiar enough with the internals of cmdstanr to know other alts, though I'm happy to discuss whatever can work for yinz!

Additional context
Add any other context about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing cmdstanr's sample argument handling and its existing R-level parallel-chain execution. Check the CmdStan version and threading requirements, then determine how HMC with dense or diag_e metrics can pass num_chains to CmdStan. Done means supported configurations use CmdStan's parallel chains without changing unsupported methods or configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.