Repository navigation
Conversation
muzero_policy with dirichlet_fraction=0.0 still sampled the Dirichlet noise (gamma sampling, several while loops in the compiled helper) and multiplied it by zero. The same happened in gumbel_muzero_policy with gumbel_scale=0.0, the documented setting for evaluating perfect-information games. A Python zero now returns the probs (or zero Gumbels) directly. The random key is still split in the same way, so the other keys are unchanged, and a traced zero keeps the previous path. The previous mixing promoted bfloat16 and float16 probs to the dtype of the Dirichlet sample (the default float type). The shortcut keeps that promotion, so its outputs and dtypes match those of a traced zero fraction. The tests compare the helper and the whole tree of muzero_policy against a traced zero, dtypes included, for bfloat16, float16 and float32 priors.
yoch
force-pushed
the
pr/zero-noise-shortcut
branch
from
October 14, 2026 18:31
0910efc to
fbc60c0
Compare
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.
muzero_policy(..., dirichlet_fraction=0.0)still samples the Dirichlet noise (gamma sampling, a few while loops in the compiled helper) and multiplies it by zero. The same happens ingumbel_muzero_policywithgumbel_scale=0.0, which is the documented setting for evaluating perfect-information games.When the coefficient is a Python zero (static), the helper now returns the probs, or zero Gumbels, directly. The random key is still split in the same way, so the other keys are unchanged, and a traced zero keeps the old path. On a CPU with batch 128 and 81 actions, a whole 8-simulation
muzero_policycall withdirichlet_fraction=0.0goes from 22.5 ms to 12.3 ms (best of 7); with a non-zero fraction the time is unchanged (22.1 ms against 21.5 ms), as expected. The gain is only visible on short searches, where the sampling is a large share of the call.One detail worth a look in review: the old mixing
(1 - fraction) * probs + fraction * noisepromotes bfloat16 or float16 probs to the default float type. The shortcut keeps that promotion (it casts the probs without sampling), so outputs and dtypes match a traced zero fraction. The tests check this for bfloat16, float16 and float32 priors, on the helper and on the full tree ofmuzero_policy.Tests: pytest from
_testing/: 29 passed, pylint clean on the changed source file (the one remainingline-too-longmessage inpolicies_test.pyis a line that is already onmain).On a Colab T4 the gain is small (a whole 8-simulation call at batch 128 and 81 actions: 5.9 ms against 6.0 ms with
dirichlet_fraction=0.0, medians of 5; 5.4 ms against 6.0 ms for the best call) and there is no change with a non-zero fraction (5.8 ms against 6.3 ms, same trees). On a TPU v5e the same call goes from 3.39 ms to 3.24 ms (medians of 5; 3.41 against 3.26 with a non-zero fraction), so the benefit is mostly on CPU and for short searches; I see no cost elsewhere.Possible overlap: #123 and #121 also edit
policies.py; both apply cleanly on top of this branch.