-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
mmrm 0.3.13's first fit is different than subsequent ones #472
Comments
Oh no 😮... |
@luwidmer Surprisingly, this doesn't seem to be a problem with rlang::warn(msg, .frequency = "once", .frequency_id = "tmb_warn_optimization") the results become reproducible. Seems like So, why is this warning triggered at all? That's because your are testing for the wrong flag. Should have been: tmb_config <- TMB::config(DLL = "mmrm")
if ( ! tmb_config$tmbad_deterministic_hash) { ... ## NOTE: NULL on old versions of TMB } |
Thanks @kaskr , wow that is really weird that |
@kaskr super interesting, and sorry for blaming TMB, my bad 😢! I did re-run 0.3.13 through RDvalgrind with level 2 valgrind instrumentation and no uninitialized memory is used (also not by rlang) there as far as this instrumentation can detect. Commenting the warning and re-installing also did the trick for me, but I'm a bit at a loss of why rlang::warn would no longer make things reproducible... that's worrying at least 🤔 |
@danielinteractive is it possible a different optimizer is used when this warning is fired? It doesn't show up for me in the above code, even though it should?! I very much doubt the issue is in rlang::warn |
@danielinteractive yup I think that might be it, changing to warning() gives the following result: > source("~/.active-rstudio-document")
0.3.13.9000
Error in refit_multiple_optimizers(fit = fit, control = control) :
No optimizer led to a successful model fit. Please try to use a different covariance structure or other covariates. |
@luwidmer ah yeah true, the warning will be captured internally and then another optimizer will be chosen, causing the other result. Alright, then I just did a mistake there putting the warning in the TMB fitting function, I guess we will need to move it higher up into |
@kaskr For my understanding, we can still now use the TMB tape optimizer but just with deterministic hash and that will produce reproducible results, is that correct? So forcing |
@danielinteractive Yes that is correct! |
Summary
mmrm 0.3.13 gives a different result on the first call than subsequent ones. Note that with TMB 1.9.15 and mmrm 0.3.12 this does not happen (the result is the same every time).
I've been able to narrow it down to the TMB::config call in the warning about optimize.instantly (https://github.com/openpharma/mmrm/blob/main/R/utils.R#L536 - also, if I manually set optimize.instantly to 1, the warning does not trigger?), so this seems to be a side effect of calling
TMB::config
to get the configuration even without changing the config? Reproducible example that allows for switching mmrm versions easily below:Output for mmrm 0.3.13:
Output for mmrm 0.3.12:
OS / Environment
Multiple (R 4.4 on ARM64 / MacOS, R 4.3.1 on RHEL 7)
@danielinteractive @kaskr any ideas?
The text was updated successfully, but these errors were encountered: