【KataGo特集:第3回】KataGoの設定ファイル

この記事は約30分で読めます。

gtp_example.cfgを読み解く

C++ (非Python) gtpボットの設定

オンラインサーバー/実際のトーナメント/試合での実行

これらの実行を計画している場合は、コミとハンディキャップゲームの適切な処理、ゲーム終了時のクリーンアップ、およびその他のさまざまな詳細について、以下の「ルール」セクションを注意深く読むことをお勧めします。

パフォーマンスとメモリの使用に関する注意

次の1つ以上を調整することをお勧めします。

numSearchThreads:

使用するCPUスレッドの数。 GPUが強力な場合、GPUを十分に活用するために十分な大きさのバッチを供給するために多くのスレッドが必要になるため、実際にはプロセッサのコア数よりもはるかに多くなる可能性があります。

./katago benchmark」コマンドは、このパラメーターを調整したり、以下の他のパラメーターへの変更の影響をテストしたりするのに役立ちます。

nnCacheSizePowerOfTwo:

これは、プライマリRAM/メモリの使用量であるNNキャッシュサイズを制御します。
メモリの使用量を気にせず、数万回以上の探索で検索のパフォーマンスを向上させたい場合は、これを増やしてください。 メモリ使用量を制限する場合は、これを減らします。

少々の数学を喜んでやってくれる場合: 各ニューラルネットのエントリはおおよそ1.5KB使用します。ただし、碁盤全体の所有権/領域の視覚化を使用する場合を除き、各エントリはおおよそ3KB使用します。 エントリ数は(2 ^ nnCacheSizePowerOfTwo)、
たとえば、2^18 = 262144です。

その他の注意事項:

複数のGPUを使用している場合は、以下の「OpenCL GPU設定」または「CUDA GPU設定」を参照してください。

OpenCLを使用している場合は、KataGoが正しいデバイスを取得していることを確認する必要があります。
(たとえば、一部のシステムにはIntel CPU OpenCLとGPU OpenCLの両方がある場合があり、KataGoが間違ったものを選択しているように見える場合は、以下で「openclGpuToUse」を指定してこれを修正します)

また、使用目的に応じて、「maxVisits」、「ponderingEnabled」、「resignThreshold」、および場合によっては他のパラメーターを調整することもできます。

# For the `katago gtp` command, ALL of THE BELOW VALUES MAY BE SET OR OVERRIDDEN if desired via
# the command line arguments:
# -override-config KEY=VALUE,KEY=VALUE,...

katago gtpコマンドの場合、コマンドライン引数を使用して、必要に応じて以下の値をすべて設定または上書きできます。
-override-config KEY=VALUE,KEY=VALUE,...

Logs and files(ログとファイル)

Where to output log?(ログの出力先)

▼KataGoを実行するたびに、ここで指定したディレクトリに個別のファイルが作成され、ログを記録します。

logDir = gtp_logs

▼logDirの代わりに指定すると、単一のファイルにログを記録します。

# logFile = gtp.log

Logging options(ログのオプション)

▼すべてのGTP通信のログを記録する(true/false)
▼探索情報のログを記録する(true/false)
▼標準エラー出力(stderr)にログを記録する(true/false)

logAllGTPCommunication = true
logSearchInfo = true
logToStderr = false

▼GTPの起動時に標準エラー出力(stderr)に情報を出力する(true/false)

# startupPrintMessageToStderr = false

▼OGSへのmalkovichチャットなどで使用するためのstderrを出力する(true/false)

# ogsChatToStderr = true

▼KataGoのopenCLTunerファイルやキャッシュデータなどの保存先ディレクトリを指定する

# homeDataDir = DIRECTORY

Analysis(分析)

▼lz-analyzeおよびその他の場所で出力される分析の最大長の設定。バリエーションの最初の移動後の移動数。

# analysisPVLen = 15

▼チャットと分析の勝率を(BLACK | WHITE | SIDETOMOVE)としてレポート。
デフォルトはSIDETOMOVEです。LZを使用するツールの多くがこれを期待します。

# reportAnalysisWinratesAs = SIDETOMOVE

▼値を大きくすると、KataGoは上位の動きをより深く正確に探索できなくなりますが、分析のために、より多様な動きを探索して評価します(プレイには影響しません)。
デフォルトは0.04です。
1のような極端な値は、非常に悪い動きであっても、ボード上のすべての動きに多くのプレイアウトを分散します。

# analysisWideRootNoise = 0.04

Default rules(デフォルトのルール)

ルールの説明については、https://lightvector.github.io/KataGo/rules.htmlを参照してください。
これらのルールはデフォルトであり、実行中にいくつかのカスタムGTPコマンドで変更できます。
これらのコマンドについては、https://github.com/lightvector/KataGo/blob/master/docs/GTP_Extensions.mdを参照してください。

▼ルール値には、下記のほか「中国」「日本」「韓国」「aga」「chinese-ogs」「new-zealand」があります。
KataGoは、指定した人間用ルールセットと完全に一致するとは主張していませんが、実装されているルールを考慮して可能な限り厳密に動作するように努めます。

rules = tromp-taylor

▼以下を使用して、個々のルールの任意の組み合わせを指定します。

# koRule = SIMPLE       # 単純なコウルール(トリプルコウ = 結果なし)
# koRule = POSITIONAL   # Positional superko
# koRule = SITUATIONAL  # Situational superko

▼エリア採点と領地採点のルール

# scoringRule = AREA       # エリアスコアリング
# scoringRule = TERRITORY  # テリトリースコアリング (このルールは、一種の特別なコンピューターフレンドリーな領域ルールセットを使用します)
# taxRule = NONE  # 囲まれたすべての空のポイントがスコアリングされます
# taxRule = SEKI  # 関の目はポイントとしてカウントされません
# taxRule = ALL   # すべてのグループは、生きるために必要な2つの目に対して最大2ポイントの課税を受けます

▼マルチストーン自殺は合法ですか? (単石自殺は常に違法です)。

# multiStoneSuicideLegal = true

▼エリアスコアリング時にtrueに設定して、最初のパスに0.5ポイントを付与します。

# hasButton = false

▼通過する前にすべての石をキャプチャする必要があるコンピュータルールセットを除いて、trueに設定します。

# friendlyPassOk = true
# whiteHandicapBonus = 0    # ハンディキャップゲームでは、白に黒のハンディキャップストーンの補償を与えない (Tromp-taylor, NZ, JP)
# whiteHandicapBonus = N-1  # ハンディキャップゲームでは、黒のハンディキャップストーンに白のN-1ポイントを与えます (AGA)
# whiteHandicapBonus = N    # ハンディキャップゲームでは、黒のハンディキャップストーンに白のNポイントを与えます (Chinese)

GTPで指定されていない場合は、コメントを外して変更し、起動時にKataGoがデフォルトで使用するボードサイズを調整します。

# defaultBoardSize = 19

▼GUIまたはGTPコントローラーが別のコミを設定しようとした場合でも、これを指定して特定のコミを強制します。

# ignoreGTPAndForceKomi = 7

Bot behavior(ボットの動作)

Resignation(投了)

▼少なくともresignConsecTurnsが連続している場合、winLossUtility([-1,1]スケール)がresignThresholdを下回っている場合に投了が発生します。

allowResignation = true
resignThreshold = -0.90
resignConsecTurns = 3

▼この行のコメントを解除して、KataGoがクローズゲームを辞任しないようにします。これは、この数ポイントよりも少なくなります。

# resignMinScoreDifference = 10

Handicap(ハンディキャップ)

▼ゲームの開始時に黒が連続して多くの動きをする場合、そのゲームはハンディキャップゲームであると想定します。
これは、一部のサーバーおよび一部のGUIで必要であり、多くのSGFファイルから初期化する場合にも必要です。これは、GTP「place_free_handicap」コマンドではなく、黒に対して繰り返しGTP「play」コマンドを使用してハンディキャップゲームをセットアップする場合があります。
ただし、whiteHandicapBonusが使用されていて、サーバーにそのようなプラクティスがない場合は、コミの誤った理解につながる可能性もあります。
デフォルトはtrueです。 この動作を無効にするには、コメントを解除してfalseに設定します。

# assumeMultipleStartingBlackMovesAreHandicap = true

▼KataGoをハンディキャップまたは変更されたコミゲームで動的に調整し、それらのゲーム設定に基づいて、対戦相手よりも強いまたは弱い必要があると想定し、それに応じてプレイします。 適切な安全/攻撃的なプレーを優先するように勝率とスコアにバイアスをかけることにより、ハンディキャップの強さを大幅に改善します。
分析(lz-analyze、kata-analyze、Lizzieなどのプログラムで使用)には影響しないため、分析は偏りがありません。
コメントを外してこれを0に設定すると、これが無効になり、KataGoが常に同じように再生されます。

# dynamicPlayoutDoublingAdvantageCapPerOppLead = 0.045

▼動的レベルの代わりに、これをコメント解除し、これを-3.0から3.0の値に設定して、KataGoの攻撃性をFIXEDレベルに設定できます。
分析ツール(lz-analyze、kata-analyze、Lizzieなどのプログラムで使用)には影響します。
ネガティブは、KataGoを対戦相手よりもはるかに弱いかのように振る舞わせ、防御的にプレイすることを好みます。
ポジティブなため、KataGoは対戦相手よりもはるかに強力であるかのように動作し、積極的にプレイしたり、わずかにオーバープレイしたりすることを好みます。
これと「dynamicPlayoutDoublingAdvantageCapPerOppLead」の両方が設定されている場合、動的はすべてのゲームに使用され、この固定値は分析ツールに使用されます。

# playoutDoublingAdvantage = 0.0

▼これらのいずれかをコメント解除すると、FIXED playoutDoublingAdvantageは、KataGoが指定された色を再生する場合にのみ適用され、反対の色を再生する場合は無効になります。

# playoutDoublingAdvantagePla = BLACK
# playoutDoublingAdvantagePla = WHITE

Passing and cleanup(パスとクリーンアップ)

▼Tromp-Taylorのルールでパスが終了して「勝つ」場合でも、ボットがパスでゲームが終了するとは決して想定しないようにします。
通常、これは、スコアリングが非トランプテイラーで実装される可能性のあるサーバーで分析または再生するために使用する場合に適しています。
デフォルトはtrueです。 これを無効にするには、コメントを解除してfalseに設定します。

# conservativePass = true

▼テリトリースコアリングを使用する場合、セルフプレイゲームは2パスを超えて続行され、人間のプレーヤーを混乱させる可能性のある特別なクリーンアップルールが適用されます。 このオプションは、GTPプレイにボットを使用するときに特別なクリーンアップフェーズに到達できないようにします。
デフォルトはtrueです。 KataGoで特別なクリーンアップを開始できるようにする場合は、コメントを解除してfalseに設定します。
たとえば、それ自体に対して、またはhttps://lightvector.github.io/KataGo/rules.htmlに記載されているルールを正確に実装した別のボットに対してテストしている場合です。

# preventCleanupPhase = true

Misc Behavior(その他の動作)

▼ボードが対称である場合は、同等の各動きのコピーを1つだけ検索します。 ko / superkoも説明しようとすると、理論的にはsuperkoに完全ではありません。
これを無効にするには、コメントを解除してfalseに設定します。

# rootSymmetryPruning = true

▼コメントを外してtrueに設定すると、KataGoネットが誤評価する特定の定石を回避し、常に再生することを好む特定の他のボットと比較して、オープニングの多様性を向上させることができます。

# avoidMYTDaggerHack = false

▼KataGoに、ボードの隅々で同じ定石をプレイすることを避けることを穏やかに好むようにします。
コメントを外して特定の値に設定します。 それ以外の場合、デフォルトは偶数ゲームでは0、ハンディキャップゲームでは0.005になります。
この設定の下部にあるAvoid SGFメカニズムも参照してください。

