Lazy SMP

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Werewolf
Posts: 2058
Joined: Thu Sep 18, 2008 10:24 pm

Lazy SMP

Post by Werewolf »

Forgive for asking ancient questions, but they are fairly crucial. In all instances I'm referring to Stockfish's implementation of Lazy SMP.
Please could you have a go at the following "multiple choice" ? :D

1. Adding cores in a CPU to an engine ALWAYS increases search speed, providing that there's no loss in clock speed. This applies even if the new cores are slower than the old ones.
a) TRUE
b) FALSE
c) UNCLEAR

The newer CPUs with "efficiency" cores are in mind here.

2. Stockfish runs on two different PCs. In each case it searches at 5 MN/s. On the first PC it's running on one core, on the second 4 cores.
a) Stockfish's search is roughly as fast on both machines
b) Stockfish's search is much faster on the first PC

3. Jack has a 16 core PC. He runs Stockfish on 8 cores and then later that day on all 16 cores. He notices an improvement in both nps and time to depth. Jack is trying to decide which one is more indicative of the speed-up.
a) Time to depth
b) NPS
c) They both need to be considered.

4. (Related to Q3) As thread count increases Stockfish's search "thickens".
a) TRUE
b) FALSE
User avatar
Ovyron
Posts: 4562
Joined: Tue Jul 03, 2007 4:30 am

Re: Lazy SMP

Post by Ovyron »

Werewolf wrote: Sat Mar 26, 2022 1:22 pm In all instances I'm referring to Stockfish's implementation of Lazy SMP.
Time to depth is everything, so it'll trump all even if nodes searched are lower. For multicore CPUs you'll have cores searching stuff that turned out to be irrelevant, so a single core with the same relative speed is going to have lower time to depth because of the time saved not searching those irrelevant lines.

Nodes per second don't tell you anything as most could have been used on nodes that had no effect (say, 80% of search time is employed investigating irrelevant move, then the best move has a fail high and 20% of remaining time is making sure it holds, then 80% of all nodes searched went to waste, getting to the depth when it happens ASAP is crucial as it minimizes nodes wasted.)
Your beliefs create your reality, so be careful what you wish for.
Uri Blass
Posts: 11124
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Lazy SMP

Post by Uri Blass »

I disagree that time to depth is everything and I read that more cores at fixed depth are better because the engine does less pruning.
smatovic
Posts: 3479
Joined: Wed Mar 10, 2010 10:18 pm
Location: Hamburg, Germany
Full name: Srdja Matovic

Re: Lazy SMP

Post by smatovic »

...I am not into SF dev, but as far as I got it, they use an 'unsound' Lazy SMP approach, one which you can not figure out with pen n paper, compared to something like YBWC or ABDADA, hence time to depth is the wrong metric here, Elo is the right one. Bob used to say they just widen the search, but IMO it is not that easy. I guess the parallel search is intertwined with the selective search heuristics/eval, so funny effects might occur in SMP if things change. As long as there is an effective branching factor ~2 there must be IMO something you can parallelize, and others seem to see an upper limit with ~128 cores for current AB-NNUE engines. Would be fun if some SF dev could make a paper how SF Lazy SMP actually works, how it gains Elo without widening the search and lowering time to depth, or alike. My speculation - cos SF dev can not figure out SF Lazy SMP with pen n paper, no one can answer your questions until they run specific tests for your given use cases.

--
Srdja
Modern Times
Posts: 3784
Joined: Thu Jun 07, 2012 11:02 pm

Re: Lazy SMP

Post by Modern Times »

smatovic wrote: Wed Jun 01, 2022 2:59 pm ..... hence time to depth is the wrong metric here, Elo is the right one. ....
Srdja
Yes, at the end of the day Elo is the real-world measure of the effectiveness of an SMP implementation in chess, if not the technical one.
User avatar
Ovyron
Posts: 4562
Joined: Tue Jul 03, 2007 4:30 am

Re: Lazy SMP

Post by Ovyron »

smatovic wrote: Wed Jun 01, 2022 2:59 pm hence time to depth is the wrong metric here, Elo is the right one
And my claim is that the shorter time to depth the more elo, as it leaves more time on the clock so on other moves this engine will outsearch the one with longer time to depth.

Would like to see an example of an engine reaching lower depth and beating the higher depth one, all things being equal, more depth = more elo.
Your beliefs create your reality, so be careful what you wish for.
User avatar
Ronald
Posts: 161
Joined: Tue Jan 23, 2018 10:18 am
Location: Rotterdam
Full name: Ronald Friederich

Re: Lazy SMP

Post by Ronald »

In current chess engines depth is a relative concept with all the pruning and extensions going on. With lazy SMP the depth that is reported by the engine is the depth of only 1 search thread(usually the main thread, or a helper thread with a higher depth/score) so this makes engine depth even more obscure.

I'm pretty sure that if you run a match on fixed depth with a single thread version against a multiple thread version with a lesser fixed depth, then up to a certain difference in depth/number of threads the multi threaded version will be better. When doing such an experiment, you have to make sure that the engine used always stops the helper threads at the fixed depth, usually the search in only stopped when the main thread reaches the fixed depth, so other threads may have a deeper search depth than reported.

Of course its safe to assume that "all things being equal" usually more depth means more elo (except for mate in X positions...)
Sopel
Posts: 391
Joined: Tue Oct 08, 2019 11:39 pm
Full name: Tomasz Sobczyk

Re: Lazy SMP

Post by Sopel »

Ovyron wrote: Thu Jun 02, 2022 11:11 am
smatovic wrote: Wed Jun 01, 2022 2:59 pm hence time to depth is the wrong metric here, Elo is the right one
And my claim is that the shorter time to depth the more elo, as it leaves more time on the clock so on other moves this engine will outsearch the one with longer time to depth.

Would like to see an example of an engine reaching lower depth and beating the higher depth one, all things being equal, more depth = more elo.
Your understanding of modern chess engines is pretty inexistent if depth is the metric you use
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.

Maybe you copied your stockfish commits from someone else too?
I will look into that.
User avatar
Ovyron
Posts: 4562
Joined: Tue Jul 03, 2007 4:30 am

Re: Lazy SMP

Post by Ovyron »

Ronald wrote: Thu Jun 02, 2022 12:56 pm I'm pretty sure that if you run a match on fixed depth with a single thread version against a multiple thread version with a lesser fixed depth, then up to a certain difference in depth/number of threads the multi threaded version will be better.
I'd love to see this, I've never seen an engine with lower depth beat one with a higher one (which in this case would be same engine with different conditions.)

Probably could be fast to run (say, depth 11 multi thread beating depth 12 single thread.)
Your beliefs create your reality, so be careful what you wish for.
User avatar
Ovyron
Posts: 4562
Joined: Tue Jul 03, 2007 4:30 am

Re: Lazy SMP

Post by Ovyron »

Sopel wrote: Thu Jun 02, 2022 12:56 pm Your understanding of modern chess engines is pretty inexistent if depth is the metric you use
This isn't about understanding, but of practice, nobody has tested for this case (where lower depth wins.)
Your beliefs create your reality, so be careful what you wish for.