Hi wonderful Stan folks -
I’m looking to parallelize an (otherwise slow) ODE model. To this end I installed rstan 2.26.1 dev (& StanHeaders) according to this post; verified that the original (non-parallel) model compiled and ran under that config.
Next step; following the reduce_sum example here I set up the partial sum functions for the likelihoods including the ODE evaluation (there are >3k observation for which to run this). The parallel code is here growth_model_ode_update.stan (12.1 KB) .
Note there is one partial sum for a second likelihood that does not depend on the ODE and does not throw errors…so only the ODE config gives trouble. After a few hours of debugging I finally got to this error message:
Error in stanc(model_code = model_code, model_name = model_name, verbose = verbose, :
0
Semantic error in 'string', line 199, column 12 to line 200, column 157:
Ill-typed arguments supplied to function 'reduce_sum'. Available arguments:
(T[], int, int, ...) => real, T[], int, ...
(T[,], int, int, ...) => real, T[,], int, ...
(T[,,], int, int, ...) => real, T[,,], int, ...
(T[,,,], int, int, ...) => real, T[,,,], int, ...
(T[,,,,], int, int, ...) => real, T[,,,,], int, ...
(T[,,,,,], int, int, ...) => real, T[,,,,,], int, ...
(T[,,,,,,], int, int, ...) => real, T[,,,,,,], int, ...
Where T is any one of int, real, vector, row_vector or matrix.
Instead supplied arguments of incompatible type: (vector, int, int, real, real, real, real, vector, vector, vector, data real[], data real[], data real[], data int[]) => real, vector, int, int, real, real, real, real, vector, vector, vector, real[], real[], real[], int[]
Calls: stan_model -> stanc_builder -> stanc
Execution halted
The error seems the same as discussed here:. Based on taht, I added data types to the partial sum function, but run into the rror that the “data” type is not maintained through the function call (I think), However, given subsequent benchmarks here, I wonder if this should work in some config other than the one I am trying here?
Wondering if @wds15 may have some insights?
Thanks lots in advance!
> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.10
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_NZ.UTF-8 LC_NUMERIC=C LC_TIME=en_NZ.UTF-8 LC_COLLATE=en_NZ.UTF-8
[5] LC_MONETARY=en_NZ.UTF-8 LC_MESSAGES=en_NZ.UTF-8 LC_PAPER=en_NZ.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.26.1 StanHeaders_2.26.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 compiler_4.0.4 pillar_1.5.1 prettyunits_1.1.1 tools_4.0.4
[6] pkgbuild_1.2.0 jsonlite_1.7.2 lifecycle_1.0.0 tibble_3.1.0 gtable_0.3.0
[11] pkgconfig_2.0.3 rlang_0.4.10 DBI_1.1.1 cli_2.3.1 rstudioapi_0.13
[16] parallel_4.0.4 curl_4.3 loo_2.4.1 gridExtra_2.3 dplyr_1.0.5
[21] generics_0.1.0 vctrs_0.3.6 tidyselect_1.1.0 stats4_4.0.4 grid_4.0.4
[26] glue_1.4.2 inline_0.3.17 R6_2.4.1 processx_3.4.5 fansi_0.4.2
[31] purrr_0.3.4 ggplot2_3.3.3 callr_3.5.1 magrittr_2.0.1 codetools_0.2-17
[36] matrixStats_0.56.0 scales_1.1.1 ps_1.3.3 ellipsis_0.3.1 assertthat_0.2.1
[41] colorspace_2.0-0 V8_3.4.0 utf8_1.1.4 RcppParallel_5.0.3 munsell_0.5.0
[46] crayon_1.3.4