Skip to content

Fix neuron pruning #1903

@ppolewicz

Description

@ppolewicz

As users of sn17 observed this week, pruning neurons can sometimes be unfair - it might cause two miners to be deregistered in wrong order.

When we looked into it closely, Fish summarized:

pruning score and emissions are stored differently as storage values so you can have cases where they might have different emissions but the same pruning score meaning it would default to registration date. This is likely happening here. Pruning score is not exactly the same as emission even though it's based on it.

I'd like to propose a slight simplification of the registration process:

  • align the registration cycle with tempo (not removing the concept of the registration cycle - we might need it if dynamic tempo is ever implemented)
  • remove trust
  • remove pruning score
  • remove rank
  • replace the logic contained in
    pub fn get_neuron_to_prune(netuid: NetUid) -> u16 {
    with a rust equivalent of list(sorted(neurons, lambda neuron: not neuron.is_immune, neuron.emission, neuron.registration_block, neuron.uid))[0] - so every time we need to select a neuron for pruning, we'd sort the neurons by non_immunity, emission, registration block and the actual uid number and pick the lowest one for pruning.

The current system seems to be half-designed for thousands of registrations per block. It's confusing, unnecessarily stateful, unfair due to some implementation detail and hard to explain, when it doesn't have to be (even for me lol). If we ever needed something like this, then we'd calculate it once during the first deregistration in the given tempo and we'd store a queue of THREE uids which can potentially be deregistered in the current tempo after the one we are deregistering right now... but even that is premature optimization because chatgpt says sorting a thousand structs by 4 integer properties using a modern CPU should take about 5-50 microseconds. We don't need an elaborate caching scheme here when reading from the cache would take more time than recalculating the result.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions