Guard against division by zero in apply_per_asset_coefficients#232
Open
sniper-noob wants to merge 2 commits intomode-network:mainfrom
Open
Guard against division by zero in apply_per_asset_coefficients#232sniper-noob wants to merge 2 commits intomode-network:mainfrom
sniper-noob wants to merge 2 commits intomode-network:mainfrom
Conversation
Problem:
apply_per_asset_coefficients() computes sum_coefficients by summing
(coef * count) for each asset. If all assets in the DataFrame have
coefficient 0, sum_coefficients is 0 and line 138 divides by zero:
df["prompt_score_v3"] /= 0.0 → NaN for every miner
This happens when the DataFrame only contains assets with zero
coefficients (SPYX, NVDAX, TSLAX, AAPLX, GOOGLX before the
new_equities_launch date). The NaN scores propagate to
compute_smoothed_score where they contaminate rolling averages
and eventually reach compute_softmax.
Example:
Assets in round: ["SPYX", "NVDAX"] (both have coef 0)
sum_coefficients = 0 * 2 + 0 * 1 = 0
df["prompt_score_v3"] /= 0 → [NaN, NaN, NaN]
rolling_avg = NaN → softmax gets NaN → reward weights = NaN
Fix:
moving_average.py line 138:
Check if sum_coefficients is 0 before dividing. If so, set all
scores to 0.0 (zero-coefficient assets should contribute nothing).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
046eea6 to
c3a38a6
Compare
SPYX and NVDAX have non-zero coefficients in the config dict. Use UNKNOWN_A/UNKNOWN_B to test the actual zero-coefficient path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Problem:
apply_per_asset_coefficients() computes sum_coefficients by summing (coef * count) for each asset. If all assets in the DataFrame have coefficient 0, sum_coefficients is 0 and line 138 divides by zero:
df["prompt_score_v3"] /= 0.0 → NaN for every miner
This happens when the DataFrame only contains assets with zero coefficients (SPYX, NVDAX, TSLAX, AAPLX, GOOGLX before the new_equities_launch date). The NaN scores propagate to compute_smoothed_score where they contaminate rolling averages and eventually reach compute_softmax.
Example:
Assets in round: ["SPYX", "NVDAX"] (both have coef 0)
sum_coefficients = 0 * 2 + 0 * 1 = 0
df["prompt_score_v3"] /= 0 → [NaN, NaN, NaN]
rolling_avg = NaN → softmax gets NaN → reward weights = NaN
Fix:
moving_average.py line 138:
Check if sum_coefficients is 0 before dividing. If so, set all
scores to 0.0 (zero-coefficient assets should contribute nothing).