From 40f8aa001357713a3db23356fed0797774cd4899 Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Tue, 31 Dec 2024 15:13:08 +0200 Subject: [PATCH 1/6] feat: update imports and configurations for bittensor core modules to match with the latest version --- compute/axon.py | 18 ++++++++++-------- compute/prometheus.py | 6 +++--- compute/utils/subtensor.py | 2 +- neurons/validator.py | 4 ++-- requirements.txt | 8 ++++---- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/compute/axon.py b/compute/axon.py index 820102d1..117411e9 100644 --- a/compute/axon.py +++ b/compute/axon.py @@ -27,8 +27,10 @@ import bittensor.utils.networking as net import time import uvicorn -from bittensor import axon, subtensor -from bittensor.axon import FastAPIThreadedServer, AxonMiddleware +from bittensor import axon +from bittensor.core.subtensor import Subtensor as subtensor + +from bittensor.core.axon import FastAPIThreadedServer, AxonMiddleware from fastapi import FastAPI, APIRouter from rich.prompt import Confirm from starlette.requests import Request @@ -39,7 +41,7 @@ def serve_extrinsic( - subtensor: "bittensor.subtensor", + subtensor: "bittensor.core.subtensor", wallet: "bittensor.wallet", ip: str, port: int, @@ -250,16 +252,16 @@ def __init__( if config is None: config = axon.config() config = copy.deepcopy(config) - config.axon.ip = ip or config.axon.get("ip", bittensor.defaults.axon.ip) - config.axon.port = port or config.axon.get("port", bittensor.defaults.axon.port) + config.axon.ip = ip or config.axon.get("ip", bittensor.core.settings.DEFAULTS.axon.ip) + config.axon.port = port or config.axon.get("port", bittensor.core.settings.DEFAULTS.axon.port) config.axon.external_ip = external_ip or config.axon.get( - "external_ip", bittensor.defaults.axon.external_ip + "external_ip", bittensor.core.settings.DEFAULTS.axon.external_ip ) config.axon.external_port = external_port or config.axon.get( - "external_port", bittensor.defaults.axon.external_port + "external_port", bittensor.core.settings.DEFAULTS.axon.external_port ) config.axon.max_workers = max_workers or config.axon.get( - "max_workers", bittensor.defaults.axon.max_workers + "max_workers", bittensor.core.settings.DEFAULTS.axon.max_workers ) axon.check_config(config) self.config = config diff --git a/compute/prometheus.py b/compute/prometheus.py index b586eb42..74464242 100644 --- a/compute/prometheus.py +++ b/compute/prometheus.py @@ -21,10 +21,11 @@ import bittensor.utils.networking as net import compute +import inspect def prometheus_extrinsic( - subtensor: "bittensor.subtensor", + subtensor: "bittensor.core.subtensor.Subtensor.MockSubtensor", wallet: "bittensor.wallet", port: int, netuid: int, @@ -99,9 +100,8 @@ def prometheus_extrinsic( # Add netuid, not in prometheus_info call_params["netuid"] = netuid - bittensor.logging.info("Serving prometheus on: {}:{} ...".format(subtensor.network, netuid)) - success, err = subtensor._do_serve_prometheus( + success, err = subtensor.do_serve_prometheus( wallet=wallet, call_params=call_params, wait_for_finalization=wait_for_finalization, diff --git a/compute/utils/subtensor.py b/compute/utils/subtensor.py index 8efac3cb..8c1106d5 100644 --- a/compute/utils/subtensor.py +++ b/compute/utils/subtensor.py @@ -20,7 +20,7 @@ from compute.utils.cache import ttl_cache -bt_blocktime = bt.__blocktime__ +bt_blocktime = bt.BLOCKTIME @ttl_cache(maxsize=1, ttl=bt_blocktime) diff --git a/neurons/validator.py b/neurons/validator.py index 626e4027..cc91634e 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -236,9 +236,9 @@ def init_prometheus(self, force_update: bool = False): :return: bool """ bt.logging.info("Extrinsic prometheus information on metagraph.") - success = self.subtensor.serve_prometheus( + success = self._subtensor.serve_prometheus( wallet=self.wallet, - port=bt.defaults.axon.port, + port=bt.core.settings.DEFAULTS.axon.port, netuid=self.config.netuid, force_update=force_update, ) diff --git a/requirements.txt b/requirements.txt index 2e300025..6296bf31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ at==0.0.3 -bittensor==6.9.4 +bittensor==8.5.0 black==23.7.0 cryptography==42.0.0 docker==7.0.0 GPUtil==1.4.0 igpu==0.1.2 -numpy==1.26.3 +numpy==2.0.2 psutil==5.9.8 pyinstaller==6.4.0 -torch==2.1.2 -wandb==0.16.6 +torch==2.5.1 +wandb==0.19.1 pyfiglet==1.0.2 python-dotenv==1.0.1 requests==2.31.0 From 30df2b8899497bd6138724dd2b8044fd3fc02d24 Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Mon, 6 Jan 2025 13:56:42 +0200 Subject: [PATCH 2/6] feat: update version numbers and dependencies; add wandb to .gitignore --- .gitignore | 3 +++ compute/__init__.py | 11 ++++++++--- requirements.txt | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 26e7eba1..890d21f2 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,9 @@ target/ profile_default/ ipython_config.py +# wandb +wandb/ + # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: diff --git a/compute/__init__.py b/compute/__init__.py index 70909360..234065bb 100644 --- a/compute/__init__.py +++ b/compute/__init__.py @@ -18,9 +18,9 @@ import string # Define the version of the template module. -__version__ = "1.5.3" -__minimal_miner_version__ = "1.5.1" -__minimal_validator_version__ = "1.5.2" +__version__ = "1.7.0" +__minimal_miner_version__ = "1.7.0" +__minimal_validator_version__ = "1.7.0" version_split = __version__.split(".") __version_as_int__ = (100 * int(version_split[0])) + (10 * int(version_split[1])) + (1 * int(version_split[2])) @@ -33,6 +33,11 @@ # Validators static vars # Time before the specs requests will time out. time unit = seconds specs_timeout = 60 + +# Proof of GPU settings +pog_retry_limit = 30 +pog_retry_interval = 80 # seconds + # Time before the proof of work requests will time out. time unit = seconds pow_timeout = 30 # Initial and minimal proof of work difficulty. Needs benchmark and adjustment. diff --git a/requirements.txt b/requirements.txt index 6296bf31..b51f9913 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,13 @@ at==0.0.3 bittensor==8.5.0 black==23.7.0 -cryptography==42.0.0 +cryptography==43.0.1 docker==7.0.0 GPUtil==1.4.0 igpu==0.1.2 numpy==2.0.2 psutil==5.9.8 pyinstaller==6.4.0 -torch==2.5.1 wandb==0.19.1 pyfiglet==1.0.2 python-dotenv==1.0.1 From 26cf2c4c69d86e623e0f84a7a42d7fe12fa3717b Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Mon, 6 Jan 2025 13:57:41 +0200 Subject: [PATCH 3/6] refactor: update prometheus logging and remove deprecated serve_prometheus code prometheus extrinsic is removed from 8.2.1 --- neurons/validator.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/neurons/validator.py b/neurons/validator.py index cc91634e..f52f9891 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -234,16 +234,21 @@ def init_prometheus(self, force_update: bool = False): """ Register the prometheus information on metagraph. :return: bool - """ + """ extrinsic bt.logging.info("Extrinsic prometheus information on metagraph.") - success = self._subtensor.serve_prometheus( - wallet=self.wallet, - port=bt.core.settings.DEFAULTS.axon.port, - netuid=self.config.netuid, - force_update=force_update, - ) + success = # prometheus extrinsic. removed at 8.2.1 + # TODO : remove all the related code from the code base + # self._subtensor.serve_prometheus( + # wallet=self.wallet, + # port=bt.core.settings.DEFAULTS.axon.port, + # netuid=self.config.netuid, + # force_update=force_update, + # ) if success: - bt.logging.success(prefix="Prometheus served", sufix=f"Current version: {get_local_version()}") + bt.logging.success( + prefix="Prometheus served", + suffix=f"Current version: {get_local_version()}" # Corrected keyword + ) else: bt.logging.error("Prometheus initialization failed") return success From 0e82b23a38e28ac2e1700d9c1c501270a156bb30 Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Mon, 6 Jan 2025 14:36:39 +0200 Subject: [PATCH 4/6] refactor: fix an issue with a comment --- neurons/validator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neurons/validator.py b/neurons/validator.py index 7977891d..bff5d661 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -246,7 +246,9 @@ def init_prometheus(self, force_update: bool = False): """ Register the prometheus information on metagraph. :return: bool - """ extrinsic + """ + # extrinsic prometheus is removed at 8.2.1 + bt.logging.info("Extrinsic prometheus information on metagraph.") success = # prometheus extrinsic. removed at 8.2.1 # TODO : remove all the related code from the code base From 8b3d7ca6e8ec4a2e799703c7a2b132b59306227d Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Mon, 6 Jan 2025 14:37:23 +0200 Subject: [PATCH 5/6] refactor: update extrinsic prometheus handling in validator.py --- neurons/validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neurons/validator.py b/neurons/validator.py index bff5d661..8cb9c90c 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -250,7 +250,7 @@ def init_prometheus(self, force_update: bool = False): # extrinsic prometheus is removed at 8.2.1 bt.logging.info("Extrinsic prometheus information on metagraph.") - success = # prometheus extrinsic. removed at 8.2.1 + success = True # TODO : remove all the related code from the code base # self._subtensor.serve_prometheus( # wallet=self.wallet, From 1aa0309dfcbb3c8bca1bbbcb297057ca17608f1f Mon Sep 17 00:00:00 2001 From: Mohaned AbdElMonsef Date: Mon, 6 Jan 2025 14:51:32 +0200 Subject: [PATCH 6/6] refactor: simplify GPU handling and fix parameter passing in RegisterAPI --- neurons/register_api.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/neurons/register_api.py b/neurons/register_api.py index 0daff4e7..eb77f6de 100644 --- a/neurons/register_api.py +++ b/neurons/register_api.py @@ -1668,12 +1668,8 @@ async def count_all_gpus() -> JSONResponse: # Iterate through the miner specs details and print the table for hotkey, details in specs_details.items(): if details : - gpu_miner = details["gpu"] - gpu_capacity = "{:.2f}".format( - (gpu_miner["capacity"] / 1024) - ) - gpu_name = str(gpu_miner["details"][0]["name"]).lower() - gpu_count = gpu_miner["count"] + gpu_miner = details.get("gpu", "") + gpu_count = gpu_miner.get("count", 0) GPU_COUNTS += gpu_count bt.logging.info(f"API: List resources successfully") return JSONResponse( @@ -1819,7 +1815,7 @@ async def list_resources_wandb(query: ResourceQuery = None, for hotkey, details in specs_details.items(): miner_older_than = self.miner_is_older_than(db, 48, hotkey) - miner_pog_ok = self.miner_pog_ok((db, 48, hotkey)) + miner_pog_ok = self.miner_pog_ok(db, 48, hotkey) if hotkey in running_hotkey and miner_pog_ok: if details: # Check if details are not empty @@ -3061,7 +3057,7 @@ def miner_is_older_than(self, db: ComputeDb, hours: int, ss58_address: str) -> b cursor.close() def miner_pog_ok(self, db: ComputeDb, hours: int, ss58_address: str) -> bool: - gpu_specs = get_pog_specs(self.db, ss58_address) + gpu_specs = get_pog_specs(db, ss58_address) if gpu_specs is not None: return True else: