Skip to content

Commit 0759f6a

Browse files
shibshibAla ShaabanaEugene-hu
authored
Allow set subnet specific hyper parameters. (#1745)
* Allowed for display and setting of AdjustmentAlpha * Added adjustment_alpha value settings * Added difficulty * Fixed setting difficulty errors * wallet typing * Removed subnet info changes * black and test fixes * Fixed subnet_info * version update * changelog and black --------- Co-authored-by: Ala Shaabana <ala@bittensor.com> Co-authored-by: Eugene <etesting007@gmail.com>
1 parent 9e7e872 commit 0759f6a

File tree

8 files changed

+59
-6
lines changed

8 files changed

+59
-6
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 6.9.3 / 2024-03-12
4+
5+
## What's Changed
6+
* Release/6.9.2 by @ifrit98 in https://github.com/opentensor/bittensor/pull/1743
7+
8+
9+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.9.2...v6.9.3
10+
11+
312
## 6.9.2 / 2024-03-08
413

514
## What's Changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.9.2
1+
6.9.3

bittensor/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
nest_asyncio.apply()
2828

2929
# Bittensor code and protocol version.
30-
__version__ = "6.9.2"
30+
__version__ = "6.9.3"
3131

3232
version_split = __version__.split(".")
3333
__version_as_int__: int = (

bittensor/chain_data.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
["max_regs_per_block", "Compact<u16>"],
177177
["serving_rate_limit", "Compact<u64>"],
178178
["max_validators", "Compact<u16>"],
179+
["adjustment_alpha", "Compact<u64>"],
180+
["difficulty", "Compact<u64>"],
179181
],
180182
},
181183
}
@@ -882,6 +884,7 @@ class SubnetInfo:
882884
emission_value: float
883885
burn: Balance
884886
owner_ss58: str
887+
# adjustment_alpha: int
885888

886889
@classmethod
887890
def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetInfo"]:
@@ -922,6 +925,8 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetInfo":
922925
max_allowed_validators=decoded["max_allowed_validators"],
923926
min_allowed_weights=decoded["min_allowed_weights"],
924927
max_weight_limit=decoded["max_weights_limit"],
928+
# adjustment_alpha=decoded["adjustment_alpha"],
929+
# bonds_moving_avg=decoded["bonds_moving_average"],
925930
scaling_law_power=decoded["scaling_law_power"],
926931
subnetwork_n=decoded["subnetwork_n"],
927932
max_n=decoded["max_allowed_uids"],
@@ -975,6 +980,8 @@ class SubnetHyperparameters:
975980
max_regs_per_block: int
976981
serving_rate_limit: int
977982
max_validators: int
983+
adjustment_alpha: int
984+
difficulty: int
978985

979986
@classmethod
980987
def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]:
@@ -1023,10 +1030,12 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters":
10231030
target_regs_per_interval=decoded["target_regs_per_interval"],
10241031
min_burn=decoded["min_burn"],
10251032
max_burn=decoded["max_burn"],
1026-
bonds_moving_avg=decoded["bonds_moving_avg"],
10271033
max_regs_per_block=decoded["max_regs_per_block"],
10281034
max_validators=decoded["max_validators"],
10291035
serving_rate_limit=decoded["serving_rate_limit"],
1036+
bonds_moving_avg=decoded["bonds_moving_avg"],
1037+
adjustment_alpha=decoded["adjustment_alpha"],
1038+
difficulty=decoded["difficulty"],
10301039
)
10311040

10321041
def to_parameter_dict(self) -> "torch.nn.ParameterDict":

bittensor/commands/network.py

+5
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ def add_args(parser: argparse.ArgumentParser):
318318
"network_pow_registration_allowed": "sudo_set_network_pow_registration_allowed",
319319
"min_burn": "sudo_set_min_burn",
320320
"max_burn": "sudo_set_max_burn",
321+
"adjustment_alpha": "sudo_set_adjustment_alpha",
322+
"rho": "sudo_set_rho",
323+
"kappa": "sudo_set_kappa",
324+
"difficulty": "sudo_set_difficulty",
325+
"bonds_moving_avg": "sudo_set_bonds_moving_average",
321326
}
322327