# avoidRepeatedPatternUtility = 0.0

▼不利なコミでもKataGoをミラー碁と少し戦わせるための実験的なロジック。
デフォルトでは無効になっています。コメントを解除し、trueに設定して有効にします。

# antiMirror = false

Search limits(探索制限)

「maxVisits」、「maxPlayouts」、「maxTime」のすべてについて、検索は引き続きGTPの時間制御に従おうとし、GTPが現在のゲームでも時計下でプレイしていることを通知した場合、指定された最大値よりも速く移動する可能性があります 。

▼設定されている場合は、探索ごとのルート訪問の最大数をここで指定した値に制限します。 (ツリーの再利用では、訪問は以前の探索をカウントします)

maxVisits = 500

▼設定されている場合は、探索ごとの新しいプレイアウトの最大数をここで指定した値に制限します。 (ツリーの再利用では、プレイアウトは以前の検索をカウントしません)

# maxPlayouts = 300

▼設定されている場合は、探索時間をこの秒数に制限します。

# maxTime = 10
# Ponder on the opponent's turn?
ponderingEnabled = false
maxTimePondering = 60  # Maximum time to ponder, in seconds. Comment out to make unlimited.
# Note: you can set "maxVisitsPondering" or "maxPlayoutsPondering" too.
# Approx number of seconds to buffer for lag for GTP time controls - will move a bit faster assuming there is this much lag per move.
lagBuffer = 1.0
# Number of threads to use in search
numSearchThreads = 6
# Play a little faster if the opponent is passing, for friendliness
searchFactorAfterOnePass = 0.50
searchFactorAfterTwoPass = 0.25
# Play a little faster if super-winning, for friendliness
searchFactorWhenWinning = 0.40
searchFactorWhenWinningThreshold = 0.95

GPU Settings(GPU設定)

# Maximum number of positions to send to a single GPU at once.
# The default value here is roughly equal to numSearchThreads, but you can specify it manually
# if you are running out of memory, or if you are using multiple GPUs that expect to split
# up the work.
# nnMaxBatchSize = <integer>
# Cache up to (2 ** this) many neural net evaluations in case of transpositions in the tree.
# Uncomment and edit to change if you want to adjust a major component of KataGo's RAM usage.
# nnCacheSizePowerOfTwo = 20
# Size of mutex pool for nnCache is (2 ** this).
# nnMutexPoolSizePowerOfTwo = 16
# Randomize board orientation when running neural net evals? Uncomment and set to false to disable.
# nnRandomize = true
# If provided, force usage of a specific seed for nnRandomize instead of randomizing.
# nnRandSeed = abcdefg
# TO USE MULTIPLE GPUS:
# Set this to the number of GPUs you have and/or would like to use.
# **AND** if it is more than 1, uncomment the appropriate CUDA or OpenCL section below.
# numNNServerThreadsPerModel = 1

CUDA GPU settings(CUDA GPU設定)

これらは、KataGoのCUDAバージョンを使用する場合にのみ適用されます。

# IF USING ONE GPU: optionally uncomment and change this if the GPU you want to use turns out to be not device 0
# cudaDeviceToUse = 0
# IF USING TWO GPUS: Uncomment these two lines (AND set numNNServerThreadsPerModel above):
# cudaDeviceToUseThread0 = 0  # change this if the first GPU you want to use turns out to be not device 0
# cudaDeviceToUseThread1 = 1  # change this if the second GPU you want to use turns out to be not device 1
# IF USING THREE GPUS: Uncomment these three lines (AND set numNNServerThreadsPerModel above):
# cudaDeviceToUseThread0 = 0  # change this if the first GPU you want to use turns out to be not device 0
# cudaDeviceToUseThread1 = 1  # change this if the second GPU you want to use turns out to be not device 1
# cudaDeviceToUseThread2 = 2  # change this if the third GPU you want to use turns out to be not device 2

