Difference between revisions of "NNUE"

From Chessprogramming wiki
Jump to: navigation, search
(9 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
'''NNUE''', (&#398;U&#1048;&#1048; Efficiently Updatable Neural Networks)<br/>  
 
'''NNUE''', (&#398;U&#1048;&#1048; Efficiently Updatable Neural Networks)<br/>  
a Neural Network architecture intended to replace the [[Evaluation|evaluation]] of [[Shogi]], [[Chess|chess]] and other board game playing [[Alpha-Beta|alpha-beta]] searchers running on a CPU.
+
a Neural Network architecture intended to replace the [[Evaluation|evaluation]] of [[Shogi]], [[Chess|chess]] and other board game playing [[Alpha-Beta|alpha-beta]] searchers running on a CPU. Inspired by [[Kunihito Hoki|Kunihito Hoki's]] approach of [[Piece-Square Tables|piece-square tables]] indexed by king location, and further two-piece locations and side to move as applied in his Shogi engine [[Bonanza]] <ref>[http://yaneuraou.yaneu.com/2020/05/03/%E6%A9%9F%E6%A2%B0%E5%AD%A6%E7%BF%92%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%8B%E3%82%A2%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E5%B0%86%E6%A3%8Bai%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80%E3%81%9D%E3%81%AE1/ 機械学習エンジニアのための将棋AI開発入門その1 Introduction to Shogi AI development for machine learning engineers Part 1], May 03, 2020 (Japanese)</ref>, '''NNUE''' was introduced in 2018 by [[Yu Nasu]] <ref>[[Yu Nasu]] ('''2018'''). ''&#398;U&#1048;&#1048; Efficiently Updatable Neural-Network based Evaluation Functions for Computer Shogi''.  Ziosoft Computer Shogi Club, [https://github.com/ynasu87/nnue/blob/master/docs/nnue.pdf pdf] (Japanese with English abstract)</ref>, and was used in Shogi adaptations of [[Stockfish]] such as [[YaneuraOu]] <ref>[https://github.com/yaneurao/YaneuraOu GitHub - yaneurao/YaneuraOu: YaneuraOu is the World's Strongest Shogi engine(AI player), WCSC29 1st winner, educational and USI compliant engine]</ref>,
NNUE was introduced in 2018 by [[Yu Nasu]] <ref>[[Yu Nasu]] ('''2018'''). ''&#398;U&#1048;&#1048; Efficiently Updatable Neural-Network based Evaluation Functions for Computer Shogi''.  Ziosoft Computer Shogi Club, [https://github.com/ynasu87/nnue/blob/master/docs/nnue.pdf pdf] (Japanese with English abstract)</ref>,
 
and was used in Shogi adaptations of [[Stockfish]] such as [[YaneuraOu]] <ref>[https://github.com/yaneurao/YaneuraOu GitHub - yaneurao/YaneuraOu: YaneuraOu is the World's Strongest Shogi engine(AI player), WCSC29 1st winner, educational and USI compliant engine]</ref>,
 
 
and [[Kristallweizen]] <ref>[https://github.com/Tama4649/Kristallweizen/ GitHub - Tama4649/Kristallweizen: 第29回世界コンピュータ将棋選手権 準優勝のKristallweizenです。]</ref>, apparently with [[AlphaZero]] strength <ref>[http://www.talkchess.com/forum3/viewtopic.php?f=2&t=72754 The Stockfish of shogi] by [[Larry Kaufman]], [[CCC]], January 07, 2020</ref>.  
 
and [[Kristallweizen]] <ref>[https://github.com/Tama4649/Kristallweizen/ GitHub - Tama4649/Kristallweizen: 第29回世界コンピュータ将棋選手権 準優勝のKristallweizenです。]</ref>, apparently with [[AlphaZero]] strength <ref>[http://www.talkchess.com/forum3/viewtopic.php?f=2&t=72754 The Stockfish of shogi] by [[Larry Kaufman]], [[CCC]], January 07, 2020</ref>.  
  
Line 31: Line 29:
 
* [[Cerebrum]]
 
* [[Cerebrum]]
 
* [[David E. Moriarty#SANE|SANE]]
 
* [[David E. Moriarty#SANE|SANE]]
 +
* [[Stockfish NNUE#HalfKA|Stockfish HalfKAv2]]
  
 
=Publications=
 
=Publications=
Line 125: Line 124:
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76437 256 in NNUE?] by Ted Wong, [[CCC]], January 28, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76437 256 in NNUE?] by Ted Wong, [[CCC]], January 28, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76446 So what do we miss in the traditional evaluation?] by [[Ferdinand Mosca]], [[CCC]], January 29, 2021 » [[Evaluation]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76446 So what do we miss in the traditional evaluation?] by [[Ferdinand Mosca]], [[CCC]], January 29, 2021 » [[Evaluation]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76447 Latest Night Nurse released] by [[Dietrich Kappe]], [[CCC]], January 29, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76456 None-GPL NNUE probing code] by [[Daniel Shawul]], [[CCC]], January 31, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76456 None-GPL NNUE probing code] by [[Daniel Shawul]], [[CCC]], January 31, 2021
 
===February===
 
===February===
Line 131: Line 131:
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76556 HCE and NNUE and vectorisation] by [[Vivien Clauzon]], [[CCC]], February 11, 2021 » [[Minic]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76556 HCE and NNUE and vectorisation] by [[Vivien Clauzon]], [[CCC]], February 11, 2021 » [[Minic]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76570 nnue reading code] by [[Jon Dart]], [[CCC]], February 13, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=76570 nnue reading code] by [[Jon Dart]], [[CCC]], February 13, 2021
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76648 New net: The White Rose] by [[Dietrich Kappe]], [[CCC]], February 20, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76664 Are neural nets (the weights file) copyrightable?] by [[Adam Treat]], [[CCC]], February 21, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76664 Are neural nets (the weights file) copyrightable?] by [[Adam Treat]], [[CCC]], February 21, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76731 My first NNUE nn-f0c1c3cbf2f1.nnue] by [[Michael Byrne|MikeB]], [[CCC]], February 27, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=76731 My first NNUE nn-f0c1c3cbf2f1.nnue] by [[Michael Byrne|MikeB]], [[CCC]], February 27, 2021
Line 154: Line 155:
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77438 Commercial Release of Ethereal 13.00 (NNUE) for AVX2 Systems] by [[Andrew Grant]], [[CCC]], June 04, 2021 » [[Ethereal#Ethereal 13 (NNUE)|Ethereal 13.00 (NNUE)]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77438 Commercial Release of Ethereal 13.00 (NNUE) for AVX2 Systems] by [[Andrew Grant]], [[CCC]], June 04, 2021 » [[Ethereal#Ethereal 13 (NNUE)|Ethereal 13.00 (NNUE)]]
 
: [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77438&start=17 Re: Commercial Release of Ethereal 13.00 (NNUE) for AVX2 Systems] by [[Andrew Grant]], [[CCC]], June 04, 2021 » [[Stockfish NNUE#NNUE Structure|HalfKP]]
 
: [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77438&start=17 Re: Commercial Release of Ethereal 13.00 (NNUE) for AVX2 Systems] by [[Andrew Grant]], [[CCC]], June 04, 2021 » [[Stockfish NNUE#NNUE Structure|HalfKP]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77467 Dark Horse Update] by [[Dietrich Kappe]], [[CCC]], June 11, 2021
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77492 Some more experiments with neural nets] by [[Jonathan Kreuzer]], [[CCC]], June 15, 2021 » [[Slow Chess]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77492 Some more experiments with neural nets] by [[Jonathan Kreuzer]], [[CCC]], June 15, 2021 » [[Slow Chess]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77503&start=55 Re: will Tcec allow Stockfish with a Leela net to play?] by [[Connor McMonigle]], [[CCC]], June 17, 2021 » [[Stockfish]], [[Dragon by Komodo Chess|Komodo Dragon]], [[Ethereal]], [[Seer]]
 
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77503&start=55 Re: will Tcec allow Stockfish with a Leela net to play?] by [[Connor McMonigle]], [[CCC]], June 17, 2021 » [[Stockfish]], [[Dragon by Komodo Chess|Komodo Dragon]], [[Ethereal]], [[Seer]]
Line 161: Line 163:
 
===July===
 
===July===
 
* <span id="KingPlacementsCont"></span>[http://www.talkchess.com/forum3/viewtopic.php?f=7&t=75506&start=39 Re: NNUE Question - King Placements] by [[Tomasz Sobczyk]], [[CCC]], July 01, 2021 » [[#KingPlacements|NNUE Question]]
 
* <span id="KingPlacementsCont"></span>[http://www.talkchess.com/forum3/viewtopic.php?f=7&t=75506&start=39 Re: NNUE Question - King Placements] by [[Tomasz Sobczyk]], [[CCC]], July 01, 2021 » [[#KingPlacements|NNUE Question]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77602 Before things become more messy than they already are] by [[Ed Schroder|Ed Schröder]], [[CCC]], July 02, 2021
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=7&t=77606 NNUE training set generation] by [[Edsel Apostol]], [[CCC]], July 03, 2021
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77612 Time to rethink what Albert Silver has done?] by [[Srdja Matovic]], [[CCC]], July 03, 2021 » [[Fat Fritz#Fat Fritz 2|Fat Fritz 2]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77639 Would the ICGA have accepted today's NNUE engines?] by Madeleine Birchfield, [[CCC]], July 05, 2021 » [[ICGA]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77664 Koivisto 5.0] by [[Finn Eggers]], [[CCC]], July 07, 2021 » [[Koivisto]]
 +
* [http://www.talkchess.com/forum3/viewtopic.php?f=2&t=77681 NNUE one year retrospective] by Madeleine Birchfield, [[CCC]], July 09, 2021
  
 
=External Links=
 
=External Links=
Line 192: Line 200:
 
* [https://software.intel.com/content/www/us/en/develop/articles/lower-numerical-precision-deep-learning-inference-and-training.html Lower Numerical Precision Deep Learning Inference and Training] by [https://community.intel.com/t5/user/viewprofilepage/user-id/134067 Andres Rodriguez] et al., [[Intel]], January 19, 2018 » [[AVX-512]]
 
* [https://software.intel.com/content/www/us/en/develop/articles/lower-numerical-precision-deep-learning-inference-and-training.html Lower Numerical Precision Deep Learning Inference and Training] by [https://community.intel.com/t5/user/viewprofilepage/user-id/134067 Andres Rodriguez] et al., [[Intel]], January 19, 2018 » [[AVX-512]]
 
* [https://en.wikipedia.org/wiki/Nue Nue from Wikipedia]
 
* [https://en.wikipedia.org/wiki/Nue Nue from Wikipedia]
 +
* [[:Category:Hiromi Uehara|Hiromi]] - [https://en.wikipedia.org/wiki/Spectrum_(Hiromi_album) Spectrum], 2019, [https://en.wikipedia.org/wiki/YouTube YouTube] Video
 +
: {{#evu:https://www.youtube.com/watch?v=A8RCz_RoefM|alignment=left|valignment=top}}
  
 
=References=  
 
=References=  
Line 197: Line 207:
 
'''[[Neural Networks|Up one Level]]'''
 
'''[[Neural Networks|Up one Level]]'''
 
[[Category:Toriyama Sekien]]
 
[[Category:Toriyama Sekien]]
 +
[[Category:Hiromi Uehara]]

Revision as of 08:59, 20 July 2021

Home * Learning * Neural Networks * NNUE

Toriyama Sekien - Nue (鵺) [1] [2]

NNUE, (ƎUИИ Efficiently Updatable Neural Networks)
a Neural Network architecture intended to replace the evaluation of Shogi, chess and other board game playing alpha-beta searchers running on a CPU. Inspired by Kunihito Hoki's approach of piece-square tables indexed by king location, and further two-piece locations and side to move as applied in his Shogi engine Bonanza [3], NNUE was introduced in 2018 by Yu Nasu [4], and was used in Shogi adaptations of Stockfish such as YaneuraOu [5], and Kristallweizen [6], apparently with AlphaZero strength [7].

Stockfish NNUE

As reported by Henk Drost [8], Nodchip incorporated NNUE into the chess playing Stockfish 10 as a proof of concept. Stockfish NNUE was born, and in summer 2020 the computer chess community bursts out enthusiastically due to its rapidly raising playing strength with different networks trained using a mixture of supervised and reinforcement learning methods - despite the approximately halved search speed, becoming stronger than its original [9], finally responsible for the huge strength improvement of Stockfish 12.

NNUE Engines

see Category:NNUE

Being tempted by the success of Stockfish NNUE and attracted by how easy the method and small the code is, many engine developers have started testing and applying NNUE. For quick trials and evaluating before going into serious development, some of them borrowed and/or rewrote NNUE code and use networks from Stockfish NNUE. Most of them reported positive results, such as David Carteau with Orion [10], Ehsan Rashid with DON [11], various Stockfish derivatives by Michael Byrne [12], and Volodymyr Shcherbyna with Igel [13] using the Night Nurse NNUE net by Dietrich Kappe [14]. Daniel Shawul added NNUE support à la CFish into his egbbdll probing library of Scorpio [15] [16], making it even easier to use NNUE. The promising engines Halogen 7 and 8 by Kieren Pearson, and Seer by Connor McMonigle came with their own, distinct NNUE implementations, and on November 10, 2020, the commercial Dragon by Komodo Chess aka Komodo NNUE appeared [17], trying to close the gap to Stockfish NNUE. The commercial Fat Fritz 2.0, based on a slightly modified Stockfish 12 using a customized, double sized network, was released by ChessBase in February 2021.

NN Structure

The neural network of Stockfish NNUE consists of four layers, W1 through W4. The input layer W1 is heavily overparametrized, feeding in the board representation for various king configurations. The efficiency of the net is due to incremental update of W1 in make and unmake move, where only a fraction of its neurons need to be recalculated. The remaining three layers with 32x2x256, 32x32 and 32x1 weights are computational less expensive, best calculated using appropriate SIMD instructions like AVX2 on x86-64, or if available, AVX-512.

NNUE.jpg

NNUE structure with incremental update [18]

See also

Publications

Forum Posts

2020

January ...

Re: The Stockfish of shogi by Gian-Carlo Pascutto, CCC, January 18, 2020

July

Re: NNUE accessible explanation by Jonathan Rosenthal, CCC, July 23, 2020
Re: NNUE accessible explanation by Jonathan Rosenthal, CCC, July 24, 2020
Re: NNUE accessible explanation by Jonathan Rosenthal, CCC, August 03, 2020

August

September

Re: First success with neural nets by Jonathan Kreuzer, CCC, November 11, 2020 » Checkers

October

Re: Hacking around CFish NNUE by Daniel Shawul, CCC, October 15, 2020 » Scorpio
Re: How to scale stockfish NNUE score? by Daniel Shawul, CCC, October 17, 2020
July 01, 2021 continuation

November

Re: Speculations about NNUE development (was New engine releases 2020) by Connor McMonigle, CCC, November 12, 2020
Re: Speculations about NNUE development (was New engine releases 2020) by Connor McMonigle, CCC, November 12, 2020 » Dragon by Komodo Chess, Seer, Halogen

December

2021

January

February

March

April

May

June

Re: Commercial Release of Ethereal 13.00 (NNUE) for AVX2 Systems by Andrew Grant, CCC, June 04, 2021 » HalfKP
Re: will Tcec allow Stockfish with a Leela net to play? by Daniel Shawul, CCC, June 18, 2021 » Scorpio
Re: will Tcec allow Stockfish with a Leela net to play? by Vivien Clauzon, CCC, June 18, 2021 » Minic

July

External Links

NNUE

Learn Next Generation Shogi Thinking Engine, NNUE Function (Part 1. Network Structure) - Computer Shogi
Let's Learn Next Generation Shogi Thinking Engine, NNUE Function (Part 2. Remodeling/Learning) - Computer Shogi

NNUE libraries

Some developers disintegrate and rewrite the Stockfish NNUE code into independent libraries which can be much easier to embed into other chess engines.

Source Code

Misc

References

  1. Nue (鵺) from the Konjaku Gazu Zoku Hyakki (今昔画図続百鬼) by Toriyama Sekien, circa 1779, Wikimedia Commons
  2. Re: What does NNUE actually mean by Henk Drost, CCC, July 29, 2020
  3. 機械学習エンジニアのための将棋AI開発入門その1 Introduction to Shogi AI development for machine learning engineers Part 1, May 03, 2020 (Japanese)
  4. Yu Nasu (2018). ƎUИИ Efficiently Updatable Neural-Network based Evaluation Functions for Computer Shogi. Ziosoft Computer Shogi Club, pdf (Japanese with English abstract)
  5. GitHub - yaneurao/YaneuraOu: YaneuraOu is the World's Strongest Shogi engine(AI player), WCSC29 1st winner, educational and USI compliant engine
  6. GitHub - Tama4649/Kristallweizen: 第29回世界コンピュータ将棋選手権 準優勝のKristallweizenです。
  7. The Stockfish of shogi by Larry Kaufman, CCC, January 07, 2020
  8. Stockfish NN release (NNUE) by Henk Drost, CCC, May 31, 2020
  9. Can the sardine! NNUE clobbers SF by Henk Drost, CCC, July 16, 2020
  10. Orion 0.7 : NNUE experiment by David Carteau, CCC, August 19, 2020
  11. Re: New engine releases 2020...Don NNUE 2020? by supersharp77, CCC, August 19, 2020
  12. ... the last shall be first ... by MikeB, CCC, 19 Aug 2020
  13. Introducing Igel chess engine by Volodymyr Shcherbyna, CCC, 20 Aug 2020
  14. Night Nurse 0.2 by Dietrich Kappe, CCC, August 19, 2020
  15. Re: Hacking around CFish NNUE by Daniel Shawul, CCC, October 15, 2020
  16. Re: How to scale stockfish NNUE score? by Daniel Shawul, CCC, October 17, 2020
  17. Dragon by Komodo Chess by Larry Kaufman, CCC, November 10, 2020
  18. Image from Yu Nasu (2018). ƎUИИ Efficiently Updatable Neural-Network based Evaluation Functions for Computer Shogi. Ziosoft Computer Shogi Club, pdf (Japanese with English abstract)
  19. Translation of Yu Nasu's NNUE paper by Dominik Klein, CCC, January 07, 2021
  20. Outer product from Wikipedia
  21. Tensor product from Wikipedia
  22. PyTorch from Wikipedia
  23. TensorFlow from Wikipedia
  24. Vafra by Robert Jurjević
  25. Update default net to nn-8a08400ed089.nnue by Sopel97 · Pull Request #3474 · official-stockfish/Stockfish · GitHub by Tomasz Sobczyk
  26. nnue-trainer by Jon Dart, CCC, March 27, 2021

Up one Level