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
16 changes: 12 additions & 4 deletions bittensor/_cli/commands/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def run (cli):
TABLE_DATA = []
total_stake = 0.0
total_rank = 0.0
total_validator_trust = 0.0
total_trust = 0.0
total_consensus = 0.0
total_weight_consensus = 0.0
total_incentive = 0.0
total_dividends = 0.0
total_emission = 0
Expand All @@ -49,23 +51,27 @@ def run (cli):
row = [
str(ep.uid),
'{:.5f}'.format( metagraph.stake[uid]),
'{:.5f}'.format( metagraph.ranks[uid]),
'{:.5f}'.format( metagraph.ranks[uid]),
'{:.5f}'.format( metagraph.trust[uid]),
'{:.5f}'.format( metagraph.consensus[uid]),
'{:.5f}'.format( metagraph.consensus[uid]),
'{:.5f}'.format( metagraph.weight_consensus[uid]),
'{:.5f}'.format( metagraph.incentive[uid]),
'{:.5f}'.format( metagraph.dividends[uid]),
'{}'.format( int(metagraph.emission[uid] * 1000000000)),
'{:.5f}'.format( metagraph.validator_trust[uid]),
'*' if metagraph.validator_permit[uid] else '',
str((metagraph.block.item() - metagraph.last_update[uid].item())),
str( metagraph.active[uid].item() ),
'*' if metagraph.validator_permit[uid] else '',
ep.ip + ':' + str(ep.port) if ep.is_serving else '[yellow]none[/yellow]',
ep.hotkey[:10],
ep.coldkey[:10]
]
total_stake += metagraph.stake[uid]
total_rank += metagraph.ranks[uid]
total_validator_trust += metagraph.validator_trust[uid]
total_trust += metagraph.trust[uid]
total_consensus += metagraph.consensus[uid]
total_weight_consensus += metagraph.weight_consensus[uid]
total_incentive += metagraph.incentive[uid]
total_dividends += metagraph.dividends[uid]
total_emission += int(metagraph.emission[uid] * 1000000000)
Expand All @@ -80,12 +86,14 @@ def run (cli):
table.add_column("[overline white]RANK", '{:.5f}'.format(total_rank), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]TRUST", '{:.5f}'.format(total_trust), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]CONSENSUS", '{:.5f}'.format(total_consensus), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]WCONSENSUS", '{:.5f}'.format(total_weight_consensus), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]INCENTIVE", '{:.5f}'.format(total_incentive), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]DIVIDENDS", '{:.5f}'.format(total_dividends), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]EMISSION(\u03C1)", '\u03C1{}'.format(int(total_emission)), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VTRUST", '{:.5f}'.format(total_validator_trust), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VAL", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]UPDATED", justify='right', no_wrap=True)
table.add_column("[overline white]ACTIVE", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VAL", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]AXON", justify='left', style='dim blue', no_wrap=True)
table.add_column("[overline white]HOTKEY", style='dim blue', no_wrap=False)
table.add_column("[overline white]COLDKEY", style='dim purple', no_wrap=False)
Expand Down
15 changes: 12 additions & 3 deletions bittensor/_cli/commands/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def run( cli ):
total_rank = 0.0
total_trust = 0.0
total_consensus = 0.0
total_validator_trust = 0.0
total_weight_consensus = 0.0
total_incentive = 0.0
total_dividends = 0.0
total_emission = 0
Expand All @@ -126,6 +128,8 @@ def run( cli ):
rank = nn.rank
trust = nn.trust
consensus = nn.consensus
validator_trust = nn.validator_trust
weight_consensus = nn.weight_consensus
incentive = nn.incentive
dividends = nn.dividends
emission = int(nn.emission * 1000000000)
Expand All @@ -139,22 +143,26 @@ def run( cli ):
'{:.5f}'.format(stake),
'{:.5f}'.format(rank),
'{:.5f}'.format(trust),
'{:.5f}'.format(consensus),
'{:.5f}'.format(consensus),
'{:.5f}'.format(weight_consensus),
'{:.5f}'.format(incentive),
'{:.5f}'.format(dividends),
'{}'.format(emission),
str(last_update),
'{:.5f}'.format(validator_trust),
'*' if validator_permit else '',
str(last_update),
bittensor.utils.networking.int_to_ip( nn.axon_info.ip) + ':' + str(nn.axon_info.port) if nn.axon_info.port != 0 else '[yellow]none[/yellow]',
nn.hotkey
]
total_stake += stake
total_rank += rank
total_trust += trust
total_consensus += consensus
total_weight_consensus += weight_consensus
total_incentive += incentive
total_dividends += dividends
total_emission += emission
total_validator_trust += validator_trust
TABLE_DATA.append(row)

total_neurons = len(neurons)
Expand All @@ -174,8 +182,9 @@ def run( cli ):
table.add_column("[overline white]INCENTIVE", '{:.5f}'.format(total_incentive), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]DIVIDENDS", '{:.5f}'.format(total_dividends), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]EMISSION(\u03C1)", '\u03C1{}'.format(int(total_emission)), footer_style = "overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]UPDATED", justify='right', no_wrap=True)
table.add_column("[overline white]VTRUST", '{:.5f}'.format(total_validator_trust), footer_style="overline white", justify='right', style='green', no_wrap=True)
table.add_column("[overline white]VAL", justify='right', no_wrap=True)
table.add_column("[overline white]UPDATED", justify='right', no_wrap=True)
table.add_column("[overline white]AXON", justify='left', style='dim blue', no_wrap=True)
table.add_column("[overline white]HOTKEY_SS58", style='dim blue', no_wrap=False)
table.show_footer = True
Expand Down
8 changes: 8 additions & 0 deletions bittensor/_metagraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def from_neurons( network: str, netuid: int, neurons: List['bittensor.NeuronInfo
ranks = [ 0 for _ in range(n_total) ]
trust = [ 0 for _ in range(n_total) ]
consensus = [ 0 for _ in range(n_total) ]
validator_trust = [ 0 for _ in range(n_total) ]
weight_consensus = [ 0 for _ in range(n_total) ]
incentive = [ 0 for _ in range(n_total) ]
emission = [ 0 for _ in range(n_total) ]
dividends = [ 0 for _ in range(n_total) ]
Expand All @@ -155,6 +157,8 @@ def from_neurons( network: str, netuid: int, neurons: List['bittensor.NeuronInfo
ranks[n.uid] = n.rank
trust[n.uid] = n.trust
consensus[n.uid] = n.consensus
validator_trust[n.uid] = n.validator_trust
weight_consensus[n.uid] = n.weight_consensus
incentive[n.uid] = n.incentive
dividends[n.uid] = n.dividends
emission[n.uid] = n.emission
Expand Down Expand Up @@ -183,6 +187,8 @@ def from_neurons( network: str, netuid: int, neurons: List['bittensor.NeuronInfo
tranks = torch.tensor( ranks, dtype=torch.float32 )
ttrust = torch.tensor( trust, dtype=torch.float32 )
tconsensus = torch.tensor( consensus, dtype=torch.float32 )
tvalidator_trust = torch.tensor( validator_trust, dtype=torch.float32 )
tweight_consensus = torch.tensor( weight_consensus, dtype=torch.float32 )
tincentive = torch.tensor( incentive, dtype=torch.float32 )
temission = torch.tensor( emission, dtype=torch.float32 )
tdividends = torch.tensor( dividends, dtype=torch.float32 )
Expand All @@ -203,6 +209,8 @@ def from_neurons( network: str, netuid: int, neurons: List['bittensor.NeuronInfo
metagraph.ranks = torch.nn.Parameter( tranks, requires_grad=False )
metagraph.trust = torch.nn.Parameter( ttrust, requires_grad=False )
metagraph.consensus = torch.nn.Parameter( tconsensus, requires_grad=False )
metagraph.validator_trust = torch.nn.Parameter( tvalidator_trust, requires_grad=False )
metagraph.weight_consensus = torch.nn.Parameter( tweight_consensus, requires_grad=False )
metagraph.incentive = torch.nn.Parameter( tincentive, requires_grad=False )
metagraph.emission = torch.nn.Parameter( temission, requires_grad=False )
metagraph.dividends = torch.nn.Parameter( tdividends, requires_grad=False )
Expand Down
22 changes: 20 additions & 2 deletions bittensor/_metagraph/metagraph_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def clear( self ) -> 'Metagraph':
self.ranks = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.trust = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.consensus = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.validator_trust = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.weight_consensus = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.incentive = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.emission = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.dividends = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
Expand Down Expand Up @@ -127,6 +129,18 @@ def T(self) -> torch.FloatTensor:
"""
return self.trust

@property
def Cw(self) -> torch.FloatTensor:
""" Weight consensus
"""
return self.weight_consensus

@property
def Tv(self) -> torch.FloatTensor:
""" Validator trust
"""
return self.validator_trust

@property
def D(self) -> torch.FloatTensor:
""" Dividends
Expand Down Expand Up @@ -296,6 +310,8 @@ def load_from_state_dict(self, state_dict:dict ) -> 'Metagraph':
self.ranks = torch.nn.Parameter( state_dict['ranks'], requires_grad=False )
self.trust = torch.nn.Parameter( state_dict['trust'], requires_grad=False )
self.consensus = torch.nn.Parameter( state_dict['consensus'], requires_grad=False )
self.validator_trust = torch.nn.Parameter( state_dict['validator_trust'], requires_grad=False )
self.weight_consensus = torch.nn.Parameter( state_dict['weight_consensus'], requires_grad=False )
self.incentive = torch.nn.Parameter( state_dict['incentive'], requires_grad=False )
self.emission = torch.nn.Parameter( state_dict['emission'], requires_grad=False )
self.dividends = torch.nn.Parameter( state_dict['dividends'], requires_grad=False )
Expand Down Expand Up @@ -333,7 +349,7 @@ def sync ( self, netuid: int, subtensor: 'bittensor.Subtensor' = None, block: Op
def to_dataframe(self):
try:
index = self.uids.tolist()
columns = [ 'uid', 'active', 'stake', 'rank', 'trust', 'consensus', 'incentive', 'dividends', 'emission']
columns = [ 'uid', 'active', 'stake', 'rank', 'trust', 'consensus', 'validator_trust', 'weight_consensus', 'incentive', 'dividends', 'emission']
dataframe = pandas.DataFrame(columns = columns, index = index)
for uid in self.uids.tolist():
v = {
Expand All @@ -342,7 +358,9 @@ def to_dataframe(self):
'stake': self.stake[uid].item(),
'rank': self.ranks[uid].item(),
'trust': self.trust[uid].item(),
'consensus': self.consensus[uid].item(),
'consensus': self.consensus[uid].item(),
'validator_trust': self.validator_trust[uid].item(),
'weight_consensus': self.weight_consensus[uid].item(),
'incentive': self.incentive[uid].item(),
'dividends': self.dividends[uid].item(),
'emission': self.emission[uid].item()
Expand Down
6 changes: 6 additions & 0 deletions bittensor/_metagraph/metagraph_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__( self ):
tranks = torch.tensor( [1.0/2000 for _ in range (2000) ], dtype=torch.float32 )
ttrust = torch.tensor( [ 1.0 for _ in range (2000) ], dtype=torch.float32 )
tconsensus = torch.tensor( [1.0 for _ in range (2000) ], dtype=torch.float32 )
tvalidator_trust = torch.tensor( [ 1.0 for _ in range (2000) ], dtype=torch.float32 )
tweight_consensus = torch.tensor( [1.0 for _ in range (2000) ], dtype=torch.float32 )
tincentive = torch.tensor( [1.0/2000 for _ in range (2000) ], dtype=torch.float32 )
temission = torch.tensor( [1.0/2000 for _ in range (2000) ], dtype=torch.float32 )
tdividends = torch.tensor( [1.0/2000 for _ in range (2000) ], dtype=torch.float32 )
Expand All @@ -64,6 +66,8 @@ def __init__( self ):
self.ranks = torch.nn.Parameter( tranks, requires_grad=False )
self.trust = torch.nn.Parameter( ttrust, requires_grad=False )
self.consensus = torch.nn.Parameter( tconsensus, requires_grad=False )
self.validator_trust = torch.nn.Parameter( tvalidator_trust, requires_grad=False )
self.weight_consensus = torch.nn.Parameter( tweight_consensus, requires_grad=False )
self.incentive = torch.nn.Parameter( tincentive, requires_grad=False )
self.emission = torch.nn.Parameter( temission, requires_grad=False )
self.dividends = torch.nn.Parameter( tdividends, requires_grad=False )
Expand All @@ -87,6 +91,8 @@ def clear( self ) -> 'Metagraph':
self.ranks = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.trust = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.consensus = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.validator_trust = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.weight_consensus = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.incentive = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.emission = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
self.dividends = torch.nn.Parameter( torch.tensor( [], dtype=torch.float32), requires_grad=False )
Expand Down
4 changes: 4 additions & 0 deletions bittensor/_neuron/text/core_server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def backward_callback(inputs_x:torch.FloatTensor, grads_dy:torch.FloatTensor, sy
'rank': nn.rank,
'trust': nn.trust,
'consensus': nn.consensus,
'validator_trust': nn.validator_trust,
'weight_consensus': nn.weight_consensus,
'incentive': nn.incentive,
'emission': nn.emission,
}
Expand All @@ -451,6 +453,8 @@ def backward_callback(inputs_x:torch.FloatTensor, grads_dy:torch.FloatTensor, sy
prometheus_guages.labels("rank").set( nn.rank )
prometheus_guages.labels("trust").set( nn.trust )
prometheus_guages.labels("consensus").set( nn.consensus )
prometheus_guages.labels("validator_trust").set( nn.validator_trust )
prometheus_guages.labels("weight_consensus").set( nn.weight_consensus )
prometheus_guages.labels("incentive").set( nn.incentive )
prometheus_guages.labels("emission").set( nn.emission )

Expand Down
18 changes: 13 additions & 5 deletions bittensor/_subtensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class NeuronInfo:
incentive: float
consensus: float
trust: float
weight_consensus: float
validator_trust: float
dividends: float
last_update: int
validator_permit: bool
Expand All @@ -71,6 +73,8 @@ def from_json(cls, json: Dict) -> 'NeuronInfo':
incentive = json['incentive'] / U16_MAX,
consensus = json['consensus'] / U16_MAX,
trust = json['trust'] / U16_MAX,
weight_consensus = json['weight_consensus'] / U16_MAX,
validator_trust = json['validator_trust'] / U16_MAX,
dividends = json['dividends'] / U16_MAX,
last_update = json['last_update'],
validator_permit = json['validator_permit'],
Expand All @@ -93,6 +97,8 @@ def _null_neuron() -> 'NeuronInfo':
incentive = 0,
consensus = 0,
trust = 0,
weight_consensus = 0,
validator_trust = 0,
dividends = 0,
last_update = 0,
validator_permit = False,
Expand All @@ -113,11 +119,13 @@ def _neuron_dict_to_namespace(neuron_dict) -> 'NeuronInfo':
else:
neuron = NeuronInfo( **neuron_dict )
neuron.stake = neuron.stake / RAOPERTAO
neuron.rank = neuron.rank / U64_MAX
neuron.trust = neuron.trust / U64_MAX
neuron.consensus = neuron.consensus / U64_MAX
neuron.incentive = neuron.incentive / U64_MAX
neuron.dividends = neuron.dividends / U64_MAX
neuron.rank = neuron.rank / U16_MAX
neuron.trust = neuron.trust / U16_MAX
neuron.consensus = neuron.consensus / U16_MAX
neuron.validator_trust = neuron.validator_trust / U16_MAX
neuron.weight_consensus = neuron.weight_consensus / U16_MAX
neuron.incentive = neuron.incentive / U16_MAX
neuron.dividends = neuron.dividends / U16_MAX
neuron.emission = neuron.emission / RAOPERTAO

return neuron
Expand Down
2 changes: 2 additions & 0 deletions bittensor/_subtensor/subtensor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ def _null_neuron() -> NeuronInfo:
incentive = 0,
consensus = 0,
trust = 0,
weight_consensus = 0,
validator_trust = 0,
dividends = 0,
last_update = 0,
validator_permit = False,
Expand Down
12 changes: 7 additions & 5 deletions bittensor/_subtensor/subtensor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
["validator_permit", "bool"],
["priority", "u64"],
["stake", "u64"],
["rank", "u64"],
["trust", "u64"],
["consensus", "u64"],
["incentive", "u64"],
["dividends", "u64"],
["rank", "u16"],
["trust", "u16"],
["consensus", "u16"],
["validator_trust", "u16"],
["weight_consensus", "u16"],
["incentive", "u16"],
["dividends", "u16"],
["emission", "u64"],
["bonds", "Vec<(u32, u64)>"],
["weights", "Vec<(u32, u32)>"]
Expand Down
Loading