Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stan refactor #2004

Merged
merged 134 commits into from Jan 9, 2017
Merged

Stan refactor #2004

merged 134 commits into from Jan 9, 2017

Conversation

syclik
Copy link
Member

@syclik syclik commented Aug 9, 2016

Submisison Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

This pull request accomplishes two major things:

  1. In the src/stan/services folder (the stan::services namespace), we now have functions that should be called by the interfaces.
  2. Removes a lot of the old code.

It does this while maintaining all current behavior.

Intended Effect

The intended effect is to make the downstream interfaces easier to implement and maintain.

The code is much cleaner. Each of the functions in src/stan/services excluding the src/stan/services/util folder are meant to be called by RStan, PyStan, and CmdStan. This will also make it much easier to deal with the upcoming template build issue we will have with the introduction of forward-mode and RHMC.

How to Verify

(I'm sorry -- the diff is large.)

  1. All tests should pass. (The upstream tests will fail due to CmdStan develop branch not having changes necessary, but I'll submit a pull request on the CmdStan branch.)
  2. Take a look at all the new functions in src/stan/services. I've covered all the use cases of CmdStan, PyStan, and RStan. See side effects below.
  3. There were a couple of additional utilities outside of src/stan/services that were added. Take a look.

If there are some oddly implemented things in there, most weird implementations are due to keeping the existing behavior intact. This way, we can roll these changes out with a minor release and keep moving forward.

Side Effects

CmdStan, RStan, and PyStan will break under the current branch, but will maintain the same behavior.

I have a branch of CmdStan that works. Allen has a branch of PyStan that's almost working. I have a branch of RStan that's almost working.

Documentation

The C++ code may need some more doc.

If anyone wants to help, there's that and adding more tests.

Reviewer Suggestions

This one's big, so it'd be helpful to have a few eyes on it.

@ariddell, @bgoodri: since this will effect both of you directly.
@sakrejda: since you've been looking at this for a while.
@bob-carpenter, @betanalpha, @rtrangucci: if you've got the time.

Although I'm confident that this behaves identically, this one shouldn't be taken lightly.

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): Columbia University

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

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 29, 2016 via email

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 29, 2016 via email

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 30, 2016 via email

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Dec 30, 2016 via email

@syclik
Copy link
Member Author

syclik commented Dec 30, 2016 via email

@ariddell
Copy link
Contributor

We wanted to do this outside so that the interfaces could produce error messages in their own language.

I think one source of error messages (via throwing exceptions) would be fine. I thought there were other reasons pushing validation outside the function.

@syclik
Copy link
Member Author

syclik commented Dec 30, 2016

Bob, action is back on you to review the pull request.

I made most of the changes you suggested. If I missed anything major, please remind me. The ADVI issues, I've created a new issue: #2195.

@bob-carpenter
Copy link
Contributor

@syclik Thanks! That's awesome. I'll be able to take another pass tomorrow (1 January 2017!).

Copy link
Contributor

@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.

the ipad ate a bunch of comments

*
* @param[in] state Values in a std::vector
*/
void operator()(const std::vector<double>& state) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is 100% code dup with previous---I would ratha single templated impl called twice

* Output stream
*/
std::ostream& output_;
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

space between declarations

/**
* Virtual destructor.
*/
virtual ~writer() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

move dtor up before other methods

*/
std::vector<double> vals_r(const std::string& name) const {
std::vector<double> vals_r;
return vals_r;
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need the assign

/**
* Destructor.
*/
~random_var_context() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

dtor after ctor

callbacks::writer& diagnostic_writer) {
util::experimental_message(message_writer);

boost::ecuyer1988 rng = util::rng(random_seed, chain);
Copy link
Contributor

Choose a reason for hiding this comment

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

shiuldnt this all be templated on RNG for consistency with all else

parameter_writer(names);

Eigen::VectorXd cont_params;
cont_params.resize(cont_vector.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

make change i suggested here

model.constrained_param_names(names, true, true);
parameter_writer(names);

Eigen::VectorXd cont_params;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditt

break;
}

{
Copy link
Contributor

Choose a reason for hiding this comment

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

these braces don't do anything

"------------------------------");
message_writer("EXPERIMENTAL ALGORITHM:");
message_writer(" - please expect frequent updates to the procedure");
message_writer(" - please expect unexpected inference results");
Copy link
Contributor

Choose a reason for hiding this comment

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

expect the unexpected? how about instead of both lines:

This procedure has not been thoroughly tested and may be unstable or buggy. The interface is subject to change.

@bob-carpenter
Copy link
Contributor

This pull request was too large---it overwhelmed my mac and ipad trying to review. I lost about ten comments, mostly about all the repeated code snippets that should be oulled into functions.

Never mind. I just approved it because as much as I hate to see all this code duplication, our code doesnt need to be perfectly factored going forward and I want to be pragmatic and get this in ASAP

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Jan 4, 2017 via email

@syclik
Copy link
Member Author

syclik commented Jan 9, 2017

Just communicated with @ariddell and he gave it a thumbs up.

This is now ready to merge as soon as the final tests pass. We have:

  • a review of the Stan branch by @bob-carpenter
  • sign-off by a CmdStan maintainer, me
  • sign-off by an RStan maintainer, @bgoodri
  • sign-off by the PyStan maintainer, @ariddell

As soon as the tests pass, I'm merging.

@bgoodri
Copy link
Contributor

bgoodri commented Jan 9, 2017 via email

@syclik syclik merged commit 1c2075b into develop Jan 9, 2017
@syclik syclik deleted the feature/issue-1751-service-methods branch January 9, 2017 05:38
@bob-carpenter
Copy link
Contributor

bob-carpenter commented Jan 9, 2017 via email

@seantalts seantalts modified the milestones: v2.14.0++, v2.15.0 Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet