bittensor.utils.registration.register_cuda#

This module provides functions for solving Proof of Work (PoW) problems using CUDA.

Functions#

_create_seal_hash(block_and_hotkey_hash_hex_, nonce)

Creates a seal hash from the block and hotkey hash and nonce.

_hex_bytes_to_u8_list(hex_bytes)

Convert a sequence of bytes in hexadecimal format to a list of

_seal_meets_difficulty(seal_, difficulty, limit)

Checks if the seal meets the given difficulty.

log_cuda_errors()

Logs any CUDA errors.

reset_cuda()

Resets the CUDA environment.

solve_cuda(nonce_start, update_interval, tpb, ...[, ...])

Solves the PoW problem using CUDA.

Module Contents#

bittensor.utils.registration.register_cuda._create_seal_hash(block_and_hotkey_hash_hex_, nonce)#

Creates a seal hash from the block and hotkey hash and nonce.

Parameters:
  • block_and_hotkey_hash_hex_ (bytes)

  • nonce (int)

Return type:

bytes

bittensor.utils.registration.register_cuda._hex_bytes_to_u8_list(hex_bytes)#

Convert a sequence of bytes in hexadecimal format to a list of unsigned 8-bit integers.

Parameters:

hex_bytes (bytes) – A sequence of bytes in hexadecimal format.

Returns:

A list of unsigned 8-bit integers.

Return type:

list[int]

bittensor.utils.registration.register_cuda._seal_meets_difficulty(seal_, difficulty, limit)#

Checks if the seal meets the given difficulty.

Parameters:
Return type:

bool

bittensor.utils.registration.register_cuda.log_cuda_errors()#

Logs any CUDA errors.

Return type:

str

bittensor.utils.registration.register_cuda.reset_cuda()#

Resets the CUDA environment.

bittensor.utils.registration.register_cuda.solve_cuda(nonce_start, update_interval, tpb, block_and_hotkey_hash_bytes, difficulty, limit, dev_id=0)#

Solves the PoW problem using CUDA.

Parameters:
  • nonce_start (numpy.int64) – Starting nonce.

  • update_interval (numpy.int64) – Number of nonces to solve before updating block information.

  • tpb (int) – Threads per block.

  • block_and_hotkey_hash_bytes (bytes) – Keccak(Bytes of the block hash + bytes of the hotkey) 64 bytes.

  • difficulty (int) – Difficulty of the PoW problem.

  • limit (int) – Upper limit of the nonce.

  • dev_id (int) – The CUDA device ID. Defaults to 0.

Returns:

Tuple of the nonce and the seal corresponding to the solution. Returns -1 for nonce if no solution is found.

Return type:

(Union[tuple[Any, bytes], tuple[int, bytes], tuple[Any, None]])