synapse-alpha / mirror-neuron

Experiments on bittensor reward models to find exploits
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Add plots of reward versus iteration for individual uids #50

Closed steffencruz closed 1 year ago

steffencruz commented 1 year ago

The plots below are simulations of how rewards might change within the network as a function of iterations for different uids.

rewards = []
n_steps = 1000
n_uids = 128
cheaters = np.random.randint(0,n_uids,size=10)
baselines = np.random.rand(n_uids)*0.5
#print(f'Cheaters are uids: {list(cheaters)}')
for uid in range(1,n_uids+1):
    #if uid not in cheaters: reward=np.random.rand(n_steps)
    #else: reward=0.5+np.random.rand(n_steps)*0.5

    reward = baselines[uid-1] + np.random.rand(n_steps)*(1-baselines[uid-1])
    rewards.append(reward)
df = pd.DataFrame(rewards)

Individual traces per plot are an option but there will be many (= number of uids), and this doesn't facilitate comparison of UID performance) newplot (7)

On the other hand, plotting all traces together is impossible to parse newplot (8)

Group plots are also not great. newplot (9)

Proposed Solution

I think that 2d histograms are the way to go as under/overperforming uids can be easily identified as horizontal lines.

Examples of how this might look (baseline rewards) newplot (6) With different miner (with cheaters) newplot (5)

steffencruz commented 1 year ago

Another option is exponentially weighted moving average: newplot (11)

We can also plot the average rewards and scores for each uid across the simulation to use for clustering newplot (12)

The clustering could be linked to the metagraph info such as whether the cheaters have the same coldkey or whether they are using the same API (ChatGPT)

steffencruz commented 1 year ago

This one has a RandomGatingModel where each forward call returns ones for a fixed size subset https://wandb.ai/mirror-neuron/mirror-neuron/runs/xxrudwa1?workspace=user-steffenc

And this one uses a frozen RandomGatingModel (weights never change). See how the scores are always the same versus iteration https://wandb.ai/mirror-neuron/mirror-neuron/runs/49qigtky?workspace=user-steffenc