stockfish different evaluation values

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
tissatussa
Posts: 31
Joined: Sat Sep 24, 2016 4:13 am
Location: Netherlands
Full name: Roelof Berkepeis

stockfish different evaluation values

Post by tissatussa »

when using StockFish, i always get (slightly) different evaluation values when i let SF calculate a same position again .. i encounter this when using the command line but also when using SCID .. is this normal ? Why ? Is some cache involved ? I don't understand .. one would think a computer program should always give a same result ..
-simple is not always best but best is always simple-
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: stockfish different evaluation values

Post by elcabesa »

From command line stockfish output should be the same if you restart it.
If you search the same position 2 times without restarting it, there are a lot of cached data that will affect the result. Mainly hash tables .
User avatar
tissatussa
Posts: 31
Joined: Sat Sep 24, 2016 4:13 am
Location: Netherlands
Full name: Roelof Berkepeis

Re: stockfish different evaluation values

Post by tissatussa »

Well, i do NOT encounter this .. here is my test and output :

$ ./stockfish-9-64
Stockfish 9 64 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
uci
id name Stockfish 9 64
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default
option name Contempt type spin default 20 min -100 max 100
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 131072
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 89 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 6 min 0 max 6
uciok
setoption name Clear Hash
setoption name Threads value 2
position fen 3q1rk1/prppnp2/1p4p1/2b1P1N1/5P2/7P/PP5K/R1BQR3 w - - 0 1
go depth 28

>> last 2 output lines:

info depth 28 seldepth 45 multipv 1 score cp -52 nodes 200091038 nps 2913508 hashfull 999 tbhits 0 time 68677 pv d1f3 d8c8 c1d2 e7f5 a1d1 c5e7 e1g1 b6b5 d1c1 c7c5 g5e4 g8h7 a2a3 b7c7 e4c3 d7d6 e5d6 f5d6 c3d5 c7d7 d5e7 d7e7 f3f2 c8b7 g1g2 d6f5 c1c5 f8e8 c5f5 e7e2 f5f7 b7f7 f2e2 e8e2 g2e2 f7d5 d2c3 d5f3 e2e7 h7h6
bestmove d1f3 ponder d8c8


Now quit SF and start it again, only using "setoption name Clear Hash", "setoption name Threads value 2" and the same fen position :

>> last 2 output lines:

info depth 28 seldepth 55 multipv 1 score cp -50 nodes 215603372 nps 2907116 hashfull 999 tbhits 0 time 74164 pv c1d2 e7f5 d1f3 c7c6 d2c3 b6b5 b2b4 c5e7 e1g1 d8b6 g5e4 b6e3 f3e3 f5e3 a2a3 f8c8 g1g3 e3f5 g3d3 c6c5 a1d1 c5b4 c3b4 c8c2 d1d2 c2d2 d3d2 g8f8 e4f6 e7b4 a3b4 f8e7 f6d5 e7e6 h2g2 d7d6 e5d6 b7b8 d5c7 e6d7 g2f3
bestmove c1d2 ponder e7f5


As you can see the outputs are different : the first time SF gives d1f3 as best move with cp -52, the second time SF gives c1d2 as best move with cp -50 .. can you reproduce this ?
-simple is not always best but best is always simple-
User avatar
Guenther
Posts: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: stockfish different evaluation values

Post by Guenther »

tissatussa wrote: Wed Jul 04, 2018 10:31 pm Well, i do NOT encounter this .. here is my test and output :

setoption name Threads value 2
...

As you can see the outputs are different : the first time SF gives d1f3 as best move with cp -52, the second time SF gives c1d2 as best move with cp -50 .. can you reproduce this ?
Well, all obviously assumed you used 1 thread for testing.
With MP you'll never get the same output for each run.
(worker threads distribution - shared hash etc.)
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: stockfish different evaluation values

Post by elcabesa »

Guenther is right. With multi thread you don't have reproducible output, but 2 Cp are a very small difference
User avatar
tissatussa
Posts: 31
Joined: Sat Sep 24, 2016 4:13 am
Location: Netherlands
Full name: Roelof Berkepeis

Re: stockfish different evaluation values

Post by tissatussa »

Thanks all. Indeed StockFish gives exactly the same output when using threads = 1. But only when restarting SF, otherwise a next time this engine seems to use some cached results (by its hash, i suppose).
-simple is not always best but best is always simple-