Skip to content

Commit

Permalink
[feature] cpu register faster (#854) (#875)
Browse files Browse the repository at this point in the history
* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* make sure to exit properly if registered during

* fix tests

* change import to use tests

* add optional type hints and None default

* change to count using allowed processes

* add documentation. Fix random start
  • Loading branch information
Cameron Fairchild authored Aug 11, 2022
1 parent 4c177cb commit 4d8bd79
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 128 deletions.
18 changes: 18 additions & 0 deletions bittensor/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,24 @@ def config() -> 'bittensor.config':
help='''Set true to avoid prompting the user.''',
default=False,
)
register_parser.add_argument(
'--num_processes',
'--num',
'-n',
dest='num_processes',
help="Number of processors to use for registration",
type=int,
default=None,
)
register_parser.add_argument(
'--update_interval',
'-u',
dest='update_interval',
help="The number of nonces to process before checking for next block during registration",
type=int,
default=None,
)

bittensor.wallet.add_args( register_parser )
bittensor.subtensor.add_args( register_parser )

Expand Down
2 changes: 1 addition & 1 deletion bittensor/_cli/cli_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def register( self ):
"""
wallet = bittensor.wallet( config = self.config )
subtensor = bittensor.subtensor( config = self.config )
subtensor.register( wallet = wallet, prompt = not self.config.no_prompt)
subtensor.register( wallet = wallet, prompt = not self.config.no_prompt, num_processes = self.config.num_processes, update_interval = self.config.update_interval )

def transfer( self ):
r""" Transfer token of amount to destination.
Expand Down
9 changes: 5 additions & 4 deletions bittensor/_subtensor/subtensor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
# DEALINGS IN THE SOFTWARE.
import torch
from rich.prompt import Confirm
from typing import List, Dict, Union
from multiprocessing import Process
from typing import List, Dict, Union, Optional

import bittensor
from tqdm import tqdm
Expand Down Expand Up @@ -440,7 +439,9 @@ def register (
wait_for_inclusion: bool = False,
wait_for_finalization: bool = True,
prompt: bool = False,
max_allowed_attempts: int = 3
max_allowed_attempts: int = 3,
num_processes: Optional[int] = None,
update_interval: Optional[int] = None,
) -> bool:
r""" Registers the wallet to chain.
Args:
Expand Down Expand Up @@ -474,7 +475,7 @@ def register (
attempts = 1
while True:
# Solve latest POW.
pow_result = bittensor.utils.create_pow( self, wallet )
pow_result = bittensor.utils.create_pow( self, wallet, num_processes=num_processes, update_interval=update_interval )
with bittensor.__console__.status(":satellite: Registering...({}/{})".format(attempts,max_allowed_attempts)) as status:

# pow failed
Expand Down
Loading

0 comments on commit 4d8bd79

Please sign in to comment.