[Question] The bot is always playing low rows
As I'd believe porting Katago to CoreML backend is achievable (because of @y-ich already done that ), so I would like to try it myself.
My porting approach is:
- Convert the TF model to CoreML using coremltools.
- Writing a backend of CoreML in Objective-C so it could load the converted model.
- Load the input into inputBuffers and feed them in the model.
- Get the result.
It's now running, but not generate the correct output. After calling genmove, the bot plays like below, which must be wrong.
A B C D E F G H J K L M N O P Q R S T
19 @ . . . . . . . . . . . . . . . . . .
18 . . . . . . . . . . . . . . . . . . .
17 . . . . . . . . . . . . . . . . . . .
16 . . . X1. . . . . . . . . . . . . . .
15 . . . . . . . . . . . . . . . . . . .
14 . . . . . . . . . . . . . . . . . . .
13 . . . . . . . . . . . . . . . . . . .
12 . . . . . . . . . . . . . . . . . . .
11 . . . . . . . . . . . . . . . . . . .
10 . . . . . . . . . . . . . . . . . . .
9 . . . . . . . . . . . . . . . . . . .
8 . . . . . . . . . . . . . . . . . . .
7 . . . . . . . . . . . . . . . . . . .
6 . . . . . . . . . . . . . . . . . . .
5 . . . . . . . . . . . . . . . . . . .
4 . . . . . . . . . . . . . . . . . . .
3 . . . . . . . . . . . . . . . . . . .
2 . . . . . . . . . . . . . . . . . . .
1 . . . . . . . . . . . . . . . . . . .
koPOSITIONALscoreAREAtaxNONEsui1komi7.5
Time taken: 7.20394
Root visits: 18
New playouts: 18
NN rows: 18
NN batches: 10
NN avg batch size: 1.8
PV: A19 C19 D19 M10
Tree:
: T 41.90c W 36.36c S 4.31c (+21.5 L -2.0) N 18 -- A19 C19 D19 M10
---White(v)---
A19 : T 26.13c W 17.79c S 7.44c (+39.8 L -10.0) LCB 134.32c P 0.28% WF 11.3 PSV 10 N 10 -- A19 C19 D19 M10
B19 : T 90.34c W 85.08c S 5.26c (+12.3 L +9.2) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- B19
C19 : T 79.16c W 100.00c S -20.84c (-138.8 L +47.7) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- C19
D19 : T 85.43c W 80.70c S 4.74c (+11.0 L +8.3) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- D19
E19 : T 84.23c W 79.56c S 4.67c (+10.9 L +7.8) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- E19
F19 : T 83.06c W 78.52c S 4.55c (+10.6 L +7.1) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- F19
G19 : T 87.46c W 82.53c S 4.93c (+11.5 L +8.2) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- G19
H19 : T 87.36c W 82.44c S 4.92c (+11.5 L +7.8) LCB 260.00c P 0.28% WF 0.8 PSV 0 N 1 -- H19
I'm not very familiar with the inside of Katago layers. Is there any hint for me to troubleshot and debug?
Many thanks!
I think I got the output shape wrong here, the swa_model_policy_output which is in the coremltools generated model, and its shape is (1,2,362), however, in the code, I only initial an array of 361.
However, I'm a little curious that why it's a shape of 2, rather than 1.
My assumption seems to be correct that how to handle the output is the key.
Might be a stupid question:
In the opencl implementation, the policy result is xSize * ySize,
however, in other implementation, the policy result size is xSize * ySize + 1 via call NNPos::getPolicySize method.
Directly above the line you quoted, you have:
policyPassResultBufferElts = (size_t)maxBatchSize * (1);
The +1 is because of the pass move. Each backend computes the same thing mathematically, but different backends may have slightly different buffers or use slightly different ways to compute it, the OpenCL backend for example keeps it separate and then later appends it to the final result.
Your output seems to have much more wrong than just the passing move. Notice how every move has P 0.28% - this is equal to 1/361 or 1/362. So your output is currently assigning exactly equal probability to every move. Since every move is exactly equal, the search tries moves simply in order.
Thanks for the reply! I think I figure it out there is a mistake while parsing the output from the model.