Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self, config=None):
super(Validator, self).__init__(config=config)

bt.logging.info("load_state()")
self.load_state()

# TODO(developer): Anything specific to your use case you can do here

Expand Down
2 changes: 2 additions & 0 deletions template/base/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def __init__(self, config=None):
)
self.step = 0

self.load_state()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miner needs its own null definition.


@abstractmethod
async def forward(self, synapse: bt.Synapse) -> bt.Synapse:
...
Expand Down
7 changes: 6 additions & 1 deletion template/base/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import copy
import os
import torch
import asyncio
import threading
Expand Down Expand Up @@ -339,8 +340,12 @@ def load_state(self):
"""Loads the state of the validator from a file."""
bt.logging.info("Loading validator state.")

if not os.path.exists(self.config.neuron.full_path + "/state.pt"):
bt.logging.warning("No saved state found")
return

# Load the state of the validator from file.
state = torch.load(self.config.neuron.full_path + "/state.pt")
self.step = state["step"]
self.scores = state["scores"]
self.scores = state["scores"].to(self.device)
self.hotkeys = state["hotkeys"]