Skip to content

Guard against division by zero in apply_per_asset_coefficients#232

Open
sniper-noob wants to merge 2 commits intomode-network:mainfrom
sniper-noob:fix/divzero-in-asset-coefficients
Open

Guard against division by zero in apply_per_asset_coefficients#232
sniper-noob wants to merge 2 commits intomode-network:mainfrom
sniper-noob:fix/divzero-in-asset-coefficients

Conversation

@sniper-noob
Copy link
Contributor

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).

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>
@sniper-noob sniper-noob force-pushed the fix/divzero-in-asset-coefficients branch from 046eea6 to c3a38a6 Compare March 11, 2026 09:02
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant