Skip to content
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

CI failing on mac #504

Closed
seabbs opened this issue Jan 21, 2025 · 30 comments · Fixed by #524
Closed

CI failing on mac #504

seabbs opened this issue Jan 21, 2025 · 30 comments · Fixed by #524

Comments

@seabbs
Copy link
Contributor

seabbs commented Jan 21, 2025

The mac CI is failing for it appears both cmdstan and rstan models. Using a mac locally I see no issues and there are no reported mac issues either here or upstream in rstan or brms suggesting a CI issue.

@seabbs
Copy link
Contributor Author

seabbs commented Jan 21, 2025

it looks like this may have been introduced with the cohort model as I can't find an example from main during or before that period. If so it suggests some opportunities for exploration.

@seabbs
Copy link
Contributor Author

seabbs commented Jan 22, 2025

To investigate this I have cleared the cache and changed the install cmdstan action to pull from the latest version (this functionality was the default but was turned off due to stability concerns - these have now been resolved upstream).

@seabbs
Copy link
Contributor Author

seabbs commented Jan 22, 2025

This had no impact

@seabbs
Copy link
Contributor Author

seabbs commented Jan 22, 2025

I see that the naive model works as expected with both rstan and cmdstanr

@seabbs
Copy link
Contributor Author

seabbs commented Jan 22, 2025

All CI for primarycensore is fine for all platforms so its not directly the stan code as implemented there. There is also no clear difference in the CI setup except that here we need rstan as well as cmdstan.

@seabbs

This comment has been minimized.

@seabbs
Copy link
Contributor Author

seabbs commented Jan 22, 2025

I have tested this locally with both intel and mac silicon macs and found no issues. Based on this I think this is strictly a CI issue with the most likely issues being caching of the cmdstan install or the paths used to store included functions (there are general issues with very long paths or paths with spaces in them).

@seabbs
Copy link
Contributor Author

seabbs commented Feb 4, 2025

We are also seeing some CI issues in epiforecasts/EpiNow2#938 but those are explicitly cache related (which I have already checked). Still it is likely findings from that should help here.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 4, 2025

The latent model also works so the issue is specific to the marginal model.

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

In case it helps I see this in my local install.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

ah interesting that does help. Is it just the marginal model for you and any other details?

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Do you also have a problem with anything in primarycensored?

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

This is the error - possibly related to boost/BH?

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  cialization 'rstan::(anonymous namespace)::command<model96539299c7b__namespace::model96539299c7b_, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399>>>' requested here
 1215 |     ret = command(args, model_, holder, names_oi_tidx_,
      |           ^
file9655ae06c8e.cpp:2392:68: note: in instantiation of member function 'rstan::stan_fit<model96539299c7b__namespace::model96539299c7b_, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399>>>::call_sampler' requested here
 2392 |           &rstan::stan_fit<stan_model, boost::random::ecuyer1988>::call_sampler)
      |                                                                    ^
14 warnings and 4 errors generated.

The latent model gives

Error in compileCode(f, code, language = language, verbose = verbose) : 
  signed int, 40014, 0, 2147483563>, linear_congruential_engine<unsigned int, 40692, 0, 2147483399>> &&' for 1st argument
   50 | class additive_combine_engine
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/Users/eidesfun/Library/R/arm64/4.4/library/BH/include/boost/random/additive_combine.hpp:79:48: note: explicit constructor is not a candidate
   79 |     BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(additive_combine_engine,
      |                                                ^
/Users/eidesfun/Library/R/arm64/4.4/library/BH/include/boost/random/additive_combine.hpp:97:46: note: explicit constructor is not a candidate
   97 |     BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(additive_combine_engine,
      |                                              ^
file9651b34186e.cpp:521:11: warning: variable 'pos__' set but not used [-Wunused-but-set-variable]
  521 |       int pos__ = std::numeric_limits<int>::min();
      |           ^
12 warnings and 1 error generated.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Hm okay I wonder if this is the same problem then as the latent model works in the CI.

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

Hm okay I wonder if this is the same problem then as the latent model works in the CI.

where do you see this? I could try the exact same check. The error I get in the vignette is the same as in CI so I think it must be the same

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Here #502

When you switch that vignette over to the latent model the error moves to the first time the marginal model is compiled
(in the tests). Do you see this for both rstan and cmdstan backends?

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

The latent model does work - I think I may have had a knitr cache issue above. The error only occurs in rstan (2.32.6 and 2.36.0.9000), dev version cmdstanr works doesn't seem to work.

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

If you don't see this locally it must be traceable to some package version?

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

or potentially some compiler settings we dont share but mine is all just the default

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

same

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

downgrade of BH to 1.84 didn't fix it for me.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Does the stan vignette in primarycensored work for you? That is all the same stan code as in the marginal model apart from the interface code in brms so it localises it to that

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

No, and actually ypon looking more closely epidist with cmdstanr doesn't work either with the marginal model. Same error:

. + Compiling Stan program...
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:736:47: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long long') to 'int' in initializer list [-Wc++11-narrowing]
  736 |         std::vector<int>{dist_id, primary_id, stan:
:math::size(params),
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:822:18: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_cdf<int, std::vector<double>, int, std::vector<double>, nullptr>' requested here
  822 |                  primarycensored_cdf(d, dist_id, params, pwindow,
      |                  ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:906:21: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lcdf<int, std::vector<double>, int, std::vector<double>, nullptr>' requested here
  906 |     log_cdf_upper = primarycensored_lcdf(d_upper, dist_id, params, pwindow,
      |                     ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2321:13: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lpmf<false, int, std::vector<double>, int, std::vector<double>, nullptr>' requested here
 2321 |             primarycensored_lpmf<false>(
      |             ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2593:12: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lognormal_model::log_prob_impl<false, false, Eigen::Matrix<double, -1, 1>, Eigen::Matrix<int, -1, 1>, nullptr, nullptr, nullptr>' requested here
 2593 |     return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
      |            ^
/Users/eidesfun/.cmdstan/cmdstan-2.36.0/stan/src/stan/model/model_base_crtp.hpp:93:50: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lognormal_model::log_prob<false, false, double>' requested here
   
93 |     return static_cast<const M*>(this)->template log_prob<false, false, double>(
      |                                                  ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2188:3: note: in instantiation of member function 'stan::model::model_base_crtp<primarycensored_lognormal_model_namespace::primarycensored_lognormal_model>::log_prob' requested here
 2188 |   ~primarycensored_lognormal_model() {}
      |   ^

/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:736:47: note: insert an explicit cast to silence this issue
  736 |         std::vector<int>{dist_id, primary_id, stan::math::size(params),
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                               static_cast<int>(       )
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:737:11: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long long') to 'int' in initializer list [-Wc++11-narrowing]
  737 |           stan::math::size(primary_params)}, "assigning variable ids");
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:737:11: note: insert an explicit cast to silence this issue
  737 |           stan::math::size(primary_params)}, "assigning variable ids");
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           static_cast<int>(               )

/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:736:47: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long long') to 'int' in initializer list [-Wc++11-narrowing]
  736 |         std::vector<int>{dist_id, primary_id, stan::math::size(params),
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:822:18: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_cdf<int, std::vector<stan::math::var_value<double>>, int, std::vector<double>, nullptr>' requested here
  822 |                  primarycensored_cdf(d, dist_id, params, pwindow,
      |                  ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:906:21: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lcdf<int, std::vector<stan::math::var_value<double>>, int, std::vector<double>, nullptr>' requested here
  906 |     log_cdf_upper = primarycensored_lcdf(d_upper, dist_id, params, pwindow,
      |                     ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2381:13: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lpmf<false, int, std::vector<stan::math::var_value<double>>, int, std::vector<double>, nullptr>' requested here
 2381 |             primarycensored_lpmf<false>(
      |             ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2593:12: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lognormal_model::log_prob_impl<false, false, Eigen::Matrix<stan::math::var_value<double>, -1, 1>, Eigen::Matrix<int, -1, 1>, nullptr, nullptr, nullptr>' requested here
 
2593 |     return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
      |            ^

/Users/eidesfun/.cmdstan/cmdstan-2.36.0/stan/src/stan/model/model_base_crtp.hpp:98:50: note: in instantiation of function template specialization 'primarycensored_lognormal_model_namespace::primarycensored_lognormal_model::log_prob<false, false, stan::math::var_value<double>>' requested here
   98 |     return static_cast<const M*>(this)->template log_prob<false, false>(theta,
      |                                                  ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:2188:3: note: in instantiation of member function 'stan::model::model_base_crtp<primarycensored_lognormal_model_namespace::primarycensored_lognormal_model>::log_prob' requested here
 2188 |   ~primarycensored_lognormal_model() {}
      |   ^
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:736:47: note: insert an explicit cast to silence this issue
  736 |         std::vector<int>{dist_id, primary_id, stan::math::size(params),
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                               static_cast<int>(       )
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:737:11: error: non-constant-expression cannot be narrowed from type 'int64_t' (aka 'long long') to 'int' in initializer list [-Wc++11-narrowing]
  737 |           stan::math::size(primary_params)}, "assigning variable ids");
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T/RtmpeMkxGX/model-8dc17775757.hpp:737:11: note: insert an explicit cast to silence this issue
  737 |           stan::math::size(primary_params)}, "assigning variable ids");
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           static_cast<int>(               )

4 errors generated.

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

You know what, we had this before. Replace size() with num_elements() in the stan code. Here (and possibly elsewhere).

https://github.com/epinowcast/primarycensored/blob/be0ae95eafa7cb925fdf8bc81641e867bd27e779/inst/stan/functions/primarycensored_ode.stan#L103

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Ah nice. I will update. Was there an interaction in EpiNow2 between cmdstanr and rstan? I assume that must be why the primarycensored CI doesn't see this.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Testing: #524

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

I need to stop using size..

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

Amazing this looks like it works. Phew. Just doing the PR over in primarycensored and then will formalise the PR here and get this closed out.

@sbfnk
Copy link
Contributor

sbfnk commented Feb 5, 2025

Can you check with dev version rstan, too? In previous exploration we found that an upstream fix broke things.

@seabbs
Copy link
Contributor Author

seabbs commented Feb 5, 2025

I just checked and that is what I have locally so it looks like it works

seabbs added a commit that referenced this issue Feb 5, 2025
* Update DESCRIPTION - add primarycensored branch

* Update DESCRIPTION

* Update NEWS.md

* Update NEWS.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants