Skip to content

feat: add response speed tracking in reward calculation#86

Open
0xsatoshi99 wants to merge 1 commit into
shiftlayer-llc:mainfrom
0xsatoshi99:feat/response-speed-reward
Open

feat: add response speed tracking in reward calculation#86
0xsatoshi99 wants to merge 1 commit into
shiftlayer-llc:mainfrom
0xsatoshi99:feat/response-speed-reward

Conversation

@0xsatoshi99

Copy link
Copy Markdown

Summary

Implements issue #35 - Consider response speed in reward calculation.

This PR adds response latency tracking and applies speed-based multipliers to miner rewards, encouraging miners to optimize their code for the shortest latency.

Changes

New File: game/validator/response_speed.py

  • ResponseMetrics: Dataclass tracking per-miner response times, timeout counts, and query totals
  • GameResponseTracker: Manages metrics for all miners throughout a game session
  • Speed multiplier calculation: Calculates bonus/penalty based on average response time
  • apply_speed_multipliers(): Applies speed adjustments to base rewards

Modified: game/validator/forward.py

  • Initialize GameResponseTracker at game start
  • Record response times for each miner query (including timeouts)
  • Apply speed multipliers to final rewards before storing
  • Log response speed summary at game end

Speed Multiplier Logic

Response Time Multiplier
< 5 seconds Up to +30% bonus
5-20 seconds No adjustment (1.0x)
> 20 seconds Up to -20% penalty
>50% timeout rate Maximum penalty (-20%)

Example Output

📊 Response Speed Summary:
  UID 42: avg=3.21s, fastest=2.15s, timeouts=0/4, multiplier=1.21x
  UID 87: avg=18.45s, fastest=12.30s, timeouts=1/4, multiplier=0.95x

Benefits

  • Incentivizes miners to optimize inference speed
  • Penalizes unreliable miners with frequent timeouts
  • Rewards consistent, fast responders
  • Transparent logging for debugging

Fixes #35


Contribution by Gittensor, learn more at https://gittensor.io/

Implements issue shiftlayer-llc#35 - Consider response speed in reward calculation.

Changes:
- Add new response_speed.py module with:
  - ResponseMetrics: tracks per-miner response times
  - GameResponseTracker: manages metrics for all miners in a game
  - Speed multiplier calculation (bonus for fast, penalty for slow)
  - apply_speed_multipliers: applies speed adjustments to rewards

- Update forward.py to:
  - Initialize GameResponseTracker at game start
  - Record response times for each miner query
  - Apply speed multipliers to final rewards
  - Log response speed summary at game end

Speed multiplier logic:
- Fast responses (<5s): up to +30% bonus
- Normal responses (5-20s): no adjustment
- Slow responses (>20s): up to -20% penalty
- High timeout rate (>50%): maximum penalty

This encourages miners to optimize their code for lowest latency.
@0xsatoshi99

Copy link
Copy Markdown
Author

@ultrashiny Can you please check this PR and let me know your opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider response speed in reward calculation

1 participant