Skip to content

Scoring.md #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2d80f4a
fix(dependencies): adding missing dep
hide-on-bush-x Mar 27, 2025
f0d8ed7
Merge branch 'main' of https://github.com/masa-finance/subnet-42
hide-on-bush-x Mar 28, 2025
6f11a58
feat(validator): track worker_id
hide-on-bush-x Apr 1, 2025
dc82c09
feat(validator): new tee linking
hide-on-bush-x Apr 3, 2025
bb14d74
feat(telemetry): fixing edge case
hide-on-bush-x Apr 3, 2025
f2c6f55
feat(miner): telemetry fix
hide-on-bush-x Apr 3, 2025
cd4f6fa
feat(miner): telemetry merge
hide-on-bush-x Apr 3, 2025
83149e3
feat(miner): override external ip
hide-on-bush-x Apr 4, 2025
8b07033
feat(miner): removing rising errors when post ip fails
hide-on-bush-x Apr 4, 2025
87671f7
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 4, 2025
681e375
feat(validator): registration queue fix
hide-on-bush-x Apr 4, 2025
113c308
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 4, 2025
20446a5
feat: monitor api key
hide-on-bush-x Apr 7, 2025
bda5819
feat(validator): adding monitor dashboard and fixes
hide-on-bush-x Apr 8, 2025
deb8343
fix(validator): removing log
hide-on-bush-x Apr 8, 2025
3c03411
feat(valdiator): monitoring
hide-on-bush-x Apr 8, 2025
ea74f5c
feat(docker): fixing dashbaord site
hide-on-bush-x Apr 8, 2025
0fa48ea
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 8, 2025
1a1102b
feat(validator): scoring improving
hide-on-bush-x Apr 8, 2025
b7e9239
feat(validator): restarting telemetry wehn TEE is restarted
hide-on-bush-x Apr 8, 2025
cf46cac
feat: merge
hide-on-bush-x Apr 8, 2025
88dc7bb
feat(validator): removing registered nodes from unregistered list
hide-on-bush-x Apr 9, 2025
2bc18c5
feat(validator): using dedicated TEE
hide-on-bush-x Apr 9, 2025
fc31f8e
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 9, 2025
f16b25a
feat(validator): logs improvement
hide-on-bush-x Apr 9, 2025
11415a8
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 9, 2025
fa7a8ff
feat(validator): extending loops
hide-on-bush-x Apr 10, 2025
5a0b3b8
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 10, 2025
0a679e3
feat(scoring): added md
hide-on-bush-x Apr 11, 2025
580ceaa
Merge branch 'main' of https://github.com/masa-finance/subnet-42 into…
hide-on-bush-x Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions SCORING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Subnet 42 Scoring System

## Overview

The Subnet 42 scoring system evaluates miner performance by analyzing telemetry data collected from their TEE (Trusted Execution Environment) workers. This scoring mechanism is designed to reward miners that successfully process web scraping and Twitter data collection tasks, while penalizing those with errors or failed operations.

## Telemetry Collection Process

1. **Telemetry Data Sources**: Each registered TEE worker periodically reports telemetry data that includes:
- Web scraping success and failure counts
- Twitter data collection metrics (tweets, profiles, etc.)
- Error counts by type (auth errors, rate limit errors, etc.)
- Operational timestamps

2. **Delta-based Calculations**: Rather than using absolute values, the system calculates *deltas* (changes) between telemetry snapshots to measure recent performance:
- The system stores multiple telemetry snapshots over time
- Scores are based on changes between oldest and newest snapshots
- This approach rewards recent activity and improvements

3. **TEE Restart Handling**: When a TEE worker restarts, telemetry counters may reset to zero, causing negative deltas. The system:
- Detects negative delta values in any telemetry metric
- Deletes all telemetry for that node to start fresh
- Ensures all deltas used for scoring are non-negative (using `max(0, delta)`)

## Scoring Algorithm

The scoring calculation follows these key steps:

1. **Telemetry Data Collection**: For each node:
- Retrieve telemetry data snapshots
- Calculate deltas between oldest and newest records
- Handle any negative deltas (TEE restarts)
- Store normalized delta values for scoring

2. **Key Performance Metrics**: The score primarily considers:
- `web_success`: Successful web scraping operations
- `twitter_returned_tweets`: Successfully retrieved tweets
- `twitter_returned_profiles`: Successfully retrieved Twitter profiles

3. **Kurtosis Weighting**: The system applies a custom kurtosis-like function to weight top performers more heavily:
```python
def apply_kurtosis_custom(
x,
top_percentile=90,
reward_factor=0.4,
steepness=2.0,
center_sensitivity=0.5,
boost_factor=0.2
):
```
This function:
- Applies higher weights to nodes in the top percentile (default 90%)
- Uses configurable parameters to adjust the curve's shape
- Avoids excessively punishing nodes that are performing adequately but not exceptionally

4. **Metric Normalization**: Each metric is normalized to ensure fair comparison:
- Values are scaled to a 0-1 range using min-max scaling
- Nodes with zero values receive minimal but non-zero scores
- Extreme outliers are handled appropriately

5. **Score Combination**: The final score combines weighted metrics:
- Web success, tweet retrieval, and profile retrieval each contribute to the final score
- Nodes with balanced performance across all metrics receive higher scores
- Nodes with exceptional performance in one area but poor in others receive moderate scores

6. **Validation**: Scores undergo validation checks:
- Nodes with extremely low activity receive minimal scores
- Scores are normalized to sum to 1.0 across all nodes (for setting weights)
- Invalid or disconnected nodes receive zero scores

## Weight Setting

The calculated scores are used to set weights on the Bittensor blockchain:

1. **Weight Conversion**:
- Scores are converted to weights suitable for the blockchain
- The weights determine how much TAO (the network token) each miner earns

2. **Update Frequency**:
- Weights are updated at regular intervals
- A minimum interval between updates prevents excessive blockchain transactions
- Updates are retried up to 3 times if they fail

3. **Notification**:
- Miners receive score reports with their performance metrics
- These reports provide transparency and help miners optimize their operations

## Performance Optimization

To maximize your score as a miner:

1. **Maintain Uptime**: Keep your TEE worker running continuously to avoid restarts
2. **Minimize Errors**: Reduce authentication errors, rate limits, and other failures
3. **Maximize Successful Operations**: Focus on achieving high success rates for X and web scraping
4. **Balance Performance**: Aim for good performance across all metrics rather than excelling in just one
5. **Monitor Telemetry**: Regularly check your telemetry data to identify and address issues

## Technical Implementation

The scoring system is implemented across several components:

1. **WeightsManager**: Handles the overall weight calculation process
2. **NodeManager**: Manages connections to miners and collects telemetry
3. **TelemetryStorage**: Stores and retrieves telemetry data
4. **ScoringFunctions**: Implements various mathematical scoring functions

The core of the scoring logic is in the `calculate_weights` method of the `WeightsManager` class, which:
1. Processes delta telemetry data
2. Extracts and normalizes metrics
3. Applies kurtosis weighting
4. Calculates final scores
5. Converts scores to weights

## Conclusion

The Subnet 42 scoring system is designed to fairly reward miners based on their actual performance in web scraping and Twitter data collection. By using delta-based metrics and kurtosis weighting, the system encourages continuous improvement and rewards both consistency and excellence.