|
io-chess
UCI chess engine
|
Thread-local evaluator context utilizing the MoE network. More...
#include <EvalContextMoECache.h>


Public Member Functions | |
| EvalContextMoECache (const std::string &weightsPath) | |
| EvalContextMoECache (std::shared_ptr< const EvalContextMoECacheSharedModel > sharedModel) | |
| float | evaluate (const Board &board, int ply=0) override |
| Evaluates the board from the perspective of the side to move. | |
| WDLConverter::WDL | evaluateWDL (const Board &board, int ply=0) override |
| Evaluates the board and returns Win/Draw/Loss probabilities. | |
| void | setAggression (float aggression) override |
| Sets the contempt or aggression factor for the evaluator. | |
| void | setEvalScale (int base, int weight) override |
| Sets the scaling parameters for the evaluation score. | |
| void | setEvalNormalization (bool enable) override |
| Enables or disables dynamic evaluation normalization. | |
| void | setIncrementalRebuildInterval (int interval) override |
| Sets the interval for forcing full feature rebuilds (to correct accumulation errors). | |
| uint64_t | getFullRebuilds () const override |
| Retrieves the number of full feature rebuilds performed (for profiling). | |
| Public Member Functions inherited from IEvaluator | |
| virtual | ~IEvaluator ()=default |
| virtual float | evaluate (const ChessInput &input) |
| Evaluates the position using pre-computed features. | |
Static Public Member Functions | |
| static std::shared_ptr< const EvalContextMoECacheSharedModel > | loadSharedModel (const std::string &weightsPath) |
| Loads the shared model weights from disk. | |
Private Member Functions | |
| void | init_from_shared_model (std::shared_ptr< const EvalContextMoECacheSharedModel > shared) |
| void | load_weights_into_model (const std::string &weightsPath) |
Static Private Member Functions | |
| static uint32_t | read_u32 (std::ifstream &in) |
| template<typename FloatContainer> | |
| static void | read_floats (std::ifstream &in, FloatContainer &dst, size_t n) |
| static void | read_floats_raw (std::ifstream &in, float *dst, size_t n) |
| static ExpertPoolMode | pool_mode_from_code (int code) |
| template<typename SrcContainer, typename DstContainer> | |
| static void | transpose_copy (const SrcContainer &src, DstContainer &dst, int rows, int cols) |
| static void | load_weights_into_target (const std::string &weightsPath, BenchConfig &cfg, SharedMoEWeights &weights) |
Private Attributes | |
| BenchConfig | cfg_ {} |
| std::shared_ptr< const EvalContextMoECacheSharedModel > | sharedModel_ {} |
| std::array< MoEDoubleAccumulator, 2 > | models_ {} |
| FactorizedInput | scratchInput_ {} |
| std::array< FactorizedInput, 2 > | prevInputByStm_ {} |
| std::array< bool, 2 > | hasPrevByStm_ {{false, false}} |
| WDLConverter | wdlConverter_ |
| int | evalScaleBase_ = 750 |
| int | evalScaleWeight_ = 25 |
| bool | enableEvalNormalization_ = true |
| int | rebuildEveryNEvals_ = 0 |
| std::array< uint32_t, 2 > | evalsSinceFullByStm_ {{0, 0}} |
| std::atomic< uint64_t > | totalRebuilds_ {0} |
Static Private Attributes | |
| static constexpr uint32_t | kMagicWeights = 0x32454F4D |
| static constexpr uint32_t | kVersion = 1 |
Thread-local evaluator context utilizing the MoE network.
Maintains incremental accumulator state and evaluates positions rapidly.
|
explicit |

|
explicit |

|
overridevirtual |
Evaluates the board from the perspective of the side to move.
| board | The current chess board state. |
| ply | The current depth from the root of the search (used for scaling). |
Implements IEvaluator.

|
overridevirtual |
Evaluates the board and returns Win/Draw/Loss probabilities.
| board | The current chess board state. |
| ply | The current depth from the root of the search. |
Reimplemented from IEvaluator.


|
inlineoverridevirtual |
Retrieves the number of full feature rebuilds performed (for profiling).
Reimplemented from IEvaluator.
|
private |

|
private |


|
staticprivate |


|
static |
Loads the shared model weights from disk.


|
staticprivate |

|
inlinestaticprivate |

|
staticprivate |
|
staticprivate |

|
inlineoverridevirtual |
Sets the contempt or aggression factor for the evaluator.
| aggression | The aggression factor (positive encourages risk, negative encourages draws). |
Reimplemented from IEvaluator.
|
inlineoverridevirtual |
Enables or disables dynamic evaluation normalization.
| enable | True to enable normalization, false to use raw scores. |
Reimplemented from IEvaluator.
|
inlineoverridevirtual |
Sets the scaling parameters for the evaluation score.
| base | The base scaling divisor. |
| weight | The material weight scaling factor. |
Reimplemented from IEvaluator.
|
inlineoverridevirtual |
Sets the interval for forcing full feature rebuilds (to correct accumulation errors).
| interval | The number of incremental updates before forcing a rebuild. |
Reimplemented from IEvaluator.
|
inlinestaticprivate |

|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |