Skip to content

process_weights_for_netuid breaks when there is only 1 non-zero weight #93

@dylanuys

Description

@dylanuys

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions