Buying a new computer - best hardware for fast Stan performance


#1

Hi folks,
my department is going to buy a new computer that will be mainly used for Stan (running in R). What is your recommondation for the hardware (considering the trade-off between money and performance/ computation time)?

Thanks in advance!
Alexander


#2

I’ve been wondering the same as I’m soon replacing my home PC. Are Alienware machines well-suited to running STAN (also in R)? I’m eyeing a new coffee-lake model for the hex-cores with room to expand to dual GPU’s sometime later. Will such power be useful in future STAN ?


#3

My advice is not to worry about raw CPU power too much because runtime is driven by 1) algorithmic issues such as proper scaling of parameters, numerical problems caused by poor fit, whatever posterior geometry drives stepsize to be too small, etc…; 2) model optimization to trim the auto-diff tree size and share calculations. Everything else is at least an order of magnitude down the line.

One thing that does slow you down is your ability to run multiple models with multiple chains at once so I’d get a dual-CPU motherboard with slightly dated hex-core processors before I tried to get the latest fastest CPU. SSD disks are nice for getting things to compile faster.


#4

Nice!

Stan runs MCMC chains in parallel on each of your processor’s cores, so if it were me I’d try to get a processor with as many cores as possible. I think the new Intel and AMD ones that came out this past Summer have up to 16 cores. More RAM is always cheap and gives you good bang for your buck. I think @Bob_Carpenter also mentioned in another thread that GPU support is coming soon in Stan, so you probably want to get an nvidia GPU for that, maybe even in addition to the GPU that will drive your monitors.

I’m tagging @bbbales2 because he’d have good advice on this. He taught me everything I know about hardware.


#5

Thanks for the advice guys. I should explain where I’m coming from on this. Currently I mostly use JAGS on my laptop or old Xeon hex core PC. But I’ve taken note of the developments within STAN of MPI based within thread parallelisation and GPU, so since I’m thinking to upgrade the PC anyhow, I was wondering whether something like an Alienware machine would be good to take advantage of these new algorithms. Unfortunately 16 cores etc out of my reach, but a new hex core I could later stuff a GPU or two into later on is doable - and the Alienwares seem easy to upgrade - but I have no experience of them. I do want the single core speed too for other reasons so buying older chips not attractive @sakrejda.
Apologies @Alexander, I do not mean to hijack your thread!


#6

A GPU should be good for large Cholesky decompositions. If you can do a suitable break down of your problem into good chunks, then MPI will be amazing. I think MPI is more general in terms on when it speeds up your model while GPU is really specifc (but IF a GPU can speed up your case, then you will probably want it). For MPI: The more CPUs the better and what hasn’t been mentioned yet is fast RAM.

… but MPI will be a bit of a pain for the user to program up his model…


#7

I looked at this a while ago (disclaimer, I have not looked at it since v2.16), and here is what I found using a fairly complicated model on large data:

For my model with some large matrix operations, the fastest speedup was from getting on a system with lots of L3 cache on the CPU(s). I ran the same model on a bunch of different hardware and the slowest speeds were from the system with the highest clock speed - a consumer-grade workstation (i7 @ 3.8 GHz, 8MB L3 cache - 4 days). Middling times were on some compute servers (Google Cloud, campus clusters) with decent clock speeds, but I was sharing with other jobs (~3.2 GHz - 2 days). The fastest times were on a system I cobbled together with used server parts off Ebay. That system has the lowest clock (and oldest CPUs) but highest L3 cache (dual Xeon @ 2.6 GHz, 25 MB L3 per chip - 20 14 hrs). edit - just checked and the run-times were lower than I remembered

Hardly authoritative, but from my experience running other models since then, Stan benefits greatly from large cache on the CPU and high memory bandwidth. My low clock, high memory bandwidth “frankenstein” workstation is my go-to for running Stan. I would guess that the newer AMD Threadripper CPUs in a workstation could be a great value, as they have gobs of cache. I will get a chance to play with one in the coming months and will report back.


#8

@wds15 - These days I’m doing alot of multi-level/hierarchical models of different types for modelling longitudinal multiple outcomes dataset. Will MPI be a help for those?

@mespe - really interesting thanks. I was eyeing up a model with this chip: https://ark.intel.com/products/126686/Intel-Core-i7-8700-Processor-12M-Cache-up-to-4_60-GHz


#9

Yes, for hierarchical models I do expect speedups do be quite nice with MPI. MPI has the cost of communication which needs to be balanced by the computational cost per unit. Hierarchical models are usually good in this regard as you have per unit few parameters and lots of data such that you need to communicate not that much, but you need to calculate a lot per parameter set - which is what you need for MPI to work well.


#10

For reference, I built my dual Xeon system for $500 USD. That said, I have been playing around with computer hardware for a long while and have lots of experience building systems, so your mileage might vary.

The other consideration is what kind of models you are running - it really only makes sense (in my mind) to fret about hardware if you are running models which are hitting some kind of realistic limit. For most of my day-to-day work, a laptop is more than enough. Even with that larger model, I developed the model and tested it on my laptop with a subset of the data, and only needed the computation for the final stages with the full data set.

That line for me was when after every optimization I could think of the model was still taking long enough that I could not run it over night and look at the results the next morning.


#11

That’s going to be true for most mathematical operations in decently optimized software. Getting data from memory to the CPU registers is really really expensive.

I don’t know how much the interfaces parallelize compilation, but you can do a lot in parallel from CmdStan on teh build side.

For parallelizing chains, that’s useful up to four or so—enough to diagnose multimodalities and non-convergence, but beyond that, you’re mainly getting proportionately higher effective sample sizes for the same runs. You still have to pay the price of warmup.

When we get MPI done, the way to speed things up will be parallelizing within chains. That’ll be able to use a lot of cores. So 16, 32, or a cluster full of cores would be good in that situation if you really need to scale. Personally, I think I’m going to get one of the new iMacs because I won’t have to learn a new OS and I want a nice 5K screen.

If it’s even a question, good solid-state disks are a necessity, since compiling Stan brings in an awful lot of little files.


#12

Maybe just being contrarian but I have an old server with crap HDD’s and I don’t really notice the slower compilation speed… but then again I usually do way more model validation than compared to model writing so I just go do something else when compiling a model.


#13

@mespe -once upon a time I’d have been all for such a build but my knowledge is way out of date for such shenanigans. The Xeon chip in my current desktop is not suitable for a dual chip board and has slow RAM speed in any case, so no point in harvesting that (my 4 year old MBP is much faster running JAGS models than the desktop, probably due to faster RAM). My motivation here is that I’m building alot of these models on different datasets, and waiting hours/overnight for results really screws with my workflow. So even marginal gains per model would add up for me. The potential gains offered by MPI would be amazing. But I need to first transition from Jags to stan anyhow. I’m simply thinking ahead since I was thinking to upgrade the PC anyhow.

Thanks all for your responses. Most helpful and informative!