fix division by zero in anneal_beta when total_timesteps < batch_size#489
Open
valtterivalo wants to merge 1 commit intoPufferAI:4.0from
Open
fix division by zero in anneal_beta when total_timesteps < batch_size#489valtterivalo wants to merge 1 commit intoPufferAI:4.0from
valtterivalo wants to merge 1 commit intoPufferAI:4.0from
Conversation
When total_timesteps is smaller than one batch (total_agents * horizon), total_epochs = total_timesteps / batch_size evaluates to 0. The anneal_beta formula then computes current_epoch / total_epochs = 0 / 0, which is NaN in IEEE 754. This NaN propagates through priority replay weights (mb_prio) into the loss, silently producing NaN for all losses. cosine_annealing() already guards against this (line 714: if T == 0 return lr_base), but the anneal_beta computation on the next line does not. Clamping total_epochs to at least 1 fixes both.
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.
total_epochs = total_timesteps / batch_sizeis integer division, so whentotal_timesteps < batch_size(e.g. short smoke tests with 50k steps), it evaluates to 0. this causesanneal_betato compute0/0 = NaN, which propagates throughmb_priointo the PPO loss.cosine_annealing()already handles this case (if (T == 0) return lr_base) butanneal_betadidn't have the same guard.fix: clamp
total_epochsto at least 1.