bittensor.core.extrinsics.set_weights

bittensor.core.extrinsics.set_weights#

Functions#

do_set_weights(self, wallet, uids, vals, netuid[, ...])

Internal method to send a transaction to the Bittensor blockchain, setting weights for specified neurons. This method constructs and submits the transaction, handling retries and blockchain communication.

set_weights_extrinsic(subtensor, wallet, netuid, uids, ...)

Sets the given weights and values on chain for wallet hotkey account.

Module Contents#

bittensor.core.extrinsics.set_weights.do_set_weights(self, wallet, uids, vals, netuid, version_key=version_as_int, wait_for_inclusion=False, wait_for_finalization=False, period=5)#

Internal method to send a transaction to the Bittensor blockchain, setting weights for specified neurons. This method constructs and submits the transaction, handling retries and blockchain communication.

Parameters:
  • self (bittensor.core.subtensor.Subtensor) – Subtensor interface

  • wallet (bittensor_wallet.Wallet) – The wallet associated with the neuron setting the weights.

  • uids (list[int]) – List of neuron UIDs for which weights are being set.

  • vals (list[int]) – List of weight values corresponding to each UID.

  • netuid (int) – Unique identifier for the network.

  • version_key (int) – Version key for compatibility with the network.

  • wait_for_inclusion (bool) – Waits for the transaction to be included in a block.

  • wait_for_finalization (bool) – Waits for the transaction to be finalized on the blockchain.

  • period (int) – Period dictates how long the extrinsic will stay as part of waiting pool.

Returns:

A tuple containing a success flag and an optional response message.

Return type:

tuple[bool, Optional[str]]

This method is vital for the dynamic weighting mechanism in Bittensor, where neurons adjust their trust in other neurons based on observed performance and contributions.

bittensor.core.extrinsics.set_weights.set_weights_extrinsic(subtensor, wallet, netuid, uids, weights, version_key=0, wait_for_inclusion=False, wait_for_finalization=False)[source]#

Sets the given weights and values on chain for wallet hotkey account.

Parameters:
  • subtensor (bittensor.core.subtensor.Subtensor) – Subtensor endpoint to use.

  • wallet (bittensor_wallet.Wallet) – Bittensor wallet object.

  • netuid (int) – The netuid of the subnet to set weights for.

  • uids (Union[NDArray[np.int64], torch.LongTensor, list]) – The uint64 uids of destination neurons.

  • weights (Union[NDArray[np.float32], torch.FloatTensor, list]) – The weights to set. These must be float s and correspond to the passed uid s.

  • version_key (int) – The version key of the validator.

  • wait_for_inclusion (bool) – If set, waits for the extrinsic to enter a block before returning true, or returns false if the extrinsic fails to enter the block within the timeout.

  • wait_for_finalization (bool) – If set, waits for the extrinsic to be finalized on the chain before returning true, or returns false if the extrinsic fails to be finalized within the timeout.

Returns:

A tuple containing a success flag and an optional response message.

Return type:

tuple[bool, str]