Upgrading hardware for LinearAlgebra in Julia

Hello, I typically work on solving eigenvalue problems with non-Hermitian matrices using LinearAlgebra.jl. Recently, I’ve been considering upgrading my laptop to improve the operating time for matrix diagonalization and eigenvalue/eigenstate plotting.

Could you recommend a better laptop for these tasks? My current setup is a 2019 Apple MacBook Pro 13 with an Intel Core i7 2.8GHz processor, 16GB of RAM, and a 512GB SSD. My budget is up to 3000 USD, and I require 24GB or more of RAM for dealing with larger matrices.

For example, the eigvals() function takes around 4800 seconds to run with the following code:

using LinearAlgebra
N = 24000
A = rand(Complex{Float64}, N, N)
eigvals(A)

Are there laptops that can achieve significantly faster computation times? I’ve heard that having sufficient memory bandwidth might help. Additionally, are there any differences in Julia’s performance between macOS and Windows?

1 Like

I have a Framework | Choose Framework Laptop 13 DIY Edition (AMD Ryzen™ 7040 laptop with 32 GB RAM (about 1873 EUR incl 2 TB SSD), and executing your code needed 2444 seconds:

julia> @time include("bench.jl")
2443.947729 seconds (649.32 k allocations: 17.223 GiB, 0.00% gc time, 0.02% compilation time)
24000-element Vector{ComplexF64}:
  -63.28884672452826 + 1.5069795003392608im
  -63.12570688280942 + 1.4679802358275418im
 -63.015408649892365 - 0.42639858375064493im
 -62.946303089959684 + 0.23500221839911026im
  -62.88981327039282 - 5.183074187040009im
  -62.88776881868133 + 5.592425894654174im
  -62.86713334920773 + 5.009766111939222im
 -62.815652194879405 + 7.609916770085996im
  -62.76227359987212 - 2.595894052465677im
  -62.73574157082742 - 1.3667994538987132im
                     ⋮
  62.889907901907776 + 1.33551586908236im
   62.90583407685033 - 3.5874513673751816im
   62.92909375107443 + 3.3003355030709787im
   62.96355871197654 + 6.116995895976287im
   63.02210103845973 - 2.6238456440881786im
  63.072462256601426 + 0.5801813099236778im
  63.173794099395465 - 5.058255854848188im
  63.209142310557354 + 0.26971206309029594im
   11999.39418054727 + 12000.131475334652im

If you use an AMD Ryzen™ 7040HS CPU as in the 16 inch version of this laptop you will gain another 10-20% of speed.

If you want the best performance, I would suggest Linux or Mac over Windows.

3 Likes

Thank you for your recommendation. That’s cool! but the Framework PC is not sold in Japan😢.

I’d like to know which Intel and Mac CPUs are equivalent to the AMD Ryzen™ 7040HS CPU in terms of diagonalization performance. Also, I want to know how hot your laptop got while executing bench.jl.

From what perspective?

Between 80 and 100 °C CPU temperature. Which is fine, you hear the fan, but it is not loud. The laptop casing was not hot, only the CPU.

Other laptops with this CPU: AMD Ryzen 7040 series Laptop List - Google Sheets

2 Likes

You may want to check this recent topic Help wanted: benchmarking multi-threaded CPU performance.

One question: Must it be a laptop? What about a desktop at home as a server, and your laptop as a thin client? In a desktop you get more capacity/$, and they are expandable. Set up a VPN on your router if you need an access from outside.

As for Windows vs. Mac: They are difficult to compare, as Windows doesn’t run on Apple’s “M” processors. On Macs, the M processors are supposed to be much faster than their previous generation using Intel. In any case on my relatively low end Mac Mini M1, 8GB (2020) Julia was about twice as fast as on a medium range i5 Windows Notebook a year older.

In the benchmarking topic, those in possession of a powerful computer were asked to share benchmarking results. My Mac Mini was certainly not in in the category, but here are my results - you may want to compare with your Mac:

[7.7, 7.6, 7.5, 7.5, 7.6, 7.7, 7.7, 7.6, 7.6]  threads=4
[9.3, 9.8, 8.8, 9.8, 9.4, 9.3, 9.8, 9.5, 9.8]  threads=8
2 Likes

Yes, my priority is portability. Since I can access a supercomputer at my university (if I follow the procedure), I’m looking for a “thin client” with better performance than my current one, though it doesn’t need to be the best.

Here is my result:

[2.0, 2.6, 2.5, 2.5, 2.4, 2.6, 2.8, 2.5, 2.4]  threads=1
[7.4, 7.9, 7.8, 8.1, 8.4, 7.2, 7.3, 7.6, 7.2]  threads=4

and my colleague’s one with M1 Max MacBook Pro:

[1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7]  threads=1

It seems that this benchmark doesn’t reflect the diagonalization performance on Mac. Indeed, with the M1 Max, eigvals(rand(Complex{Float64}, 6000, 6000)) took around 60 seconds, which suggests that for N = 24000, the computation would take approximately 60 * 64 = 3840 seconds based on the O(n^3) scaling law. This calculation shows the M1 Max is 1.25 times faster than my current setup. This result also implies that the AMD Ryzen™ 7 7840U is much better than the M1 Max for my purposes. (assuming I didn’t make any calculation errors)

Could someone run this on an M3 Mac or an Intel Core i9 (or Ultra 9) with N=6000?

If you are already inside the Apple ecosystem, you need to be real with yourself about whether you want to leave it or not. If not: Apple has a trade-in program. See how much you can trade-in or sell your current macbook for. Use the proceeds to get the most expensive macbook that fits within your budget (and 3000 goes quite a ways).

You could of course get more performance per dollar by leaving the ecosystem, but that may not be the only criteria you care about.

I’m not fixated on Apple products. While I find features like battery life and usability attractive, I’m aware of drawbacks such as not being suitable for gaming and cost. My main concern in this topic is just to know which laptop or CPU can perform diagonalization most comfortably and quickly. After knowing that, I will consider my other criteria and chose my next laptop.

FWIW, I did N=6000 in 75 seconds with my desktop.

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × AMD Ryzen 9 5950X 16-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)
1 Like

