Skip to content

Conversation

@amas0
Copy link
Collaborator

@amas0 amas0 commented Nov 13, 2025

Submission Checklist

  • Run unit tests
  • Declare copyright holder and open-source license: see below

Summary

Intends to resolve #770.

Adds a save_singe_paths boolean keyword argument to CmdStanModel.pathfinder, which sets save_single_paths=True in the PathfinderArgs (this argument already existed). Also, exposes these output file locations to the user as part of the RunSet. Specifically, this adds two properties: RunSet.single_path_csv_files and RunSet.single_path_json_files that will only be populated with file paths if pathfinder is run with the new flag enabled.

This PR also changes slightly the cmdstanpy behavior for Pathfinder, specifically it explicitly defaults the num_paths argument to 4 within cmdstanpy. Previously, it defaulted to None and cmdstan under the hood would default to 4 paths. This meant (as far as I could tell) that cmdstanpy didn't have any explicit reference to the num_paths value if run using defaults.

Some follow-on questions I have:

  • Right now, the file paths are accessible within the RunSet but no higher. Is there a desire to expose these files as properties on the CmdStanPathfinder class?
  • Relatedly, is there any desire to load these files in, in some way like via a possible CmdStanPathfinder.single_path_draws() or something?

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): myself

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

Previous implementation left num_paths as None by default.
This meant it would be set as a default value of 4 by cmdstan
under the hood. While functional, this meant that cmdstanpy
did not explicitly know the number of paths used when running
pathfinder. This made it awkward to write code that needed to
know how many paths were run.

By making the default explicitly 4 in cmdstanpy, this clarifies
behavior at the cost of not automaticallyu inheriting any changes
to default cmdstan behavior.
@WardBrian
Copy link
Member

Your two questions are part of why we did not implement this when first exposing pathfinder -- it's not entirely clear when users want these, and it introduces a whole ton of conditional logic into the pathfinder return and the runset. I'm still not entirely convinced it's a good idea

@amas0
Copy link
Collaborator Author

amas0 commented Nov 14, 2025

Yeah, and my intuition is that there's not a real need to have it bubble up to the stanfit object.

I think it makes sense to include it in the runset, we do state in the docstring:

    Encapsulates the configuration and results of a call to any CmdStan
    inference method. Records the method return code and locations of
    all console, error, and output files.

It'd be a larger lift to do any processing of the resultant files, but storing a reference isn't too bad.

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.

cannot set the save_single_paths argument to Pathfinder model

2 participants