Skip to content

Commit

Permalink
fix: convert to np array and back to torch
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvis8x7b committed Oct 27, 2024
1 parent 8cd6ad2 commit fa7bacc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import torch
import wandb
from bittensor.btlogging import logging as logger
from bittensor.utils.weight_utils import process_weights_for_netuid
from fastapi.encoders import jsonable_encoder
from tenacity import RetryError
from torch.nn import functional as F
Expand Down Expand Up @@ -678,13 +679,19 @@ async def set_weights(self):
(
final_uids,
final_weights,
) = bt.utils.weight_utils.process_weights_for_netuid( # type: ignore
uids=uids,
weights=safe_normalized_weights,
netuid=self.config.netuid,
) = process_weights_for_netuid( # type: ignore
uids=uids.numpy(),
weights=safe_normalized_weights.numpy(),
netuid=self.config.netuid, # type: ignore
subtensor=self.subtensor,
metagraph=self.metagraph,
)

if isinstance(final_weights, np.ndarray):
final_weights = torch.from_numpy(final_weights).to("cpu")
if isinstance(final_uids, np.ndarray):
final_uids = torch.from_numpy(final_uids).to("cpu")

logger.debug(f"weights:\n{safe_normalized_weights}")
logger.debug(f"uids:\n{uids}")

Expand Down

0 comments on commit fa7bacc

Please sign in to comment.