Help in improving model

Hello all. I have a pretty complicated model that I fit with quite a lot of data that takes a really long time to fit (it spends ~24 hours for 100 iterations for a small subset of subjects). I want to implement multithreading with map_rect to make it run faster, but I am unsure what is the right way of doing it given the unusual structure of my model:

model {
                // model 1
                for (1:A) {
                      y_A ~ bernouli(theta1)
                }
                // model 2
                for (1:B) {
                      y_B ~ bernouli(theta2)
                }                
                // model 3
                for (1:C) {
                      y_C ~ bernouli(theta3)
                }                
                // model n
                for (1:N) {
                      y_N ~ bernouli(thetaN)
                }   
} 

where every model (from model 1 to model n) has a different structure and different input data.
Should I map_rect over the full set of models? Should I do it for each model separately? Any direction will be helpful!
Thanks!

Definitely if your models are independent then run them as different models.
Before you try map_rect to vectorize your code. You don’t need the for - loop.
Depending of your code, you may recode your code and use bernoulli_logit
instead of bernoulli.

Thanks! My models are dependent because the data comes from the same subjects. I don’t really have to iterate over each model after I vectorize it, but I do have to loop over the entire set of models.
How does dependency affect parallelization here?

But how about your parameters? Are they sharing information between your models?

Each model has a different set of parameters, but they all have shared hyperpriors that are outside of the loop.