Repository navigation
Accumulate low-precision search averages in float32 - #128
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #127.
Accumulate the node's weighted return sum and visit denominator in at least float32, then cast back to the existing tree dtype. This avoids float16 overflow before division and conversion of large visit counts to half precision.
Tree storage, visit accounting and float32 arithmetic are preserved. This is independent of #126's Q-normalization change.
Validation
python -m pytest -q --pyargs mctx46 tests passed, including all 24 existing tests and 22 new cases. The new suite covers float16/bfloat16/float32 values, opposite-sign returns, large visit counts, eager/JIT execution and the public MuZero policy. Ten cases fail on unchanged source.
The full suite ran from a temporary child directory so the repository's existing JSON fixture paths resolve correctly. Another 22 tests passed in a separate compatibility checkout containing #116's backward-pass refactor with the arithmetic correction applied inside it; that refactor is not included here.
Tests used macOS CPU and JAX 0.11.2. No accelerator, trained model or full game benchmark was run. Already-overflowed returns and general float32 overflow remain outside this correction.
New-test formatting, scoped syntax/lint checks and
git diff --checkpass. No dependency or workflow changes.