On my 32 MB M2 Mac Pro got (for N=6000):
52.693343 seconds (20 allocations: 552.750 MiB, 0.00% gc time)

If you wait a bit for M4 Mac pros you”ll likely shave off 2x% or more. Th m3 is 1x% faster (where x is some integer 3 or 4 just don’t remember exactly)

PS Just for comparison on intell I7 6 core 64gb Mac mini I get:
119.139765 seconds (652.05 k allocations: 596.847 MiB, 0.01% gc time, 0.51% compilation time)

These Mx chips are impressive

1 Like

On a Framework 13 laptop with an AMD 7840u processor, I get this timing:

julia> let N = 6000
           A = rand(ComplexF64, N, N)
           @time eigvals(A)
       end;
 55.588438 seconds (20 allocations: 552.750 MiB, 0.00% gc time)

which is pretty comparable to your M2 result for a processor that came out around the same time. The Apple’s chips are mostly only impressive when looked at on a per-watt basis, but even there AMD is catching up pretty quick (though Apple has some very cool stuff like a wide memory bus, and some of the ARM niceties when it comes to vectorization).

Do you mean macbook pro, or mac pro? Also which M2 specifically? The Mac Pro only has a M2 Ultra, whereas Macbook Pros can have a regular M2, a M2 Pro, or an M2 Max.

Since there is no M3 Mac Pro I suspect you’re talking about laptops but I’m not sure. My understanding was that the M3 was not much faster than the M2 at all, but there’s some signs the M4 is a bigger step forward than the M3 was.

But when the M4 comes out, it’ll also be competing with AMD’s Strix chips which are sounding rather promising.

1 Like

which is pretty comparable to your M2 result for a processor that came out around the same time. The Apple’s chips are mostly only impressive when looked at on a per-watt basis, but even there AMD is catching up pretty quick (though Apple has some very cool stuff like a wide memory bus, and some of the ARM niceties when it comes to vectorization).

I’m not sure how the graphics chip or ML processing compares on these AMD chips, but Apple has pretty impressive performance on those and they are both accessible from Julia and Python if you want to use them.

Do you mean macbook pro, or mac pro? Also which M2 specifically? The Mac Pro only has a M2 Ultra, whereas Macbook Pros can have a regular M2, a M2 Pro, or an M2 Max.

Yes I am taking about MacBook Pro and I’m using an M2 Max. Thanks for making me clarify :slight_smile:

there is no M3 Mac Pro I suspect you’re talking about laptops but I’m not sure. My understanding was that the M3 was not much faster than the M2 at all, but there’s some signs the M4 is a bigger step forward than the M3 was.

But when the M4 comes out, it’ll also be competing with AMD’s Strix chips which are sounding rather promising.

I already noted the m3 is only around 12-14% faster whereas I believe M4 is 23% or so faster. Again m4 gpu and ml will both be even more impressive.

I prefer Apple over windows and Linux desktop for many, many reasons, having used all 3 quite extensively. Ditto w/Apple hardware. So as long as Apple performance is comparable I see no reason to switch.

If you have the money, go for Apple… But you cannot extend the RAM after buying it which might be a disadvantage, with a Framework laptop you can exchange every component yourself (it comes with a screwdriver)…

3 Likes

If you have the money, go for Apple… But you cannot extend the RAM after buying it which might be a disadvantage, with a Framework laptop you can exchange every component yourself (it comes with a screwdriver)…

Yes I have heard this argument many times. But while“time is money” might be a truism, that doesn’t make it not relevant. if I multiply out my hourly billing rate by the large numbers of hours I waste on really stupid things in Windows (and even more so in Linux desktops), with the value of that time I can buy several very expensive Apple laptops. Not to mention my Apple hardware lasts longer and has higher resell value so I save even more money. So that’s not a great argument. If Apple performance was significantly worse and I wasted time on that, then I might reconsider.

PS I want to clarify I’m not trying to initiate a desktop war or criticize anyone else’s choice of laptop. While the principle “time is money” is true for everyone (students have opportunity costs even if their billable rate is 0) different people may find different OS more productive for them. In addition there are other important types of value (“I greatly value working in an OSS platform”) which might compensate for other costs. But since the op was originally in an Apple environment, the cost of his time is a legitimate criterion of concern.

1 Like