323328

bittensor/commands/wallets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import sys
2222
from rich.prompt import Prompt, Confirm
2323
from rich.table import Table
24-
from typing import Optional, List
24+
from typing import Optional, List, Tuple
2525
from . import defaults
2626
import requests
2727
from ..utils import RAOPERTAO
@@ -692,7 +692,7 @@ def check_config(config: "bittensor.Config"):
692692
config.wallet.name = str(wallet_name)
693693

694694

695-
def _get_coldkey_ss58_addresses_for_path(path: str) -> tuple[list[str], list[str]]:
695+
def _get_coldkey_ss58_addresses_for_path(path: str) -> Tuple[List[str], List[str]]:
696696
"""Get all coldkey ss58 addresses from path."""
697697

698698
def list_coldkeypub_files(dir_path):

bittensor/mock/subtensor_mock.py

+8
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def setup(self) -> None:
270270
"Prometheus": {},
271271
"SubnetOwner": {},
272272
"Commits": {},
273+
"AdjustmentAlpha": {},
274+
"BondsMovingAverage": {},
273275
},
274276
}
275277

@@ -328,6 +330,7 @@ def create_subnet(self, netuid: int) -> None:
328330
subtensor_state["BlocksSinceLastStep"][netuid][0] = 0
329331
subtensor_state["Tempo"][netuid] = {}
330332
subtensor_state["Tempo"][netuid][0] = 99
333+
331334
# subtensor_state['NetworkConnect'][netuid] = {}
332335
# subtensor_state['NetworkConnect'][netuid][0] = {}
333336
subtensor_state["EmissionValues"][netuid] = {}
@@ -364,6 +367,11 @@ def create_subnet(self, netuid: int) -> None:
364367
subtensor_state["NetworksAdded"][netuid] = {}
365368
subtensor_state["NetworksAdded"][netuid][0] = True
366369

370+
subtensor_state["AdjustmentAlpha"][netuid] = {}
371+
subtensor_state["AdjustmentAlpha"][netuid][0] = 1000
372+
373+
subtensor_state["BondsMovingAverage"][netuid] = {}
374+
subtensor_state["BondsMovingAverage"][netuid][0] = 1000
367375
else:
368376
raise Exception("Subnet already exists")
369377

bittensor/subtensor.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
)
8282
from .extrinsics.root import root_register_extrinsic, set_root_weights_extrinsic
8383
from .types import AxonServeCallParams, PrometheusServeCallParams
84-
from .utils import U16_NORMALIZED_FLOAT, ss58_to_vec_u8
84+
from .utils import U16_NORMALIZED_FLOAT, ss58_to_vec_u8, U64_NORMALIZED_FLOAT
8585
from .utils.balance import Balance
8686
from .utils.registration import POWSolution
8787

@@ -2858,6 +2858,28 @@ def max_weight_limit(
28582858
return None
28592859
return U16_NORMALIZED_FLOAT(_result.value)
28602860

2861+
def adjustment_alpha(
2862+
self, netuid: int, block: Optional[int] = None
2863+
) -> Optional[float]:
2864+
"""Returns network AdjustmentAlpha hyper parameter"""
2865+
if not self.subnet_exists(netuid, block):
2866+
return None
2867+
_result = self.query_subtensor("AdjustmentAlpha", block, [netuid])
2868+
if not hasattr(_result, "value") or _result is None:
2869+
return None
2870+
return U64_NORMALIZED_FLOAT(_result.value)
2871+
2872+
def bonds_moving_avg(
2873+
self, netuid: int, block: Optional[int] = None
2874+
) -> Optional[float]:
2875+
"""Returns network BondsMovingAverage hyper parameter"""
2876+
if not self.subnet_exists(netuid, block):
2877+
return None
2878+
_result = self.query_subtensor("BondsMovingAverage", block, [netuid])
2879+
if not hasattr(_result, "value") or _result is None:
2880+
return None
2881+
return U64_NORMALIZED_FLOAT(_result.value)
2882+
28612883
def scaling_law_power(
28622884
self, netuid: int, block: Optional[int] = None
28632885
) -> Optional[float]:

0 commit comments

Comments
 (0)