Skip to content
Merged
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.9.2
4.9.3
2 changes: 1 addition & 1 deletion gas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.9.2"
__version__ = "4.9.3"

version_split = __version__.split(".")
__spec_version__ = (
Expand Down
4 changes: 2 additions & 2 deletions gas/cache/util/miner_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def resolve_coldkeys(

if endpoint:
print(f" {Colors.DIM}connecting to subtensor: {endpoint}{Colors.END}")
subtensor = bt.subtensor(chain_endpoint=endpoint)
subtensor = bt.Subtensor(chain_endpoint=endpoint)
else:
print(f" {Colors.DIM}connecting to subtensor: finney{Colors.END}")
subtensor = bt.subtensor(network="finney")
subtensor = bt.Subtensor(network="finney")

print(f" {Colors.DIM}fetching metagraph for netuid {netuid}...{Colors.END}")
metagraph = subtensor.metagraph(netuid=netuid, lite=True)
Expand Down
4 changes: 2 additions & 2 deletions gas/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def perf(wallet_name, wallet_hotkey, modality, api_url):
from gas.protocol.miner_requests import fetch_models

try:
wallet = bt.wallet(name=wallet_name, hotkey=wallet_hotkey)
wallet = bt.Wallet(name=wallet_name, hotkey=wallet_hotkey)
except Exception as e:
click.echo(f"Error loading wallet: {e}", err=True)
sys.exit(1)
Expand Down Expand Up @@ -906,7 +906,7 @@ def gen_perf(wallet_name, wallet_hotkey, modality, lookback_days, api_url, as_js
wh = wallet_hotkey or os.environ.get("BT_WALLET_HOTKEY", "default")

try:
wallet = bt.wallet(name=wn, hotkey=wh)
wallet = bt.Wallet(name=wn, hotkey=wh)
except Exception as e:
click.echo(f"Error loading wallet: {e}", err=True)
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion gas/protocol/epistula.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import bittensor as bt
import time
import httpx
from substrateinterface import Keypair
from bittensor_wallet import Keypair
from fastapi import Request, HTTPException


Expand Down
2 changes: 1 addition & 1 deletion gas/protocol/gas_api_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _verification_stats_to_entries(


def post_generator_verification_upload(
wallet: bt.wallet,
wallet: bt.Wallet,
base_url: str,
lookback_hours: float,
verification_stats: Dict[str, Dict[str, Any]],
Expand Down
12 changes: 6 additions & 6 deletions gas/protocol/miner_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def calculate_sha256(data: bytes) -> str:


def generate_presigned_url(
wallet: bt.wallet,
wallet: bt.Wallet,
upload_endpoint: str,
filename: str,
file_size: int,
Expand Down Expand Up @@ -110,7 +110,7 @@ def upload_to_r2(presigned_url: str, file_content: bytes, content_type: str = 'a
}


def confirm_upload(wallet: bt.wallet, upload_endpoint: str, model_id: int, file_hash: str) -> dict:
def confirm_upload(wallet: bt.Wallet, upload_endpoint: str, model_id: int, file_hash: str) -> dict:
"""Confirm file upload and finalize model record."""

payload = {
Expand Down Expand Up @@ -153,7 +153,7 @@ def confirm_upload(wallet: bt.wallet, upload_endpoint: str, model_id: int, file_


def upload_single_modality(
wallet: bt.wallet,
wallet: bt.Wallet,
file_path: str,
modality: str,
upload_endpoint: str,
Expand Down Expand Up @@ -264,7 +264,7 @@ def extract_error(result: dict) -> str:


def fetch_performance(
wallet: bt.wallet,
wallet: bt.Wallet,
modality: Optional[str] = None,
vertical: Optional[str] = None,
api_url: Optional[str] = None,
Expand Down Expand Up @@ -301,7 +301,7 @@ def fetch_performance(


def fetch_models(
wallet: bt.wallet,
wallet: bt.Wallet,
modality: Optional[str] = None,
api_url: Optional[str] = None,
) -> Dict:
Expand Down Expand Up @@ -337,7 +337,7 @@ def fetch_models(


def fetch_generator_performance(
wallet: bt.wallet,
wallet: bt.Wallet,
modality: Optional[str] = None,
lookback_days: int = 7,
api_url: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion gas/protocol/validator_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def get_escrow_addresses(


async def get_benchmark_results(
hotkey, metagraph: bt.metagraph, base_url: str = "https://gas.bitmind.ai",
hotkey, metagraph: bt.Metagraph, base_url: str = "https://gas.bitmind.ai",
max_retries: int = 3,
):
"""
Expand Down
7 changes: 3 additions & 4 deletions gas/utils/chain_model_metadata_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ChainModelMetadataStore:

def __init__(
self,
subtensor: bt.subtensor,
subtensor: bt.Subtensor,
netuid: int,
):
self.subtensor = subtensor
Expand All @@ -30,7 +30,7 @@ async def store_model_metadata(
data = model_id.to_compressed_str()

commit_partial = functools.partial(
self.subtensor.commit,
self.subtensor.set_commitment,
wallet,
self.netuid,
data,
Expand All @@ -44,8 +44,7 @@ async def retrieve_model_metadata(
"""Retrieves model metadata on this subnet for specific hotkey"""

metadata_partial = functools.partial(
bt.core.extrinsics.serving.get_metadata,
self.subtensor,
self.subtensor.get_commitment_metadata,
self.netuid,
hotkey,
)
Expand Down
10 changes: 5 additions & 5 deletions gas/utils/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def get_miner_uids(
metagraph: "bt.metagraph", self_uid: int, vpermit_tao_limit: int
metagraph: "bt.Metagraph", self_uid: int, vpermit_tao_limit: int
) -> List[int]:
available_uids = []
for uid in range(int(metagraph.n.item())):
Expand All @@ -30,9 +30,9 @@ def get_miner_uids(
def create_set_weights(version: int, netuid: int):
@fail_with_none("Failed setting weights")
def set_weights(
wallet: "bt.wallet",
metagraph: "bt.metagraph",
subtensor: "bt.subtensor",
wallet: "bt.Wallet",
metagraph: "bt.Metagraph",
subtensor: "bt.Subtensor",
weights: Tuple[List[int], List[float]],
):
uids, raw_weights = weights
Expand Down Expand Up @@ -63,7 +63,7 @@ def set_weights(
wait_for_finalization=False,
wait_for_inclusion=False,
version_key=version,
max_retries=1,
max_attempts=1,
)
if result is True:
bt.logging.success("set_weights on chain successfully!")
Expand Down
2 changes: 1 addition & 1 deletion gas/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def print_info(metagraph, hotkey, block, isMiner=True):
if isMiner:
bt.logging.info(
log
+ f"Stake:{metagraph.S[uid]} | Trust:{metagraph.T[uid]} | Incentive:{metagraph.I[uid]} | Emission:{metagraph.E[uid]}"
+ f"Stake:{metagraph.S[uid]} | Incentive:{metagraph.I[uid]} | Emission:{metagraph.E[uid]}"
)
return
bt.logging.info(log + f"VTrust:{metagraph.Tv[uid]} | ")
Expand Down
2 changes: 1 addition & 1 deletion gas/utils/wandb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def init_wandb(
config: bt.config, process: str, uid: int, hotkey: bt.Keypair, wandb_dir: str = None
config: bt.Config, process: str, uid: int, hotkey: bt.Keypair, wandb_dir: str = None
) -> wandb.run:
"""
Initialize a Weights & Biases run.
Expand Down
19 changes: 10 additions & 9 deletions neurons/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import traceback
import asyncio

from bittensor.core.settings import SS58_FORMAT, TYPE_REGISTRY
from bittensor.core.settings import TYPE_REGISTRY
from bittensor_wallet.utils import SS58_FORMAT
import signal

from gas import (
Expand All @@ -30,7 +31,7 @@ class BaseNeuron:
Base neuron class with async substrate support and automatic reconnection.
Provides clean async/await coordination throughout the application.
"""
config: "bt.config"
config: "bt.Config"
neuron_type: NeuronType

def check_registered(self):
Expand Down Expand Up @@ -83,19 +84,19 @@ def __init__(self, config=None):
)

parser = argparse.ArgumentParser()
bt.wallet.add_args(parser)
bt.subtensor.add_args(parser)
bt.Wallet.add_args(parser)
bt.Subtensor.add_args(parser)
bt.logging.add_args(parser)
add_args(parser)

if self.neuron_type == NeuronType.VALIDATOR:
bt.axon.add_args(parser)
bt.Axon.add_args(parser)
add_validator_args(parser)
if self.neuron_type == NeuronType.MINER:
bt.axon.add_args(parser)
bt.Axon.add_args(parser)
add_miner_args(parser)

self.config = bt.config(parser)
self.config = bt.Config(parser)
if config:
base_config = copy.deepcopy(config)
self.config.merge(base_config)
Expand All @@ -119,8 +120,8 @@ def __init__(self, config=None):

## BITTENSOR INITIALIZATION
bt.logging.success(self.config)
self.wallet = bt.wallet(config=self.config)
self.subtensor = bt.subtensor(
self.wallet = bt.Wallet(config=self.config)
self.subtensor = bt.Subtensor(
config=self.config, network=self.config.subtensor.chain_endpoint
)
self.metagraph = self.subtensor.metagraph(self.config.netuid)
Expand Down
8 changes: 4 additions & 4 deletions neurons/discriminator/push_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def push_separate_models(
image_model_path: Optional[str] = None,
video_model_path: Optional[str] = None,
audio_model_path: Optional[str] = None,
wallet: bt.wallet = None,
wallet: bt.Wallet = None,
retry_delay_secs: int = 60,
netuid: int = 34,
chain_endpoint: Optional[str] = None,
Expand Down Expand Up @@ -222,7 +222,7 @@ async def push_separate_models(
chain_endpoint = "finney" if netuid == 34 else "test"

print_info(f"Connecting to subnet {netuid} via {chain_endpoint}")
subtensor = bt.subtensor(network=chain_endpoint)
subtensor = bt.Subtensor(network=chain_endpoint)
metadata_store = ChainModelMetadataStore(subtensor, netuid)

# Register each model separately on the blockchain
Expand Down Expand Up @@ -357,15 +357,15 @@ def main():

# Initialize wallet
try:
wallet = bt.wallet(name=args.wallet_name, hotkey=args.wallet_hotkey)
wallet = bt.Wallet(name=args.wallet_name, hotkey=args.wallet_hotkey)
print_info(f"Hotkey: {wallet.hotkey.ss58_address}")
except Exception as e:
print_error(f"Failed to initialize wallet: {e}")
sys.exit(1)

# Check if hotkey is registered
netuid = args.netuid
mg = bt.metagraph(netuid=netuid, network="finney" if netuid == 34 else "test")
mg = bt.Metagraph(netuid=netuid, network="finney" if netuid == 34 else "test")
hotkey = wallet.hotkey.ss58_address
if hotkey not in mg.hotkeys:
print_warning(f"Hotkey {hotkey} not registered on netuid {netuid}")
Expand Down
13 changes: 7 additions & 6 deletions neurons/validator/services/data_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from pathlib import Path

import bittensor as bt
from bittensor.core.settings import SS58_FORMAT, TYPE_REGISTRY
from bittensor.core.settings import TYPE_REGISTRY
from bittensor_wallet.utils import SS58_FORMAT

from gas.cache import ContentManager
from gas.config import add_args, add_data_service_args
Expand Down Expand Up @@ -77,7 +78,7 @@ def __init__(self, config):
}

try:
self.validator_wallet = bt.wallet(config=self.config)
self.validator_wallet = bt.Wallet(config=self.config)
except Exception:
self.validator_wallet = None

Expand Down Expand Up @@ -127,7 +128,7 @@ def _resolve_validator_uid(self) -> Optional[int]:
if not self.validator_wallet:
return None
try:
subtensor = bt.subtensor(config=self.config)
subtensor = bt.Subtensor(config=self.config)
metagraph = subtensor.metagraph(netuid=self.config.netuid)
hotkey = self.validator_wallet.hotkey.ss58_address
hotkeys_list = list(metagraph.hotkeys)
Expand Down Expand Up @@ -504,11 +505,11 @@ async def main():

add_args(parser)
add_data_service_args(parser)
bt.wallet.add_args(parser)
bt.subtensor.add_args(parser)
bt.Wallet.add_args(parser)
bt.Subtensor.add_args(parser)
bt.logging.add_args(parser)

config = bt.config(parser)
config = bt.Config(parser)

bt.logging(config=config, logging_dir=config.neuron.full_path)
bt.logging.set_info()
Expand Down
13 changes: 5 additions & 8 deletions neurons/validator/services/generator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, config):

self._output_dir = Path(self.config.cache.base_dir)

self.validator_wallet = bt.wallet(config=self.config)
self.validator_wallet = bt.Wallet(config=self.config)

self._service_running = False
self._generation_running = False
Expand Down Expand Up @@ -73,7 +73,7 @@ def __init__(self, config):
self.tp_generators = {"nano_banana": nano_banana.generate_image}

self._first_run_profiled = False
self._job_profiles = {}
self._job_profiles = {}
# job_name -> {"peak_vram_gb": float, "avg_duration_s": float, "count": int}
# Per-model profiling: model_name -> {"max_peak_vram_gb": float, "avg_gen_s": float, "count": int, "last_gen_s": float}
self._model_profiles = {}
Expand Down Expand Up @@ -223,9 +223,6 @@ def _generation_work_loop(self):
"""Main generation loop."""
bt.logging.info("[GENERATOR-SERVICE] Starting generation work loop")

# Clear any pending verification backlog before the first generation cycle.
self._run_verification()

while not self._stop_requested.is_set():
try:
self._await_media(min_needed=1, max_wait_s=1200, poll_s=10)
Expand Down Expand Up @@ -839,10 +836,10 @@ def main():

add_args(parser)
add_generation_service_args(parser)
bt.subtensor.add_args(parser)
bt.wallet.add_args(parser)
bt.Subtensor.add_args(parser)
bt.Wallet.add_args(parser)
bt.logging.add_args(parser)
config = bt.config(parser)
config = bt.Config(parser)

bt.logging(config=config, logging_dir=config.neuron.full_path)
bt.logging.set_info()
Expand Down
Loading
Loading