15
$\begingroup$

I am curious about the performance of Apple's M1 chip solving optimizations models, MIP, LP, and in solutions approach as benders or columns generations. I read that is a spectacular cpu to perform machine learning tasks, and was wondering how good is solving OR problems.

Does anyone have any experience with one? Is the M1 the best cpu (on laptops) out there for this kind of tasks? Better than an AMD 5900 or Intel i7-11?

I look up for references on the internet, but couldn't find any.

$\endgroup$
5
  • 8
    $\begingroup$ I don't know. But the best CPU for OR is the brain of a skilled analyst. Computing the right thing is more important than how fast it is computed. $\endgroup$ Commented Sep 11, 2021 at 23:40
  • 5
    $\begingroup$ As of now (2021), M1 is arguably the worst CPU you could use. Not necessarily because of performance issues (which i cannot comment much on, just that: "browser-performance" is very different from OR-performance), but because of software-support. The given answer below mentions support of commercials. But if you, and at some point you probably will, use additional software, you will see that lots of popular open-source software is struggling to produce easy-to-deploy builds (partially because the toolchains are not yet evolved enough). Browse some github-issues (e.g. scipy, or-tools, ...) $\endgroup$
    – sascha
    Commented Sep 12, 2021 at 11:43
  • $\begingroup$ Many companies around the world provide Clevo-based laptops, Sager, XMG, Xotic being examples. You can get one of these with the best CPU available for a desktop, and with a desktop-grade graphics card (if supply available). That would technically be the best option on a consumer-available laptop, despite the fact that you would end up with a laptop whose power-brick alone will weigh more than two M1 MacBooks and be worthy of the "brick" name. I have one, and I love it. $\endgroup$
    – Mefitico
    Commented Sep 13, 2021 at 0:58
  • 1
    $\begingroup$ Another alternative is not to buy a mobile device and just remote into a batch processing system and to only pay for beefy servers when you compute. Gurobi has an offer called Gurobi cloud that might be interesting.. $\endgroup$ Commented Sep 13, 2021 at 18:36
  • 1
    $\begingroup$ @orpanter i tried to benchmark small MILP problems on M1 with the help of a friend i edited my reply. If you think my answer is complete enough, please accept it. You can do that by clicking on the greyed out checkmark next to my post. I am telling you this since you are new contributor. $\endgroup$ Commented Sep 15, 2021 at 20:10

2 Answers 2

15
$\begingroup$

One problem you might encounter is that the many solvers are either not available for M1 like CPLEX[1]. M1 support for Gurobi might be mixed in general due to issue like "Only use single-threaded BLAS on Mac to avoid overshooting the thread limit" [3] and limited memory which might become a big problem for large systems.

You could probably get an evaluation license for Gurobi and evaluate them on a Mac Mini with an M1 that is available for rent online. This should at least give you an idea whether it is competitive when given more power and cooling. In general the machine learning hardware and the build in GPU (which if often counted in GigaFLOP numbers for the M1) won't be used by any solver. In general going with an AMD with more cores should be worth it as those kind of problems can easily exploit parallelism.

I wouldn't expect to have a good time using an M1 based laptop for OR. Mostly for software reasons.

  1. CPLEX
  2. Gurobi
  3. Recent Bug Fixes by Version - Gurobi

Attempts at Benchmarking

Since I don't have any indication what kind of MILP problems you want to solve I just took some really fast MILP problems and ran two open source MILP solver CBC and GLPK in this Benchmark script using Julia/JuMP.

Run on a Intel(R) Core(TM) i5-8250U CPU inside a Lenovo L380 Yoga

I got a friend to compile GLPK for me (it is now available for everybody using Julia/JuMP on M1) and to attempt to run the benchmark on a MacBook Pro with an M1 however not the more complicated and dependency rich CBC.

