Guarantee complete mate PVs in multiPV analysis

This PR introduces the additional `RootMove` attribute `previousPV` so that scores and PVs we send to the GUI in MultiPV analysis always match. This allows us in particular to extend our guarantee of exact mate (and TB win/loss) scores having a complete PV (leading to checkmate in the correct number of plies) to all PV lines. Recall that master fails here, since partially searched root moves may send to the GUI the previous score with the current/modified PV. See #6784.

The PR also uses the new attribute to extend the followPV logic to the analysis of sidelines, building on the idea in #6813 by @joergoster.

Passed non-reg STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 166880 W: 42357 L: 42282 D: 82241
Ptnml(0-2): 394, 18685, 45177, 18820, 364
https://tests.stockfishchess.org/tests/view/6a0dea55818cacc1db0abb6a

Failed non-reg LTC:
LLR: -2.97 (-2.94,2.94) <-1.75,0.25>
Total: 890520 W: 224168 L: 225282 D: 441070
Ptnml(0-2): 390, 91902, 261789, 90790, 389
https://tests.stockfishchess.org/tests/view/6a1143ad818cacc1db0ac14c

Opening as draft for discussion on how to proceed. In SinglePV analysis, the patch is completely nonfunctional. But it is maybe a (small?) slowdown because of the increased size of `RootMove`. I am not sure if there as an elegant way to enrich the class only for MultiPV analysis (but the switch can happen at any time through the UCI interface), or to mitigate the speed penalty in some other way.

A local speedup test shows only a small slowdown on my system (but still high error bars):
```
sf_base =  1156928 +/-   1459 (95%)
sf_test =  1155885 +/-   1283 (95%)
diff    =    -1043 +/-   1777 (95%)
speedup = -0.09021% +/- 0.154% (95%)
```

The PR also adds the new MultiPV mate PV correctness check to the CI.

closes https://github.com/official-stockfish/Stockfish/pull/6886

No functional change
This commit is contained in:
Robert Nurnberg @ elitebook
2026-06-09 19:36:14 +02:00
committed by Joost VandeVondele
parent 8e711c29fe
commit 1eff8b0389
3 changed files with 66 additions and 38 deletions
+4 -7
View File
@@ -24,7 +24,7 @@ jobs:
with:
repository: vondele/matetrack
path: matetrack
ref: b2c8c9599cd7173f537b28bba88f31690a6d6f62
ref: 9d77be284e8cba37e2f8a59e54cd2bcbf4e3ee4d
persist-credentials: false
- name: matetrack install deps
@@ -68,10 +68,7 @@ jobs:
- name: Run matetrack th4 go-mate
working-directory: matetrack
run: |
head -n 21 matetrack.epd > gomates.epd
head -n 44 matedtrack.epd >> gomates.epd
head -n 18 mates2000.epd >> gomates.epd
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile gomates.epd --mate 0 --threads 4 | tee matecheck4gm.out
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile matetrack.epd matedtrack.epd --bmMax 2 --mate 0 --threads 4 | tee matecheck4gm.out
! grep "issues were detected" matecheck4gm.out > /dev/null
total=$(grep "Total FENs:" matecheck4gm.out | awk '{print $3}')
bmates=$(grep "Best mates:" matecheck4gm.out | awk '{print $3}')
@@ -83,13 +80,13 @@ jobs:
- name: Run matetrack th1 multiPV
working-directory: matetrack
run: |
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 --multiPV 4 | tee matecheck1mpv.out
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile matetrack.epd matedtrack.epd --bmMax 10 --nodes 5000 --multiPV 20 --checkMultiPVs | tee matecheck1mpv.out
! grep "issues were detected" matecheck1mpv.out > /dev/null
- name: Run matetrack th4 multiPV
working-directory: matetrack
run: |
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile mates2000.epd --nodes 100000 --threads 4 --multiPV 4 | tee matecheck4mpv.out
python matecheck.py --engine /home/runner/work/Stockfish/Stockfish/Stockfish/src/stockfish --epdFile matetrack.epd matedtrack.epd --bmMax 10 --nodes 5000 --threads 4 --multiPV 20 --checkMultiPVs | tee matecheck4mpv.out
! grep "issues were detected" matecheck4mpv.out > /dev/null
- name: Run matetrack th1 with --syzygy50MoveRule false