Skip to content

Commit f1c8c15

Browse files
authored
v2.1.28 (#688)
2 parents 8dafcd2 + dc9a5f1 commit f1c8c15

3 files changed

Lines changed: 94 additions & 16 deletions

File tree

neurons/burn.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python3
2+
"""Set 100% weights to burn UID every 360 blocks."""
3+
4+
import argparse
5+
import time
6+
7+
import bittensor as bt
8+
9+
import tplr
10+
11+
BURN_UID = 1 # Same as validator.py
12+
WEIGHT_INTERVAL = 360 # Blocks between weight sets
13+
14+
15+
def get_config():
16+
parser = argparse.ArgumentParser(description="Burn-only validator script")
17+
parser.add_argument(
18+
"--netuid", type=int, default=268, help="Bittensor network UID."
19+
)
20+
bt.subtensor.add_args(parser)
21+
bt.logging.add_args(parser)
22+
bt.wallet.add_args(parser)
23+
return bt.config(parser)
24+
25+
26+
def main():
27+
config = get_config()
28+
29+
wallet = bt.wallet(config=config)
30+
subtensor = bt.subtensor(config=config)
31+
32+
metagraph = subtensor.metagraph(config.netuid)
33+
my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
34+
tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}")
35+
tplr.logger.info(
36+
f"Will set 100% weight to burn UID {BURN_UID} every {WEIGHT_INTERVAL} blocks"
37+
)
38+
39+
last_set_block = 0
40+
log_interval = 10 # Log status every N iterations (~2 minutes)
41+
iteration = 0
42+
43+
while True:
44+
try:
45+
current_block = subtensor.block
46+
blocks_since_last = current_block - last_set_block
47+
blocks_until_next = max(0, WEIGHT_INTERVAL - blocks_since_last)
48+
49+
if blocks_since_last >= WEIGHT_INTERVAL:
50+
tplr.logger.info(
51+
f"Block {current_block}: Setting weights to burn UID {BURN_UID}"
52+
)
53+
54+
success, msg = subtensor.set_weights(
55+
wallet=wallet,
56+
netuid=config.netuid,
57+
uids=[BURN_UID],
58+
weights=[1.0],
59+
wait_for_inclusion=True,
60+
)
61+
62+
if success:
63+
tplr.logger.info(
64+
f"Weights set successfully at block {current_block}"
65+
)
66+
last_set_block = current_block
67+
else:
68+
tplr.logger.warning(f"Failed to set weights: {msg}")
69+
else:
70+
# Periodic status log
71+
iteration += 1
72+
if iteration % log_interval == 0:
73+
tplr.logger.info(
74+
f"Block {current_block} | "
75+
f"Blocks until next weight set: {blocks_until_next} | "
76+
f"Last set: {last_set_block or 'never'}"
77+
)
78+
79+
time.sleep(12)
80+
81+
except KeyboardInterrupt:
82+
tplr.logger.info("Shutting down...")
83+
break
84+
except Exception as e:
85+
tplr.logger.error(f"Error: {e}")
86+
time.sleep(12)
87+
88+
89+
if __name__ == "__main__":
90+
main()

scripts/entrypoint.sh

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,12 @@ if [ "$NODE_TYPE" = "miner" ]; then
6060
${PROJECT:+--project ${PROJECT}} \
6161
${DEBUG_FLAG}
6262
elif [ "$NODE_TYPE" = "validator" ]; then
63-
echo "Starting validator with torchrun..."
64-
# Enable per-rank logging to separate files
65-
exec torchrun \
66-
--standalone \
67-
--nnodes 1 \
68-
--nproc_per_node 4 \
69-
--log_dir /app/logs/torchrun \
70-
--redirects 3 \
71-
--tee 3 \
72-
neurons/validator.py \
63+
echo "Starting burn validator..."
64+
exec python neurons/burn.py \
7365
--wallet.name ${WALLET_NAME} \
7466
--wallet.hotkey ${WALLET_HOTKEY} \
7567
--netuid ${NETUID} \
76-
--device cuda \
77-
--subtensor.network ${NETWORK} \
78-
--use_wandb \
79-
${PROJECT:+--project ${PROJECT}} \
80-
${DEBUG_FLAG}
68+
--subtensor.network ${NETWORK}
8169
elif [ "$NODE_TYPE" = "evaluator" ]; then
8270
# Count the number of visible GPUs for evaluator
8371
if [ -n "$NVIDIA_VISIBLE_DEVICES" ]; then

src/tplr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# mypy: ignore-errors
2121
# type: ignore
2222

23-
__version__ = "2.1.27"
23+
__version__ = "2.1.28"
2424

2525
# Import package.
2626
from .chain import *

0 commit comments

Comments
 (0)