With rstan 2.18, users of brms are flooded with informational messages of the form
Info: left-hand side variable (name=p) occurs on right-hand side
of assignment, causing inefficient deep copy to avoid aliasing.
that I can’t get rid of without also suppressing other relevant parser information such as failings to parse a Stan model. These info messages mostly look like false positives to me. Is there any way to selectively suppress them or even get rid of them entirely?
It is going to be all or nothing. Since you should be confident the autogenerated Stan code will parse, you could suppressMessages all of them. But basically the autogenerated Stan code needs to use more += and / or temporary variables to avoid having the same vector or matrix on both sides of the assignment.
I am confident my Stan code parses, but it will fail if the user specifies a syntactially invalid prior. I will see how much of these messages I can avoid with additional += statements.
bad news: generated code is indeed using stan::model::deep_copy instead of regular assigment and this is less efficient, so there might be a performance slowdown in current 2.18.
Yeah, thanks Mitzi, but could you clarify if a) something changed in 2.18 that made deep copies occur more regularly and hence generate warnings, or b) these deep copies were already occurring but the warnings just started appearing?
edit: should have read the github issues again first – sounds like the deep copies were introduced in 2.18…
in the current version, whenever there’s a simple assignment statement which is somehow updating the value of a variable using its current value, the generated code will call stan::model::deep_copy, e.g.
vector[5] x;
real y;
y = y + 1; // line 3: spurious deep_copy
x[1] = x[1] + 1; //line 4: spurious deep_copy
x[2:3] = x[3:4] + 1 // line 5: legit deep_copy
rewriting lines 3 and 4 using compound assignment will avoid the bug, given the logic in the compiler and generator.
Sounds like we’re going to need to do another Stan and RStan release with a bunch of patches in it. We should talk about how soon we need to do that and what all needs to be fixed.