GPUが4つ、5つなどある場合は、おそらくパターンを推測できるでしょう。

# KataGo will automatically use FP16 or not based on the compute capability of your NVIDIA GPU. If you
# want to try to force a particular behavior though you can uncomment these lines and change them
# to "true" or "false". E.g. it's using FP16 but on your card that's giving an error, or it's not using
# FP16 but you think it should.
# cudaUseFP16 = auto
# cudaUseNHWC = auto

OpenCL GPU settings(OpenCL GPU設定)

これらは、KataGoのOpenCLバージョンを使用する場合にのみ適用されます。

# Uncomment to tune OpenCL for every board size separately, rather than only the largest possible size
# openclReTunePerBoardSize = true
# IF USING ONE GPU: optionally uncomment and change this if the best device to use is guessed incorrectly.
# The default behavior tries to guess the 'best' GPU or device on your system to use, usually it will be a good guess.
# openclDeviceToUse = 0
# IF USING TWO GPUS: Uncomment these two lines and replace X and Y with the device ids of the devices you want to use.
# It might NOT be 0 and 1, some computers will have many OpenCL devices. You can see what the devices are when
# KataGo starts up - it should print or log all the devices it finds.
# (AND also set numNNServerThreadsPerModel above)
# openclDeviceToUseThread0 = X
# openclDeviceToUseThread1 = Y
# IF USING THREE GPUS: Uncomment these three lines and replace X and Y and Z with the device ids of the devices you want to use.
# It might NOT be 0 and 1 and 2, some computers will have many OpenCL devices. You can see what the devices are when
# KataGo starts up - it should print or log all the devices it finds.
# (AND also set numNNServerThreadsPerModel above)
# openclDeviceToUseThread0 = X
# openclDeviceToUseThread1 = Y
# openclDeviceToUseThread2 = Z

GPUが4つ、5つなどある場合は、おそらくパターンを推測できるでしょう。

# KataGo will automatically use FP16 or not based on testing your GPU during tuning. If you
# want to try to force a particular behavior though you can uncomment this lines and change it
# to "true" or "false". This is a fairly blunt setting - more detailed settings are testable
# by rerunning the tuner with various arguments.
# openclUseFP16 = auto

Eigen-specific settings(Eigen固有の設定)

これらは、KataGoのEigen(純粋なCPU)バージョンを使用する場合にのみ適用されます。

# This is the number of CPU threads for evaluating the neural net on the Eigen backend.
# It defaults to numSearchThreads.
# numEigenThreadsPerModel = X

Root move selection and biases(ルート移動の選択とバイアス)

以下の値のコメントを外して編集し、デフォルトから変更します。

# If provided, force usage of a specific seed for various things in the search instead of randomizing
# searchRandSeed = hijklmn
# Temperature for the early game, randomize between chosen moves with this temperature
# chosenMoveTemperatureEarly = 0.5
# Decay temperature for the early game by 0.5 every this many moves, scaled with board size.
# chosenMoveTemperatureHalflife = 19
# At the end of search after the early game, randomize between chosen moves with this temperature
# chosenMoveTemperature = 0.10
# Subtract this many visits from each move prior to applying chosenMoveTemperature
# (unless all moves have too few visits) to downweight unlikely moves
# chosenMoveSubtract = 0
# The same as chosenMoveSubtract but only prunes moves that fall below the threshold, does not affect moves above
# chosenMovePrune = 1
# Number of symmetries to sample (WITHOUT replacement) and average at the root
# rootNumSymmetriesToSample = 1
# Using LCB for move selection?
# useLcbForSelection = true
# How many stdevs a move needs to be better than another for LCB selection
# lcbStdevs = 5.0
# Only use LCB override when a move has this proportion of visits as the top move
# minVisitPropForLCB = 0.15

Internal params(内部パラメータ)

以下の値のコメントを外して編集し、デフォルトから変更します。

