-
-
Notifications
You must be signed in to change notification settings - Fork 377
Feature request: Add timestamps to sample progress #3339
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
Comments
Might the update come somewhere in here(?): stan/src/stan/services/util/generate_transitions.hpp Lines 58 to 65 in d4c6ae3
|
I like this idea, but we're very cautious about changing any of the output formats because things (like CmdStanPy's progress bars) are set up to parse the output and they might do so in very brittle ways. |
Makes sense. Thanks for considering! |
I'm reopening this issue. @mitzimorris: This is just changing things in the messages that get overwritten on top of each other, not the output format of CmdStan. Presumably nothing is parsing that transient output. I have really liked the JAX output which gives you elapsed time and estimated time remaining. And it's super cool---it just need a simple annotation around a loop, here @scan_tqdm(num_draws)
def reducer(theta, draw):
theta_star, accept = transition(keys[draw], logpdf, theta, d,
grid_size=grid_size, step_size=step_size)
return theta_star, (theta_star, accept)
_, draw_accepts = jax.lax.scan(reducer, theta, jnp.arange(num_draws)) Then when you run, it looks like this:
This says it's run 5000 of 100,000 iterations, which took 16 seconds at 311 iterations/second and is expected to run for another 5 minutes and 4 seconds. |
I believe CmdStanPy does parse the transient output to create transient progress bars. |
I don't think CmdStan has the kinds of transient/overwriting progress bars the way that CmdStanPy does. I tried that initially with CmdStan but couldn't manage to make it portable. Can't we just change CmdStanPy or is someone or something parsing its progress bar output? |
We can definitely change cmdstanpy if needed |
I have a little code from another project to get lower resolution timestamps. Though imo the date format is nicer for a logger. I like how jax does the total time so far. I kind of worry about the estimate to completion since we can go very slow in the beginning and much faster later. inline void local_time(const time_t* timer, struct tm* buf) noexcept {
#ifdef _WIN32
// Windows switches the order of the arguments?
localtime_s(buf, timer);
#else
localtime_r(timer, buf);
#endif
}
/* Get the current time with microseconds */
inline std::string time_mi() noexcept {
auto now = std::chrono::system_clock::now();
time_t epoch = std::chrono::system_clock::to_time_t(now);
struct tm tms{};
::riccati::local_time(&epoch, &tms);
auto fractional_seconds = now - std::chrono::system_clock::from_time_t(epoch);
int micros = std::chrono::duration_cast<std::chrono::microseconds>(fractional_seconds).count();
// Format the time string
char buf[sizeof "[9999-12-31 29:59:59.999999]"];
size_t nb = strftime(buf, sizeof(buf), "[%Y-%m-%d %H:%M:%S", &tms);
nb += snprintf(&buf[nb], sizeof(buf) - nb, ".%06d]", micros);
// Return the formatted string
return std::string(buf, nb);
} |
When running Stan, I like to follow the sampling output progress; for example:
It would nice if such sampling came with timestamps so that I could get a definitive sense for how long things are taking. Augmenting the above output, perhaps something like:
Does that seem reasonable? (I am new to the Stan development community, so if not I understand.)
The text was updated successfully, but these errors were encountered: