Skip to content

Commit

Permalink
fix: min weights
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvis8x7b committed Oct 23, 2024
1 parent 7c61b4d commit f772ef2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ async def resync_metagraph(self):
min_len = min(len(previous_metagraph.hotkeys), len(self.scores))
new_moving_average[:min_len] = self.scores[:min_len]
async with self._alock:
self.scores = new_moving_average
self.scores = torch.clamp(new_moving_average, min=0.0)

async def update_scores(self, hotkey_to_scores: dict[str, float]):
"""Performs exponential moving average on the scores based on the rewards received from the miners,
Expand Down Expand Up @@ -812,6 +812,7 @@ async def update_scores(self, hotkey_to_scores: dict[str, float]):
# don't acquire lock here because we're already acquiring it in the CALLER
async with self._alock:
self.scores = alpha * rewards + (1 - alpha) * self.scores
self.scores = torch.clamp(self.scores, min=0.0)
logger.debug(f"Updated scores: {self.scores}")

async def save_state(
Expand Down Expand Up @@ -852,7 +853,7 @@ async def _load_state(self):

logger.success(f"Loaded validator state: {scores=}")
async with self._alock:
self.scores = scores
self.scores = torch.clamp(scores, 0.0)

except Exception as e:
logger.error(
Expand Down

0 comments on commit f772ef2

Please sign in to comment.