Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] [cubit] CUDA registration solver #868

Merged
merged 54 commits into from
Aug 15, 2022
Merged

Conversation

camfairchild
Copy link
Collaborator

This PR adds a CUDA solver for the registration POW.

  • Requires: cubit
    • see requirements for cubit
  • installed as extra pip install -e .[cubit]
  • will throw error if the user doesn't have a CUDA device and/or cubit

New Flags

  • --cuda (default: False) to use CUDA registration (if available)
  • --cuda.dev_id <int> (default: 0)
  • --cuda.TPB <int, 128, 256, 512> (default: 256)
    • the number of threads per block in the CUDA kernel
      • should be left at default or raised to 512
      • may crash the registration process if too high
        • power of 2 only
  • --cuda.update_interval <int> (default: 50_000)
    • the number of nonces to solve between chain updates
      • can be raised or lowered.
        • having a higher value may mean less-frequent chain updates which may lead to trying to submit a solution outside of the valid solve window for that block (not efficient)

@camfairchild camfairchild added enhancement New feature or request feature new feature added labels Aug 5, 2022
@camfairchild camfairchild changed the base branch from master to nobunaga August 5, 2022 01:53
@coveralls
Copy link

Pull Request Test Coverage Report for Build 9887610a-0822-4309-8bb1-f5943016608e

  • 55 of 298 (18.46%) changed or added relevant lines in 4 files are covered.
  • 698 unchanged lines in 22 files lost coverage.
  • Overall coverage decreased (-16.5%) to 65.303%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bittensor/_subtensor/subtensor_impl.py 1 8 12.5%
bittensor/utils/register_cuda.py 8 43 18.6%
bittensor/utils/init.py 41 242 16.94%
Files with Coverage Reduction New Missed Lines %
bittensor/_dataset/thread_queue.py 1 97.14%
bittensor/_keyfile/init.py 1 90.91%
bittensor/_metagraph/init.py 1 79.49%
bittensor/_tokenizer/init.py 1 68.29%
bittensor/_wallet/wallet_mock.py 1 72.97%
bittensor/utils/balance.py 2 66.67%
bittensor/_dataset/dataset_impl.py 4 89.44%
bittensor/_subtensor/init.py 4 78.16%
bittensor/_subtensor/subtensor_mock.py 4 85.9%
bittensor/_config/init.py 8 70.97%
Totals Coverage Status
Change from base Build 4e1e1b4f-b1e3-466c-8141-fd4e3f9265c2: -16.5%
Covered Lines: 3529
Relevant Lines: 5404

💛 - Coveralls

@camfairchild camfairchild requested review from Eugene-hu, shibshib, isabella618033 and joeylegere and removed request for Eugene-hu August 12, 2022 01:10
@shibshib
Copy link
Contributor

Tested this and overall looks good! But looks like when running using btcli run it won't use cuda to register, so these flags don't quite apply there correct?

Copy link
Contributor

@shibshib shibshib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflicts still to be fixed

@camfairchild
Copy link
Collaborator Author

Tested this and overall looks good! But looks like when running using btcli run it won't use cuda to register, so these flags don't quite apply there correct?

I'll have to add those flags.

@camfairchild camfairchild merged commit c546d3f into nobunaga Aug 15, 2022
camfairchild added a commit that referenced this pull request Aug 16, 2022
…d [feature] CUDA reg (#877)

* [feature] cpu register faster (#854)

* 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

* [hotfix] fix flags for multiproc register limit (#876)

* add dot get

* add to subtensor args and defaults

* remove dot get because in subtensor args

* typo

* fix test

* Fix/diff unpack bit shift (#878)

* fix incorrect bit shift

* move inner function out and add test for diff pack

* fix test

* fix call arg check in test

* add assert

* fix test for py37

* refactor the diff pack into two functions
move the test to a unit test

* fix test

* [Feature] [cubit] CUDA registration solver (#868)

* added cuda solver

* boost versions to fix pip error

* allow choosing device id

* fix solution check to use keccak

* adds params for cuda and dev_id to register

* list devices by name during selection

* add block number logging

* fix calculation of hashrate

* fix update interval default

* add --TPB arg to register

* add update_interval flag

* switch back to old looping/work structure

* change typing

* device count is a function

* stop early if wallet registered

* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* change import to cubit

* fix import and default

* up default
should have default in CLI call

* add comments about params

* fix config var access

* add cubit as extra

* handle stale pow differently
check registration after failure

* restrict number of processes for integration test

* fix stale check

* use wallet.is_registered instead

* attempt to fix test issue

* fix my test

* oops typo

* typo again ugh

* remove print out

* fix partly reg test

* fix if solution None

* fix test?

* fix patch

* add args for cuda to subtensor

* add cuda args to reregister call

* add to wallet register the cuda args

* fix refs and tests

* add for val test also

* fix tests with rereg

* fix patch for tests

* add mock_register to subtensor passed instead

* move register under the check for isregistered

* use patch obj instead

* fit patch object

* Fix/move overview args to cli (#867)

* move cli args to CLI and fix overview

* use dot get

* fix tests

* add hotkeys/all_hotkeys to (un)stake

* fix default

* fix default in unstake

* add unstake multiple

* add add stake multiple

* move all/hotkeys back to wallet args

* convert to balance first
add catch for unstake multi

* fix ref to wallet

* fix test patch for multi hotkeys

* try to fix tests

* fix tests patch

* fix mock wallet length

* don't use new?

* fix call args get

* typo

* fix typo

* Add/address CUDA reg changes (#879)

* added cuda solver

* boost versions to fix pip error

* allow choosing device id

* fix solution check to use keccak

* adds params for cuda and dev_id to register

* list devices by name during selection

* add block number logging

* fix calculation of hashrate

* fix update interval default

* add --TPB arg to register

* add update_interval flag

* switch back to old looping/work structure

* change typing

* device count is a function

* stop early if wallet registered

* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* change import to cubit

* fix import and default

* up default
should have default in CLI call

* add comments about params

* fix config var access

* add cubit as extra

* handle stale pow differently
check registration after failure

* restrict number of processes for integration test

* fix stale check

* use wallet.is_registered instead

* attempt to fix test issue

* fix my test

* oops typo

* typo again ugh

* remove print out

* fix partly reg test

* fix if solution None

* fix test?

* fix patch

* add args for cuda to subtensor

* add cuda args to reregister call

* add to wallet register the cuda args

* fix refs and tests

* add for val test also

* fix tests with rereg

* fix patch for tests

* add mock_register to subtensor passed instead

* move register under the check for isregistered

* use patch obj instead

* fit patch object

* fix prompt

* remove unneeded if

* modify POW submit to use rolling submit again

* add backoff to block get from network

* add test for backoff get block

* suppress the dev id flag if not set

* remove dest so it uses first arg

* fix pow submit loop

* move registration status with

* fix max attempts check

* remove status in subtensor.register

* add submit status

* change to neuron get instead

* fix count

* try to patch live display

* fix patch

* .

* separate test cases

* add POWNotStale and tests

* add more test cases for block get with retry

* fix return to None

* fix arg order

Co-authored-by: Eugene <etesting007@gmail.com>
robertalanm pushed a commit that referenced this pull request Aug 17, 2022
* added cuda solver

* boost versions to fix pip error

* allow choosing device id

* fix solution check to use keccak

* adds params for cuda and dev_id to register

* list devices by name during selection

* add block number logging

* fix calculation of hashrate

* fix update interval default

* add --TPB arg to register

* add update_interval flag

* switch back to old looping/work structure

* change typing

* device count is a function

* stop early if wallet registered

* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* change import to cubit

* fix import and default

* up default
should have default in CLI call

* add comments about params

* fix config var access

* add cubit as extra

* handle stale pow differently
check registration after failure

* [feature] cpu register faster (#854)

* 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

* restrict number of processes for integration test

* fix stale check

* use wallet.is_registered instead

* attempt to fix test issue

* fix my test

* oops typo

* typo again ugh

* remove print out

* fix partly reg test

* fix if solution None

* fix test?

* fix patch

* [hotfix] fix flags for multiproc register limit (#876)

* add dot get

* add to subtensor args and defaults

* remove dot get because in subtensor args

* typo

* fix test

* add args for cuda to subtensor

* add cuda args to reregister call

* add to wallet register the cuda args

* fix refs and tests

* add for val test also

* fix tests with rereg

* Fix/diff unpack bit shift (#878)

* fix incorrect bit shift

* move inner function out and add test for diff pack

* fix test

* fix call arg check in test

* add assert

* fix test for py37

* refactor the diff pack into two functions
move the test to a unit test

* fix test

* fix patch for tests

* add mock_register to subtensor passed instead

* move register under the check for isregistered

* use patch obj instead

* fit patch object

* [Feature] [cubit] CUDA registration solver (#868)

* added cuda solver

* boost versions to fix pip error

* allow choosing device id

* fix solution check to use keccak

* adds params for cuda and dev_id to register

* list devices by name during selection

* add block number logging

* fix calculation of hashrate

* fix update interval default

* add --TPB arg to register

* add update_interval flag

* switch back to old looping/work structure

* change typing

* device count is a function

* stop early if wallet registered

* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* change import to cubit

* fix import and default

* up default
should have default in CLI call

* add comments about params

* fix config var access

* add cubit as extra

* handle stale pow differently
check registration after failure

* restrict number of processes for integration test

* fix stale check

* use wallet.is_registered instead

* attempt to fix test issue

* fix my test

* oops typo

* typo again ugh

* remove print out

* fix partly reg test

* fix if solution None

* fix test?

* fix patch

* add args for cuda to subtensor

* add cuda args to reregister call

* add to wallet register the cuda args

* fix refs and tests

* add for val test also

* fix tests with rereg

* fix patch for tests

* add mock_register to subtensor passed instead

* move register under the check for isregistered

* use patch obj instead

* fit patch object

* Fix/move overview args to cli (#867)

* move cli args to CLI and fix overview

* use dot get

* fix tests

* add hotkeys/all_hotkeys to (un)stake

* fix default

* fix default in unstake

* add unstake multiple

* add add stake multiple

* move all/hotkeys back to wallet args

* convert to balance first
add catch for unstake multi

* fix ref to wallet

* fix test patch for multi hotkeys

* try to fix tests

* fix tests patch

* fix mock wallet length

* don't use new?

* fix call args get

* typo

* fix typo

* fix prompt

* remove unneeded if

* modify POW submit to use rolling submit again

* add backoff to block get from network

* add test for backoff get block

* suppress the dev id flag if not set

* remove dest so it uses first arg

* fix pow submit loop

* move registration status with

* fix max attempts check

* remove status in subtensor.register

* add submit status

* change to neuron get instead

* fix count

* try to patch live display

* fix patch

* .

* separate test cases

* add POWNotStale and tests

* add more test cases for block get with retry

* fix return to None

* fix arg order

* fix indent

* add test to verify solution is submitted

* fix mock call

* patch hex bytes instead

* typo :/

* fix print out for unstake

* fix indexing into mock call

* call indexing

* access dict not with dot

* fix other indent

Co-authored-by: Eugene <etesting007@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature new feature added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants