|
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) |
| Initializes the thread-local context from the pre-loaded shared weights. | |
| void | load_weights_into_model (const std::string &weightsPath) |
| Loads neural network weights directly into the thread-local model (legacy usage). | |
Static Private Member Functions | |
| static uint32_t | read_u32 (std::ifstream &in) |
| Reads a 32-bit unsigned integer from the binary weights stream. | |
| template<typename FloatContainer> | |
| static void | read_floats (std::ifstream &in, FloatContainer &dst, size_t n) |
| Reads a block of float values into a resizing container from the binary stream. | |
| static void | read_floats_raw (std::ifstream &in, float *dst, size_t n) |
| Reads a raw block of floats into a contiguous C-style array. | |
| static ExpertPoolMode | pool_mode_from_code (int code) |
| Converts an integer ID stored in the weights file to an ExpertPoolMode enum. | |
| template<typename SrcContainer, typename DstContainer> | |
| static void | transpose_copy (const SrcContainer &src, DstContainer &dst, int rows, int cols) |
| Copies and transposes a matrix tensor (used to align weights for faster cache hits during inference). | |
| static void | load_weights_into_target (const std::string &weightsPath, BenchConfig &cfg, SharedMoEWeights &weights) |
| Loads neural network weights from a binary file into a shared weights container. | |
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 |
Initializes the thread-local context from the pre-loaded shared weights.

|
private |
Loads neural network weights directly into the thread-local model (legacy usage).


|
staticprivate |
Loads neural network weights from a binary file into a shared weights container.


|
static |
Loads the shared model weights from disk.


|
staticprivate |
Converts an integer ID stored in the weights file to an ExpertPoolMode enum.

|
inlinestaticprivate |
Reads a block of float values into a resizing container from the binary stream.

|
staticprivate |
Reads a raw block of floats into a contiguous C-style array.
|
staticprivate |
Reads a 32-bit unsigned integer from the binary weights stream.

|
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 |
Copies and transposes a matrix tensor (used to align weights for faster cache hits during inference).

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