Conversation
Implement temporary burn validator for 100% burn period until Crusades launches. Replaces normal validator behavior during transition phase. - Add neurons/burn.py to set 100% weight to UID 1 every 360 blocks - Update entrypoint.sh to run burn.py instead of full validator - Remove torchrun and wandb dependencies for burn mode - Add periodic status logging every 2 minutes
WalkthroughThis PR introduces a new burn-only validator module ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #688 +/- ##
=======================================
Coverage 57.69% 57.69%
=======================================
Files 27 27
Lines 4990 4990
=======================================
Hits 2879 2879
Misses 2111 2111
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/entrypoint.sh (1)
8-31: Gate CUDA/WANDB checks by NODE_TYPE to avoid blocking burn validator.
With burn-only validator, unconditional CUDA and WANDB checks (and WANDB_API_KEY requirement) can prevent validator startup in CPU-only or no-WANDB environments. Move these checks into the miner/evaluator branches (and only require WANDB for miner).🔧 Suggested refactor
-# Check required environment variables -for var in WALLET_NAME WALLET_HOTKEY NODE_TYPE WANDB_API_KEY NETUID; do + # Check required environment variables +for var in WALLET_NAME WALLET_HOTKEY NODE_TYPE NETUID; do if [ -z "${!var}" ]; then echo "Error: $var environment variable is required" exit 1 fi done @@ -# Check CUDA availability -if ! python3 -c "import torch; assert torch.cuda.is_available(), 'CUDA not available'"; then - echo "Error: CUDA is not available" - echo "Available GPUs:" - (set +e; nvidia-smi -L 2>/dev/null) || echo "nvidia-smi not available" - exit 1 -fi - -# Login to wandb non-interactively -wandb login ${WANDB_API_KEY} --relogin +# NOTE: CUDA/WANDB only needed for miner/evaluatorif [ "$NODE_TYPE" = "miner" ]; then + if [ -z "${WANDB_API_KEY}" ]; then + echo "Error: WANDB_API_KEY environment variable is required" + exit 1 + fi + if ! python3 -c "import torch; assert torch.cuda.is_available(), 'CUDA not available'"; then + echo "Error: CUDA is not available" + echo "Available GPUs:" + (set +e; nvidia-smi -L 2>/dev/null) || echo "nvidia-smi not available" + exit 1 + fi + wandb login ${WANDB_API_KEY} --relogin echo "Starting miner with torchrun..." @@ elif [ "$NODE_TYPE" = "validator" ]; then echo "Starting burn validator..." exec python neurons/burn.py \ @@ elif [ "$NODE_TYPE" = "evaluator" ]; then + if ! python3 -c "import torch; assert torch.cuda.is_available(), 'CUDA not available'"; then + echo "Error: CUDA is not available" + echo "Available GPUs:" + (set +e; nvidia-smi -L 2>/dev/null) || echo "nvidia-smi not available" + exit 1 + fi # Count the number of visible GPUs for evaluatorAlso applies to: 22-31, 63-68
🤖 Fix all issues with AI agents
In `@neurons/burn.py`:
- Around line 32-34: metagraph.hotkeys.index(...) can raise ValueError when
wallet.hotkey.ss58_address is not registered; before calling index, check
membership (e.g., if wallet.hotkey.ss58_address in metagraph.hotkeys) and if
missing log a clear error via tplr.logger.error with context (include the hotkey
and config.netuid) and exit/return cleanly; alternatively wrap the
metagraph.hotkeys.index call in a try/except ValueError that logs the same clear
message and exits to avoid an unhandled exception.
| metagraph = subtensor.metagraph(config.netuid) | ||
| my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address) | ||
| tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}") |
There was a problem hiding this comment.
Gracefully handle unregistered hotkey before indexing.
metagraph.hotkeys.index(...) throws ValueError if the hotkey isn’t registered; handle this explicitly to give a clear error and exit cleanly.
✅ Suggested guard
import argparse
import time
+import sys
@@
- metagraph = subtensor.metagraph(config.netuid)
- my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
+ metagraph = subtensor.metagraph(config.netuid)
+ if wallet.hotkey.ss58_address not in metagraph.hotkeys:
+ tplr.logger.error(
+ f"Hotkey {wallet.hotkey.ss58_address} is not registered on netuid {config.netuid}"
+ )
+ sys.exit(1)
+ my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| metagraph = subtensor.metagraph(config.netuid) | |
| my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address) | |
| tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}") | |
| metagraph = subtensor.metagraph(config.netuid) | |
| if wallet.hotkey.ss58_address not in metagraph.hotkeys: | |
| tplr.logger.error( | |
| f"Hotkey {wallet.hotkey.ss58_address} is not registered on netuid {config.netuid}" | |
| ) | |
| sys.exit(1) | |
| my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address) | |
| tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}") |
🤖 Prompt for AI Agents
In `@neurons/burn.py` around lines 32 - 34, metagraph.hotkeys.index(...) can raise
ValueError when wallet.hotkey.ss58_address is not registered; before calling
index, check membership (e.g., if wallet.hotkey.ss58_address in
metagraph.hotkeys) and if missing log a clear error via tplr.logger.error with
context (include the hotkey and config.netuid) and exit/return cleanly;
alternatively wrap the metagraph.hotkeys.index call in a try/except ValueError
that logs the same clear message and exits to avoid an unhandled exception.
Description
Related Issue(s)
Type of Change
Branch Naming
Commit Messages
Code Quality
Testing
Documentation
If this is a breaking change
Screenshots/Examples
Additional Notes
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.