From f0a3875500992119d06e9f07068fbebf33f51c62 Mon Sep 17 00:00:00 2001 From: Thykof Date: Tue, 15 Jul 2025 15:31:47 -0500 Subject: [PATCH] add use-multiprocess config --- docs/validator_guide.md | 34 ++++++++++++++++++++++++++++++++++ synth/utils/config.py | 15 +++++++++++---- synth/validator/forward.py | 3 +-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/docs/validator_guide.md b/docs/validator_guide.md index aee3a2fe..5bea3c82 100644 --- a/docs/validator_guide.md +++ b/docs/validator_guide.md @@ -23,6 +23,7 @@ - [`--neuron.sample_size INTEGER`](#--neuronsample_size-integer) - [`--neuron.timeout INTEGER`](#--neurontimeout-integer) - [`--neuron.nprocs INTEGER`](#--neuronnprocs-integer) + - [`--neuron.use_multiprocess INTEGER`](#--neuronuse_multiprocess-integer) - [`--neuron.vpermit_tao_limit INTEGER`](#--neuronvpermit_tao_limit-integer) - [`--wallet.hotkey TEXT`](#--wallethotkey-text) - [`--wallet.name TEXT`](#--walletname-text) @@ -721,6 +722,39 @@ pm2 start validator.config.js -- --neuron.vpermit_tao_limit 1000 [Back to top ^][table-of-contents] +#### `--neuron.use_multiprocess INTEGER` + +Wether to use multiple processes for the validator dendrite. + +Default: `1` + +Example to disable multiprocess: + +```js +// validator.config.js +module.exports = { + apps: [ + { + name: "validator", + interpreter: "python3", + script: "./neurons/validator.py", + args: "--neuron.use_multiprocess 0", + env: { + PYTHONPATH: ".", + }, + }, + ], +}; +``` + +Alternatively, you can add the args directly to the command: + +```shell +pm2 start validator.config.js -- --neuron.nprocs 8 +``` + +[Back to top ^][table-of-contents] + #### `--wallet.hotkey TEXT` The hotkey of the wallet. diff --git a/synth/utils/config.py b/synth/utils/config.py index 42f1c087..c3471e4c 100644 --- a/synth/utils/config.py +++ b/synth/utils/config.py @@ -41,7 +41,7 @@ def is_cuda_available(): return "cpu" -def check_config(cls, config: "bt.Config"): +def check_config(_, config: "bt.Config"): r"""Checks/validates the config namespace object.""" bt.logging.check_config(config) @@ -67,7 +67,7 @@ def check_config(cls, config: "bt.Config"): bt.logging.register_primary_logger(events_logger.name) -def add_args(cls, parser): +def add_args(_, parser): """ Adds relevant arguments to the parser for operation. """ @@ -110,7 +110,7 @@ def add_args(cls, parser): ) -def add_miner_args(cls, parser): +def add_miner_args(_, parser): """Add miner specific arguments to the parser.""" parser.add_argument( @@ -178,7 +178,7 @@ def add_miner_args(cls, parser): ) -def add_validator_args(cls, parser: argparse.ArgumentParser): +def add_validator_args(_, parser: argparse.ArgumentParser): """Add validator specific arguments to the parser.""" parser.add_argument( @@ -202,6 +202,13 @@ def add_validator_args(cls, parser: argparse.ArgumentParser): default=8, ) + parser.add_argument( + "--neuron.use_multiprocess", + type=int, + help="The number of processes to run for the validator dendrite.", + default=1, + ) + parser.add_argument( "--neuron.sample_size", type=int, diff --git a/synth/validator/forward.py b/synth/validator/forward.py index 3362859c..bda66e82 100644 --- a/synth/validator/forward.py +++ b/synth/validator/forward.py @@ -185,10 +185,9 @@ async def query_available_miners_and_save_responses( axons = [base_neuron.metagraph.axons[uid] for uid in miner_uids] - use_multiprocess = True start_time = time.time() - if use_multiprocess: + if base_neuron.config.neuron.use_multiprocess == 1: synapses = sync_forward_multiprocess( base_neuron.dendrite.keypair, base_neuron.dendrite.uuid,