fix: guard division-by-zero and uninitialized state in metrics/masking code#1575
Closed
mooreneural wants to merge 1 commit into
Closed
fix: guard division-by-zero and uninitialized state in metrics/masking code#1575mooreneural wants to merge 1 commit into
mooreneural wants to merge 1 commit into
Conversation
…s/masking code
- mlm_memmap.py: normalize codon weights only when mean > 0 to prevent NaN
propagating into np.random.binomial when all token weights are zero
- mlm_memmap.py: clamp conditional random-replace probability to [0, 1] and
guard against mask_replace_prob == 1.0 causing ZeroDivisionError
- dead_latents.py: initialize _last_avg_nonzero in __init__ so get_stats()
is safe to call before the first update()
- evo2_dataset.py: remove duplicate ASCII 45 ('-') entry in VALID_DNA_AND_DEGENERATE
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Description
Four defensive bug fixes across the codon MLM preprocessing pipeline and SAE evaluation utilities.
Usage
mlm_memmap.py — codon weight normalization: Previously, passing a
codon_weightsarray where all weights for the sequence tokens were zero caused division-by-zero → NaN → crash insidenp.random.binomial. No API change; the normalization is simply skipped when the mean is zero and masking proceeds with the flatmlm_probability.mlm_memmap.py — random replacement probability: Calling
process_itemwithmask_replace_prob=1.0(or any combo whererandom_replace_prob / (1 - mask_replace_prob) > 1.0) raisedZeroDivisionErrororValueError. Now guarded with a zero-denominator check and clamped to [0, 1].dead_latents.py — pre-update get_stats():
DeadLatentTracker().get_stats()now works immediately after construction without needing a priorupdate()call.