While the GLPK compiled successfully JuMP uses closured run time generated functions for callbacks which are not supported on ARM. The issue in the Julia language is tracked here. Even if you use a platform independent programming language, the code base below you might use a hack for performance which is not cross platform. I haven't found anything whether Pyomo can call solvers in C on an M1. However other Python libraries have similar callback trouble with C code on M1.

Unless you are willing to compile solvers yourself, fight with commercial vendors and debug their code and in addition don't care about the comforts of high-level languages I would not recommend you to use an MacBook M1 for Operations Research. As Erling Andersen noted, it would be hard to even exploit the capabilities of an M1 chip due to lack of documentation.

$\endgroup$
6
  • 2
    $\begingroup$ Some of this is incorrect: Gurobi officially supports the M1 chip, and the performance is fantastic! Check out e.g. this blog post from Ed Rothberg: gurobi.com/resource/… $\endgroup$
    – Richard
    Commented Sep 16, 2021 at 12:45
  • 2
    $\begingroup$ @Richard The blog entry you linked said literally: "Scaling is limited beyond four cores, but scaling to four cores is quite strong. The chip is very new, and the software infrastructure isn’t complete right now, so unfortunately it is still too early for us to release a native binary and official support." I described the state of Gurobi as experimental and with issues that affect large problems. I think this citation supports that judgement. I never made performance claims, only claims about support. If i missed anything in the blog post that contradicts my position please cite it. $\endgroup$ Commented Sep 16, 2021 at 13:13
  • $\begingroup$ Thank you very much! Your answer was fantastic and resolved everything I wanted to know! $\endgroup$
    – orpanter
    Commented Sep 17, 2021 at 1:50
  • 3
    $\begingroup$ Since the blog post came out we (I work for Gurobi) provide an officially supported build for Gurobi, see here: gurobi.com/downloads/gurobi-optimizer-eula The software infrastructure may be incomplete in the sense that some vendors may not have built M1-compatible builds yet, but we have, and it works very very well. The key problem is the limited memory which makes the solution of large-scale systems problematic. $\endgroup$
    – Richard
    Commented Sep 17, 2021 at 8:40
  • $\begingroup$ @Richard thank you for your insight, i updated the answer accordingly. Is "Only use single-threaded BLAS on Mac to avoid overshooting the thread limit" still a concern? $\endgroup$ Commented Sep 17, 2021 at 13:05
10
$\begingroup$

We at Mosek has started porting Mosek to the Apple M1 CPU so the upcoming version 10 will support it.

Here is an initial thought.

Normally optimization software links to a BLAS/LAPACK library such as Intel MKL that does dense matrix multiplication and other important operations. That the BLAS/LAPACK library is of high quality is very important for the performance of interior-point methods.

Now I just started looking at Apple's offering called Accelerate and to me it seems the documentation is extremely poor. For instance how do you link with it? Is it multithreaded? If it is multithreaded then how do control the number of threads?

In addition it seems Accelerate has an advanced coproccessor for matrix operation which on purpose is not documented at all as discussed by Eric Engheim. Hence, it is very hard as optimization software vendor to figure out how to exploit the hardware best possible.

Also something like the poor answer to this question is not something I find promising.

So to summarize the Apple M1 CPU and AMX coprocessor is most likely great, but I think there is significant amount of work for the software vendors to figure out how to exploit the hardware best possible. Since at least for now it is a niche platform for OR, then the question is how much energy the vendors will spend on tuning their software.

Update: The M1 seems very fast using MOSEK on 1 thread, However, using multiple threads made it slower. BTW my employees say a Mac can at most have 16GB RAM. That will limit the size problems that can be solved.

$\endgroup$
1
  • $\begingroup$ For what it's worth, the newer MacBook Pros come with up to 64 GB of RAM, which is nice for OR. But it sounds like we need to wait a while for stronger desktop machines and for the documentation and vendor support to mature. Kind of where we were around 2007 with the Intel switch. $\endgroup$ Commented Oct 28, 2021 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.