paul-buerkner / brms

brms R package for Bayesian generalized multivariate non-linear multilevel models using Stan
https://paul-buerkner.github.io/brms/
GNU General Public License v2.0
1.29k stars 187 forks source link

Within-chain parallelization via "reduce_sum" #892

Closed paul-buerkner closed 4 years ago

paul-buerkner commented 4 years ago

See the blog post of Sebastian Weber (@wds15): https://statmodeling.stat.columbia.edu/2020/05/05/easy-within-chain-parallelisation-in-stan/

paul-buerkner commented 4 years ago

If you fork the repo and then work from the reduce_sum branch that would be perfect! Brms has a couple of other rmd vignettes from which you can see the required header structure.

wds15 notifications@github.com schrieb am So., 20. Sept. 2020, 16:09:

Great. Let's do that... it's probably easier if I fork brms and then make a PR against your repo (or you grant me directly access to this repo...whatever you prefer).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/paul-buerkner/brms/issues/892#issuecomment-695785440, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCW2AHSZRCV33I7AB7OBY3SGX5HJANCNFSM4M2PFYVQ .

wds15 commented 4 years ago

I started to write this up and I am starting to populate it with text. If you want to have a look at the flow of the document, have a look here:

https://github.com/paul-buerkner/brms/compare/reduce_sum...wds15:reduce_sum

If you have any comments already now, let me know.

I will need to find a way to provide the code I wrote, but not necessarily put all of that into the document as it is rendered. So maybe I will pull out some of the utility functions and make them "sourcable" such that users can grab the easily - let's see.

paul-buerkner commented 4 years ago

Thanks! I think the exiting text already looks quite good! I am not sure what a good approach is too sourcing code in vignettes to be honest. Personally, I would be fine with showing large chunks of code in the vignette (for users to copy), but I understand it kind of breaks the flow a little. @jgabry and @mjskay do you have experience or suggestions with handling lots of code in vignettes?

wds15 commented 4 years ago

Maybe I found a good solution. One can run code chunk blocks in the header of the document, but not include its output at all. When you name these code chunks it is possible with knitr to print them later on in an "Appendix" section without executing them a second time. So this allows me to avoid distracting the reading flow and still include the code in completion. Sound good?

EDIT: Have a look at the updated vignette which includes a first implementation of this with dummy code.

paul-buerkner commented 4 years ago

Sounds good!

wds15 notifications@github.com schrieb am Di., 22. Sept. 2020, 18:36:

Maybe I found a good solution. One can run code chunk blocks in the header of the document, but not include its output at all. When you name these code chunks it is possible with knitr to print them later on in an "Appendix" section without executing them a second time. So this allows me to avoid distracting the reading flow and still include the code in completion. Sound good?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/paul-buerkner/brms/issues/892#issuecomment-696800657, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCW2AFIAP7FHGLO55WE43DSHC76RANCNFSM4M2PFYVQ .

wds15 commented 4 years ago

It's progressing nicely:

brms_threading.zip

I will probably drop the normal model for the sake of simplicity.

Hopefully tomorrow I have time to finish the text in a first version.

wds15 commented 4 years ago

I just pushed a complete first version. How to proceed?

paul-buerkner commented 4 years ago

Nice! Can you make a PR towards brms/reduce_sum?

wds15 notifications@github.com schrieb am Do., 24. Sept. 2020, 22:45:

I just pushed a complete first version. How to proceed?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/paul-buerkner/brms/issues/892#issuecomment-698550892, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCW2ADTYJLIDXUCURRG43LSHOOUXANCNFSM4M2PFYVQ .

wds15 commented 4 years ago

sure... I added two more bits and you got your PR. I should stop now as the document got almost lenghty... but now people without time can grasp the most important stuff on the first page and others can get some more details by going through the entire text.

paul-buerkner commented 4 years ago

Thank you so much! I will read through it later on and then merge it into reduce_sum.

paul-buerkner commented 4 years ago

Closed via #1004