-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add ./model compile_info #887
Comments
I have this implemented in stan/cmdstan/stanc3 but will wait for feedback before proceeding. The model would get a constructor with no arguments and a compile info function. bernoulli_model() : model_base_crtp(0) {}
std::vector<std::string> model_compile_info() const {
std::vector<std::string> info;
info.push_back("MODEL_NAME=bernoulli_model");
info.push_back("STANCFLAGS=--allow_undefined");
info.push_back("STANC_VERSION=stanc3 124f5639");
return info;
} and stan::model::model_base& new_model() {
stan_model* m = new stan_model();
return *m;
} ant the write_compile_info function in cmdstan would be: void write_compile_info(stan::callbacks::writer &writer,
std::vector<std::string>& compile_info) {
writer("STAN_VERSION = " + stan::MAJOR_VERSION + "." + stan::MINOR_VERSION + "." + stan::PATCH_VERSION);
for (int i = 0; i < compile_info.size(); i++) {
writer(compile_info[i]);
}
#ifdef STAN_THREADS
writer("STAN_THREADS=true");
#endif
#ifdef STAN_MPI
writer("STAN_MPI=true");
#endif
#ifdef STAN_OPENCL
writer("STAN_OPENCL=true");
std::stringstream msg;
msg << "OPENCL_PLATFORM_ID=" << OPENCL_PLATFORM_ID << "\n"
<< "OPENCL_DEVICE_ID=" << OPENCL_DEVICE_ID;
writer(msg.str());
#endif
} EDIT: Refactored so that flags are caught in cmdstan not the model. |
Primary use case is cmdstanX wrappers but this is useful for cmdstan also. I found myself not knowing if I compiled a model with STAN_THREADS/STAN_OPENCL a lot :) . |
I would find it better to have a config.hpp or the like in stan-math. This file would be like our make/local, but more standard like as other packages are doing it. What is the use case for exposing this via cmdstan? The name compile_info is possibly misleading as this would include -OX things as well. It should be better to call it something which says „enabled features“ or the like. |
That would work for THREADS/MPI/OPENCL but that does not give you version numbers/stanc3 version/stanc flags. Maybe there is a misunderstanding here. This is meant for printing information on how the model was compiled. Not compiling or setting compile flags.
Not sure I understand. This is a cmdstan(X) feature, so it should be exposed in cmdstan. It makes on sense in math as we have no concept of a model there.
The name is a placeholder for now. There are better names for sure. |
While we still have the monolithic CSV output it would be great to add this
info there as well to make everything as reproducible as possible.
… On Jun 7, 2020, at 7:32 AM, Rok Češnovar ***@***.***> wrote:
I have this implemented in stan/cmdstan/stanc3 but will wait for feedback before proceeding.
The model would get a constructor with no arguments and a compile info function.
bernoulli_model() : model_base_crtp(0) {}
std::vector<std::string> model_compile_info() const {
std::vector<std::string> info;
info.push_back("MODEL_NAME=bernoulli_model");
info.push_back("STANCFLAGS=--allow_undefined");
info.push_back("STANC_VERSION=%%NAME%%3 %%VERSION%%");
#ifdef STAN_THREADS
info.push_back("STAN_THREADS=true");
#endif
#ifdef STAN_MPI
info.push_back("STAN_MPI=true");
#endif
#ifdef STAN_OPENCL
info.push_back("STAN_OPENCL=true");
std::stringstream msg;
msg << "OPENCL_PLATFORM_ID=" << OPENCL_PLATFORM_ID << "\n"
<< "OPENCL_DEVICE_ID=" << OPENCL_DEVICE_ID;
info.push_back(msg.str());
#endif
return info;
}
and
stan::model::model_base& new_model() {
stan_model* m = new stan_model();
return *m;
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#887 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AALU3FVHMRUXDXXZCXHLBKDRVN3EPANCNFSM4NXDYU3Q>.
|
That is a good call. The threads/mpi/opencl are represented in a way in the CSV, though that could be made more explicit. For example, num threads is listed but we should also state that threads_enabled = 1. The version of the compiler and the flags used to compile is however not there. And given that compile-time optimizations in stanc will be available in the next release we really must add this to the CSV to make this more reproducible. |
One other potentially nice thing would be to also output the input data names and their types in a machine friendly way.
The use case is nicer messages on what data is missing in both cmdstan and cmdstanX. |
putting this into the monolithic CSV output header makes sense - we need to document the exact format or order of this info w/r/t the command line config info. |
Description:
We should add a "compile_info" argument to the model executable that would output information on how to executable was compiled:
Example:
./examples/bernoulli/bernoulli compile-info
outputs:
For now, I envisioned adding the stan version, stanc flags, stanc version, and whether the THREADS/MPI/OPENCL flags were used.
Other options I am not sure we want to use but could if there is interest:
Current Version:
v2.23.0
The text was updated successfully, but these errors were encountered: