Hi,
I am trying to run phylogenetic multilevel models in BRMS but the models are taking a long time. I realise it might be the complexity of them but was hoping other more informed parties might be able to tell me if I am implementing multithreading code correctly as I have my doubts that it is doing much for me. Any advice about acceleration would be greatly appreciated as models take >50 hours to run at the moment.
For context I am trying to model whether particular plant pests are hosted by given plants from outside their native range, based upon the the phylogenetic closeness of the plants to those in the native range of the pests and their known host status.
My model form is as follows.
fullform <- bf(mvbind(Adelges_piceae,
Megastigmus_milleri,
Megastigmus_pinus,
Megastigmus_rafni,
Megastigmus_suspectus,
Armillaria_gallica,
Armillaria_mellea,
Armillaria_ostoyae,
Heterobasidion_annosum,
Lymantria_dispar,
Lymantria_monacha,
Operophtera_brumata,
Agelastica_alni,
Chrysomela_aenea,
Eriophyes_laevis,
Eupterycyba_jucunda,
Fenusa_dohrnii,
Hemichroa_crocea,
Melampsoridium_hiratsukanum,
Pterocallis_alni,
Rhagium_mordax,
Rhynchaenus_testaceus,
Stereum_rugosum
)
~ 1 + (1|p|gr(Host, cov = A)),
family = bernoulli())
The modelling works and seems to do everything I want it to, 1000 iterations appears to be plenty to resolve the model, just very slowly.
I have tried to implement within-chain multithreading to accelerate things but I am not sure I have implemented it correctly and would really appreciate a sanity check and/or further advice on how to speed up my code.
I am not sure the current code actually makes use of the 8 cores that I am requesting from the HPC and I dont want to go queuing for more cores before checking that they’ll actually be of use.
I’m using the cmdstanr backend (cmdstanr 0.8.1.9000, cmdstan-2.33.1) and everything else should be pretty much up to date as well.
fullfit <- brm(fullform, data = host_matrix, data2 = list(A=A) , prior = priors,
chains = 1, init = 0,
iter=1000, warmup=500,
backend = "cmdstanr",
threads = threading(8)
)
TLDR: I don’t understand multithreading well enough to know if I am doing it right and could use a hand making it work. No shortage of available processing resource, just a shortage of understanding to utilise it.