bittensor icon indicating copy to clipboard operation
bittensor copied to clipboard

Hofix: error sum of weights in root subnet if any subnet does not exist

Open basfroman opened this issue 1 year ago • 0 comments

Describe the bug

If the subnet does not exist, then the sum of the weights in the network root is not calculated, but raises an error.

To Reproduce

With bittensor version 6.12 run the code:

import bittensor as bt

sub = bt.subtensor()
meta = sub.metagraph(netuid=0, lite=False)

Expected behavior

This raises error:

│ ❱ 762 │   │   │   │   │   bittensor.utils.weight_utils.convert_root_weight_uids_and_vals_to_te   │
│   763 │   │   │   │   │   │   n_subnets, list(uids), list(values), subnets                       │
│   764 │   │   │   │   │   )                                                                      │
│   765 │   │   │   │   )                                                                          │
│                                                                                                  │
│ /home/athrun/.bittensor/bittensor/bittensor/utils/weight_utils.py:129 in                         │
│ convert_root_weight_uids_and_vals_to_tensor                                                      │
│                                                                                                  │
│   126 │   │   if uid_j in subnets:                                                               │
│   127 │   │   │   index_s = subnets.index(uid_j)                                                 │
│   128 │   │   else:                                                                              │
│ ❱ 129 │   │   │   raise Exception("Incorrect Subnet {uid_j} in {subnets}")                       │
│   130 │   │   row_weights[index_s] = float(                                                      │
│   131 │   │   │   wij                                                                            │
│   132 │   │   )  # assumes max-upscaled values (w_max = U16_MAX).                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
Exception: Incorrect Subnet {uid_j} in {subnets}

Environment

any os

basfroman avatar May 20 '24 16:05 basfroman