-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Improve Handling of cpp_options
#1022
base: master
Are you sure you want to change the base?
Conversation
It sounds like the actual issue here is that cmdstanr does not correctly identify whether model was compiled with stan_opencl, should we be changing that inside of the model class instead of changing this test? |
@SteveBronder did you see this draft PR that's related to this issue? #1023 Perhaps these should be combined? |
Yes I think it would be good to merge these two PRs together into one |
Sounds good, I'll polish that one up and combine them. Any idea if the opencl tests are actually running in CI (as in is Also trying to get hold of a windows machine so I can repo the windows unit test failures. If there's any way to run these on ubuntu with docker or similar, would love to hear. |
guessing the test failures are due to this: r-lib/actions#217 |
Sorry for the multiple pings in a day....but I found another related deepish problem. This test seems to be erroneously passing in the master branch: https://github.com/stan-dev/cmdstanr/blob/master/tests/testthat/test-threads.R#L162-L166 As in, both STAN_THREADS is not successfully getting set to MRE (from master branch):
The fix is that somewhere we need to convert falsy values at the R level to completely unset the ENV variable at the bash/cpp level. I'm not sure exactly where in the code it makes the most sense to do this, but I'll take a stab at it. Alternatively, we could inform users that they need to set |
No we shouldn't do anything here, since this is behaviour in Cmdstan - not cmdstanr. The options a user specifies should match those that are then set in |
ok, I'll update the test and the docs then. That's much easier. :-) |
96cce2c
to
0eb126e
Compare
Sorry for the wall of text, but I need some input before moving forward.
It accomplishes:
Does not solve
Looking for input on two topics: 1. What should the behavior be when a model object is from an already compiled model that was compiled with different args than provided in the
|
cpp_options <- model_compile_info(self$exe_file()) |
One more wrinkle...prior to cmdstan v2.27.0, this "model info" does not exist. In that case, if the binary is already compiled, we have know way of knowing what flags were used. For that matter...I think we are assuming throughout that the version of cmdstan the user currently has configured is the same as the version the binaries were compiled with. Currently, from what I can tell, we are not checking this assumption at all. We could check using model info when available, but before 2.27, all bets are off. I'll have to think a bit about a clean way to resolve this. I'd love to hear if others have ideas. |
@andrjohns I'm a bit swamped with work at the moment and haven't had a chance to look into this yet. Do you by chance have time to comment on this? |
@jgabry @andrjohns I have a version I'm pretty happy with now. It stores what the user requested as cpp options and what the binary has configured separately, and (unless compile=FALSE) re compiles if there is a mismatch. I ran the CI on my fork and only the windows tests are failing. If someone on the team is able to give some feedback, especially on the change in functionality, that would be great! I'd love to get this in mergeable state. In any case, I will just use this version for my own purposes. |
Hi, @andrjohns, @SteveBronder, and @jgabry: @katrinabrock showed up at the Stan meeting this week. She's working on this PR. She says she can fix the Windows issue, but before doing that, needs feedback on whether her changes are targeting what you think the behavior should be. @katrinabrock: If you could remind everyone which specific things you need answered, that'd help. @mitzimorris is going to take a first pass at working on requirements with @katrinabrock, but then there will probably be some questions on the final R integration. |
@mitzimorris @SteveBronder Here's my explanation of this change as promised: Initial Symptom
My ChangesUser-facing Changes in
|
Thank you! These changes totally make sense now and handle a lot of the issues we have from dealing with a make build system. Monday I will give this a harder read through and have some Qs |
Apologies for the extended delay @katrinabrock! I'm catching back up on Stan dev this week, and have better access to an OpenCL system now. I'll put aside some time to review on Wednesday |
@katrinabrock hi my apologies for the delay. Looking at the tests it looks like the new ones for the compile options are failing on windows? |
Hi @SteveBronder, Thanks for taking a look. That's correct. As mentioned in @bob-carpenter's comment above, right now, I'm not looking for approval of the code. I'd like to make sure that the functionality I'm trying to implement is the functionality desired by the core dev team. Does everything I've listed in the comment above from three weeks ago seem like the right set of changes? If so, I'll go ahead and diagnosis and resolve the windows issue. If you would like me to make a different set of logic changes, I'd like to settle on what the logic should be and implement that before worrying about the cross platform aspect. |
Thanks, @katrinabrock, that sounds totally reasonable. |
@SteveBronder when you have a chance do you mind taking another look, based on @katrinabrock's most recent comment. I think you're much more familiar with all these CmdStan C++ options than I am. It sounded like @katrinabrock was looking for confirmation that the outlined approach in #1022 (comment) is reasonable. It seems reasonable to me but it would be good to get either you (Steve) or @andrjohns to confirm too. |
I think @mitzimorris could also look over the logic and see if there are any concerns since we would likely want to have cmdstanpy and cmdstanr in sync. |
- Test new logic with mocked CLI
Co-authored-by: Steve Bronder <[email protected]>
Co-authored-by: Steve Bronder <[email protected]>
5fb5f9b
to
f993531
Compare
@SteveBronder @jgabry I think I've addressed everything from @SteveBronder's last review. Based on his last comment, I think that review was partial and he wanted to look at the tests a bit more. Based on the comments thus far, seems like the overall approach is sound so it will be worthwhile to fix the windows issue. I haven't done that yet, but I plan to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all of this work @katrinabrock! Given the amount of review that's already happened and how long it's taken me to look at it, I'm not going to hold this up with any substantive requests.
Just a minor style change, can you update all of the single-line if statements to be split across multiple lines? For example:
if (!file.exists(private$exe_file_)) return(NULL)
to:
if (!file.exists(private$exe_file_)) {
return(NULL)
}
I'll work through any windows/WSL issues now
@andrjohns: Is there an automatic formatter for R we can configure to do this automatically? We got tired of having our PRs dominated by formatting, so we now use black for Python and ClangFormat for C++. |
Looks like the unit tests are failing now. Even on linux 🤔 . Important part@andrjohns I can probably solve the windows issue myself. I'd rather you spend your time looking at the functionality and implementation. I'm a bit concerned that I haven't really gotten substantive critiques yet. Steve's comments were mostly clarifications, formatting, and small issues. (Maybe because the substance is already perfect? 🤷♀️ 😁 😈 ) Those kinds of comments are valuable, I'd just like to make sure that some folks on the core dev team understand the changes deeply enough that they'll be patched instead of reverted if some small bug reports come in after rollout. I'm certainly willing to help, but I don't want to be the only one who understands this now 1.1K line piece of the codebase. btw - I'm still open to re-breaking this up into a bunch of smaller PRs. Less important part@bob-carpenter Yes,
Currently, afaik there are no default linters that even allow you to set a requirement disallowing single line |
Addresses several issues with the opencl tests:
Submission Checklist
Summary
Please describe the purpose of the pull request.
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):
Max Planck Institute of Animal Behavior
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: