Skip to content

Commit

Permalink
Merge pull request #211 from macrocosm-os/bump_843
Browse files Browse the repository at this point in the history
Bump version to bittensor 8.4.3 and adjust other dependencies as needed.
  • Loading branch information
cryptal-mc authored Dec 11, 2024
2 parents 4e49418 + 849f6e5 commit 695ecb5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
4 changes: 1 addition & 3 deletions constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# ---------------------------------

# Release
__version__ = "4.6.2"
__version__ = "4.6.3"

# Validator schema version
__validator_version__ = "4.6.0"
Expand Down Expand Up @@ -173,7 +173,6 @@
epsilon_func=LinearDecay(0.005, 0.0002, 36000),
max_bytes=29 * 1024 * 1024 * 1024,
),

}

# Schedule of competitions by block.
Expand Down Expand Up @@ -217,7 +216,6 @@
0.4,
),
],

),
]

Expand Down
38 changes: 23 additions & 15 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import datetime as dt
import functools
import json
import logging
import math
import os
import pickle
Expand All @@ -35,8 +36,11 @@
import traceback
import typing
from collections import defaultdict
from retry import retry

import bittensor as bt
from bittensor.utils.btlogging.helpers import all_loggers
from bittensor.utils.btlogging.defines import BITTENSOR_LOGGER_NAME
import torch
import wandb

Expand Down Expand Up @@ -126,8 +130,16 @@ def state_path(self) -> str:

def __init__(self):
self.config = config.validator_config()
# Manually default to info before overriding with arguments.
# If this is not done then info logging does not work in the cases where other modes are not specified.
bt.logging.set_info()
bt.logging(config=self.config)

# Setting logging level on bittensor messes with all loggers, which we don't want, so set explicitly to warning here.
for logger in all_loggers():
if not logger.name.startswith(BITTENSOR_LOGGER_NAME):
logger.setLevel(logging.WARNING)

bt.logging.info(f"Starting validator with config: {self.config}")

# === Bittensor objects ====
Expand Down Expand Up @@ -172,7 +184,7 @@ def __init__(self):
self._new_wandb_run()

# === Running args ===
self.weights = torch.zeros_like(torch.tensor(self.metagraph.S))
self.weights = torch.zeros_like(torch.from_numpy(self.metagraph.S))
self.global_step = 0
self.last_epoch = self.metagraph.block.item()

Expand Down Expand Up @@ -380,6 +392,9 @@ def update_models(self):
# Track how recently we checked the list of top models.
last_checked_top_models_time = None

# Delay the first update loop until the metagraph has been synced.
time.sleep(60)

# The below loop iterates across all miner uids and checks to see
# if they should be updated.
while not self.stop_event.is_set():
Expand Down Expand Up @@ -713,7 +728,7 @@ async def _try_set_weights():
netuid=self.config.netuid,
wallet=self.wallet,
uids=uids,
weights=self.weights,
weights=self.weights.numpy(),
wait_for_inclusion=False,
version_key=constants.weights_version_key,
)
Expand All @@ -722,15 +737,6 @@ async def _try_set_weights():
except:
bt.logging.warning("Failed to set weights. Trying again later.")

ws, ui = self.weights.topk(len(self.weights))
table = Table(title="All Weights")
table.add_column("uid", justify="right", style="cyan", no_wrap=True)
table.add_column("weight", style="magenta")
for index, weight in list(zip(ui.tolist(), ws.tolist())):
table.add_row(str(index), str(round(weight, 4)))
console = Console()
console.print(table)

try:
bt.logging.debug(f"Setting weights.")
await asyncio.wait_for(_try_set_weights(), ttl)
Expand All @@ -740,8 +746,12 @@ async def _try_set_weights():

def _get_current_block(self) -> int:
"""Returns the current block."""
try:
@retry(tries=5, delay=1, backoff=2)
def _get_block_with_retry():
return self.subtensor.block

try:
return _get_block_with_retry()
except:
bt.logging.debug(
"Failed to get the latest block from the chain. Using the block from the cached metagraph."
Expand Down Expand Up @@ -854,8 +864,6 @@ async def run_step(self):

bt.logging.trace(f"Current block: {cur_block}")



if cur_block < constants.BLOCK_STACK_V2_DEDUP:
dataset_by_competition_id = constants.DATASET_BY_COMPETITION_ID
else:
Expand Down Expand Up @@ -1232,7 +1240,7 @@ def _compute_and_set_competition_weights(

# Fill in metagraph sized tensor with the step weights of the evaluated models.
with self.metagraph_lock:
competition_weights = torch.zeros_like(self.metagraph.S)
competition_weights = torch.zeros_like(torch.from_numpy(self.metagraph.S))

for i, uid_i in enumerate(uids):
competition_weights[uid_i] = step_weights[i]
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
torch==2.4.1
bittensor==6.9.4
bittensor==8.4.3
huggingface-hub==0.25.2
matplotlib==3.9.2
pydantic==1.10
python-dotenv==1.0.1
rich==13.9.2
safetensors==0.4.5
numpy==2.1.2
numpy==2.0.1
transformers==4.44.1
wandb==0.18.3
datasets==3.0.1
flash-attn==2.6.3
smart-open[s3]==7.0.5
taoverse==1.0.9
taoverse==1.3.1

0 comments on commit 695ecb5

Please sign in to comment.