bittensor-subnet-template icon indicating copy to clipboard operation
bittensor-subnet-template copied to clipboard

process_weights_for_netuid breaks when there is only 1 non-zero weight

Open dylanuys opened this issue 8 months ago • 0 comments

Edge case in weight setting that only occurs when there's a single non-zero weight:

  • In weight_utils.process_weights_for_netuid , non-zero weight indices are extracted by calling np.argwhere(weights > 0).squeeze(). (line 142)
    • In the case where there is only a single weight with a non-zero value, this returns an array scalar (which is an unsized object, i.e. you cannot call len on it).
  • The resulting variable non_zero_weight_idx is used to index into uids and weights, which again produces an array scaler (lines 143-144)
  • Downstream code calls len on non_zero_weights, which fails in the case of it being an array scaler (line 168)

Toy recreation of the issue: Screenshot 2024-06-06 at 2 40 15 PM

dylanuys avatar Jun 06 '24 21:06 dylanuys