Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward analysis does not retain any tree info. #517

Closed
Videodr0me opened this issue Nov 17, 2018 · 4 comments
Closed

Backward analysis does not retain any tree info. #517

Videodr0me opened this issue Nov 17, 2018 · 4 comments

Comments

@Videodr0me
Copy link
Collaborator

In contrast to standard hash-tables in a/b engines, leela currently does not allow "backward" analysis while retaining information from previous searches. Forward analysis is possible as the tree is retained, but on going backward the tree is trimmed. The following is a scheme which might allow to use information of previous searches when going backward in a tree, while ensuring visit consistency in a tree (parent visits = sum of all child visits + 1).

If we go backward in a tree, we convert all visit distributions to new policy distributions for the nodes in the tree and update all cached NN evals to reflect the new policy. This idea rests on:

(1) visit distributions after search representing a more accurate policy value compared to initial policy
(2) all visits can safely be reset as the information is now converted to new policies.
(3) search can commence as ususal using the new policies for cached nodes.

If NN cache is not large enough some information will be lost, but one could prefer new policies for nodes along the "old" main line and or other schemes. As new policy is more accurate than old policy, even if only partially available it should still yield better analysis results than trimming the tree.

@Naphthalin
Copy link
Contributor

While being useful for analysis, the suggested behavior from this issue is incompatible with the Lc0 MCTS and would systematically distort search results. This isn't true for MCTS-minimax-hybrids like #963 though; so while the current situation can only rely on the NN cache and external GUIs like Nibbler, introducing the option of not throwing away the tree when moving backwards would be useful for "use at your own risk" with master and forks like #963 capable of reporting minimax evals. Issue should remain open.

@mooskagh
Copy link
Member

mooskagh commented May 9, 2020

There are approaches to do that, and it's surely useful (and it's the most requested feature from top GMs).
But probably will be a part of "Lc0 v2", whenever that happens..
Not sure what to do with the issue, probably worth keeping open.

@Naphthalin
Copy link
Contributor

As #963 now is functional, implementing an AnalyseMode which retains the tree when moving backwards could be tackled indeed.

Steps needed:

  • make Lc0 responsive to UCI_AnalyseMode on/off
  • deactivate the "tree cutting" when making a move or going back if UCI_AnalyseMode is on
  • make sure that current root node is allowed to have a parent
  • when switching to UCI_AnalyseMode off, all nodes which aren't in the subtree of current root should be cleaned
  • from GUI side: implement AnalyseMode toggle, maybe implement a convenience cleanup menu button which sends UCI_AnalyseMode off isready UCI_AnalyseMode on

@Naphthalin
Copy link
Contributor

For a working implementation, see #1455 and #1543, and impossible to implement in Lc0 as of now without other major changes. Will be addressed in the future, likely after #1734 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants