Skip to content

Commit

Permalink
fix: dont unpack none
Browse files Browse the repository at this point in the history
  • Loading branch information
distributedstatemachine committed Jan 3, 2025
1 parent 26c516a commit 9d5e0db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,27 @@ async def run(self):
tplr.logger.info(f'Computed total loss before: {loss_before_per_batch}')

# Get the gradients from this miner on this window
eval_grad, _ = await self.comms.get(
result = await self.comms.get(
uid=eval_uid,
window=self.sync_window + 1,
key='gradient',
timeout=5,
local=False,
stale_retention=10
)
if eval_grad is None:
score = 0
tplr.logger.info(f'Miner with uind: {eval_uid} has no gradient for window: {self.sync_window + 1}')
if result is None:
tplr.logger.info(f'Miner with uid: {eval_uid} has no gradient for window: {self.sync_window + 1}')
# Set score to 0 for this evaluation
score = 0.0
self.scores[eval_uid] = score
self.moving_avg_scores[eval_uid] = self.ma_alpha * self.moving_avg_scores[eval_uid]

# Skip to next window
while self.current_window == step_window:
await asyncio.sleep(0.1)
continue # Proceed to the next window iteration
continue

eval_grad, _ = result # Unpack only if result is not None

# Apply grad to model which is at state sync_window
for n, p in self.model.named_parameters():
Expand Down
2 changes: 1 addition & 1 deletion src/tplr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# mypy: ignore-errors
# type: ignore

__version__ = "0.2.3"
__version__ = "0.2.4"

# Import package.
from .chain import *
Expand Down

0 comments on commit 9d5e0db

Please sign in to comment.