# Scales the utility of winning/losing
# winLossUtilityFactor = 1.0
# Scales the utility for trying to maximize score
# staticScoreUtilityFactor = 0.10
# dynamicScoreUtilityFactor = 0.30
# Adjust dynamic score center this proportion of the way towards zero, capped at a reasonable amount.
# dynamicScoreCenterZeroWeight = 0.20
# dynamicScoreCenterScale = 0.75
# The utility of getting a "no result" due to triple ko or other long cycle in non-superko rulesets (-1 to 1)
# noResultUtilityForWhite = 0.0
# The number of wins that a draw counts as, for white. (0 to 1)
# drawEquivalentWinsForWhite = 0.5
# Exploration constant for mcts
# cpuctExploration = 1.0
# cpuctExplorationLog = 0.45
# Parameters that control exploring more in volatile positions, exploring less in stable positions.
# cpuctUtilityStdevPrior = 0.40
# cpuctUtilityStdevPriorWeight = 2.0
# cpuctUtilityStdevScale = 0.85
# FPU reduction constant for mcts
# fpuReductionMax = 0.2
# rootFpuReductionMax = 0.1
# Parameters that control weighting of evals based on the net's own self-reported uncertainty.
# useUncertainty = true
# uncertaintyExponent = 1.0
# uncertaintyCoeff = 0.25
# Amount to apply a downweighting of children with very bad values relative to good ones
# valueWeightExponent = 0.5
# Slight incentive for the bot to behave human-like with regard to passing at the end, filling the dame,
# not wasting time playing in its own territory, etc, and not play moves that are equivalent in terms of
# points but a bit more unfriendly to humans.
# rootEndingBonusPoints = 0.5
# Make the bot prune useless moves that are just prolonging the game to avoid losing yet
# rootPruneUselessMoves = true
# Apply bias correction based on local pattern keys
# subtreeValueBiasFactor = 0.35
# subtreeValueBiasWeightExponent = 0.8
# How big to make the mutex pool for search synchronization
# mutexPoolSize = 16384
# How many virtual losses to add when a thread descends through a node
# numVirtualLossesPerThread = 1
# Improve the quality of evals under heavy multithreading
# useNoisePruning = true

Avoid SGF Patterns(SGFパターンの回避)

このセクションのパラメーターは、KataGoをカスタマイズして、起動時にロードされた一連の提供されたSGFファイルに基づいて特定のパターンに従う移動を回避するための強力な方法を提供します。 この機能を使用するには、コメントを解除してください。
さらに、SGFファイルの移動に関するコメントに文字列%SKIP%が含まれている場合、その移動はこの目的では無視されます。

# Load sgf files from this directory when the engine is started (ONLY on startup, will not reload unless engine is restarted)
# avoidSgfPatternDirs = path/to/directory/with/sgfs/
# Penalize this much utility per matching move.
# Set this negative if you instead want to make KataGo favor the SGF patterns instead of penalizing it!
# This number does not need to be large, even 0.001 will make a difference. Too-large values may lead to bad play.
# avoidSgfPatternUtility = 0.001
# Optional - load only the newest this many files
# avoidSgfPatternMaxFiles = 20
# Optional - Penalty is multiplied by this per each older SGF file, so that old sgf files matter less than newer ones.
# avoidSgfPatternLambda = 0.90
# Optional - pay attention only to moves that were made by players with this name.
# For example you can set it to the name that your bot's past games will show up as in the SGF, so that the bot will only avoid repeating
# moves that itself made in past games, not the moves that its opponents made.
# avoidSgfPatternAllowedNames = my-ogs-bot-name1,my-ogs-bot-name2
# Optional - Ignore any moves in SGF files that occurred before this turn number.
# avoidSgfPatternMinTurnNumber = 0
# For more avoid patterns:
# You can also specify a second set of parameters, and a third, fourth, etc by numbering 2,3,4,...
# avoidSgf2PatternDirs = ...
# avoidSgf2PatternUtility = ...
# avoidSgf2PatternMaxFiles = ...
# avoidSgf2PatternLambda = ...
# avoidSgf2PatternAllowedNames = ...
# avoidSgf2PatternMinTurnNumber = ...