Bittensor
Search…
⛏
Running a Miner
You can mine Tao in these 2 ways. (1) Serve your deep learning model to your peers, gain Tao by generating useful information for them. (2) Send requests to your peers, evaluate their information, and gain Tao by buying bonds for those high-performing peers. Sound difficult? No worries, we have got your back and implemented everything with a template for you.

Quick Start

Starting the default miner is just one line of code. In the terminal, run
1
btcli run
Copied!
Follow the guild from the command line. Press enter to choose the default in the bracket or type your choice and press enter.

1. Choose a network to run your miner on.

1
Enter subtensor network [local/nobunaga/akatsuki/nakamoto] (nakamoto):
Copied!
  • nakamoto: the main network to earn Tao
  • akatsuki: the staging network
  • nobunaga: the testing network

2. Choose which coldkey wallet to anchor to.

1
Enter wallet name (default):
Copied!
If you want to create a new coldkey wallet, input a new wallet name, else input an old wallet name.
To check the list of wallets that you have already created, run btcli list from the terminal.
To understand what is a coldkey, go to wallet structure.

3. Choose which hotkey to anchor to (same as above).

4. Choose a type of miner to run with.

1
Enter miner name [template_miner/template_validator/template_server/advanced_server] (template_miner):
Copied!
There are mainly 3 types of miner.
  • template server / advanced server: These 2 options help you serve a hugging-face pre-trained model, which would be gpt2 by default. It earns Tao by providing useful knowledge to the system.
  • template validator: It validates the performance of the peers. It earns Tao by buying bonds on the high-performing peers.
  • template miner: It does (1) serve its own model and (2) validate the peer.
To configure your miners, refer to customizing your miners.
To understand the difference between server and validator, refer to how to miner Tao.

Alternative Start

Alternatively, with the use of flags, you can also start the miner just with the following command.
1
btcli run \
2
--subtensor.network <the network or your choice> \
3
--wallet.name <your coldkey wallet> \
4
--wallet.hotkey <your hotkey wallet> \
5
6
# OR for template miner,
7
python ~/.bittensor/bittensor/bittensor/_neuron/text/template_miner/main.py \
8
--subtensor.network <the network or your choice> \
9
--wallet.name <your coldkey wallet> \
10
--wallet.hotkey <your hotkey wallet> \
11
12
# OR for server,
13
python ~/.bittensor/bittensor/bittensor/_neuron/text/advanced_server/main.py \
14
--subtensor.network <the network or your choice> \
15
--wallet.name <your coldkey wallet> \
16
--wallet.hotkey <your hotkey wallet> \
17
18
# OR for validator,
19
python ~/.bittensor/bittensor/bittensor/_neuron/text/template_validator/main.py \
20
--subtensor.network <the network or your choice> \
21
--wallet.name <your coldkey wallet> \
22
--wallet.hotkey <your hotkey wallet> \
Copied!

What just happened?

Each miner is a unique machine learning model running on a unique dataset. It serves its trained model from your endpoint. This code will perform the following steps:

1. Display its configuration:

Each miner is fully configurable, the finalized configuration to run the model would be displayed.
1
axon:
2
backward_timeout: 20
3
forward_timeout: 10
4
ip: '[::]'
5
max_workers: 10
6
maximum_concurrent_rpcs: 400
7
port: 8091
8
priority:
9
max_workers: 10
10
maxsize: -1
11
config: null
12
dataset:
13
batch_size: 10
14
block_size: 20
15
data_dir: ~/.bittensor/data/
16
dataset_name: train
17
max_corpus_size: 10000.0
18
num_workers: 0
19
save_dataset: false
20
dendrite:
21
max_active_receptors: 500
22
max_worker_threads: 150
23
requires_grad: true
24
timeout: 12
25
logging:
26
debug: false
27
logging_dir: ~/.bittensor/miners
28
record_log: false
29
trace: false
30
neuron:
31
accumulate_remote_gradients: false
32
batch_size_train: 2
33
blacklist: 0
34
blacklist_allow_non_registered: true
35
clip_gradients: 1.0
36
compute_remote_gradients: false
37
device: cpu
38
epoch_length: 100
39
learning_rate: 1
40
learning_rate_chain: 1
41
momentum: 0.8
42
n_epochs: 9223372036854775807
43
n_topk_peer_weights: 100
44
name: template_neuron
45
restart: false
46
restart_on_failure: true
47
sync_block_time: 100
48
timeout: 10
49
use_upnpc: false
50
use_wandb: false
51
weight_decay: 0.25
52
nucleus:
53
dropout: 0.2
54
nhead: 2
55
nhid: 200
56
nlayers: 2
57
punishment: 0.001
58
topk: 20
59
subtensor:
60
chain_endpoint: null
61
network: nakamoto
62
wallet:
63
hotkey: default
64
name: default
65
path: ~/.bittensor/wallets/
66
wandb:
67
api_key: default
68
directory: default
69
name: default
70
offline: false
71
project: default
72
run_group: default
73
tags: default
Copied!

2. Register and Serve

If it is the first time for you to use your new hotkey, you will see the following log, meaning that we are registering your new hotkey to the chain. This process may take some time, depending on your computational power and also the current number of users trying to make a new registration.
1
πŸ“‘Registering...(0/10)
Copied!
You will see the following logs when your miner has subscribed to the network. The miner subscribes to the chain to tell others which endpoint it is on and what type of data it mines, specified by modality( modality: 0 refers to text)
1
βœ… Already Registered:
2
uid: ===
3
hotkey: ================================================
4
coldkey: =================================================
5
βœ… Found external ip: ==.==.==.==
6
βœ… Already Served
7
ip: ==.==.==.==
8
port: ====
9
modality: 0
10
hotkey: ===============================================
11
coldkey: ================================================
12
​
Copied!

3. Dataset

If you have turned on the debug log, you would see the following dataset logs.
Once subscribed, your miner will start to prepare its own dataset. Text data is pulled from our IPFS cluster and used to create a custom training dataset for your miner.
1
| SUCCESS | Loaded folder: QmRjFNn3XpYMycVzTE4YcVcxk45vNZcTAjKmtEqPLKwAWd
2
| SUCCESS | Downloaded: Wikitext_Ferugliotherium.txt
3
| SUCCESS | Saved: Wikitext_Ferugliotherium.txt
Copied!
For full details regarding our IPFS dataset, please refer to the dataset page.

4. Mine

Here is a sample log for an epoch of template_mining.
1
Iters Elapsed Time Speed Step Epoch Best-loss L-loss R-loss D-loss L-acc nPeers Stake(Ο„) Rank(Ο„) Incentive(Ο„/block) Current Block Synced Block uid_386 uid_604 uid_568 uid_611
2
33/100 00:06:54<00:14:01 0.08it/s 32 1 8.2356 13.9926 10.6439 85.4158 0.0000 782 3.508 0.000 0.000001 48650 48616 0.0028 0.0024 0.0023 0.0022
3
Copied!
  • Step: The global step. How many times we have done a forward pass and backward operation.
  • Epoch: The epoch.
  • Best-loss: The beast local loss.
  • L-loss: The current local loss.
  • R-loss: Loss from the remote module where we aggregate results from peers.
  • D-loss: The distillation loss, which indicates how good are we in mimicking the remote module.
  • L-acc: The local accuracy.
  • nPeers: The current number of peers in the chain.
  • Stake: The stake (Tao) that you own now.
  • Rank: How much weight * stake was given to you by the network.
  • Incentive: Adjusted Rank, with the number of connections you have in the network considered.
  • Current Block: The current block of the chain.
  • Synced Block: When did you last sync with the network.
  • uid_***: The weight that you have set to your peers.
To know more about how does the calculation of Tao works, refer to how to miner Tao.
During the training, the miner will query others in the network with its training. Other nodes in the network will respond depending on if you have subscribed to the network and if you have enough stake (tao) in your wallet for them to talk to you. You will see the following messages if other miners respond to you and if you have turned your debug logging on.
1
| Success | Dendrite | Forward | ---> | [10, 20] | 5F7NNouEPnEN6vUjxCmNxhuKCY5y7a7GGBfLdEy5fRP1NFq3 | None
2
| Success | Dendrite | Forward | <--- | [10, 20, 512] | 5F7NNouEPnEN6vUjxCmNxhuKCY5y7a7GGBfLdEy5fRP1NFq3 | None
Copied!
Finally, after a certain period of time, your miner will try to sync itself with the chain. There are multiple reasons to do this, but importantly, this will allow you to update your weights on the chain and purchase bonds on others in the network. The sync with the chain will also reveal new nodes that joined the chain recently and inform the chain your miner is still active.
1
| SUCCESS | Setting weights: [(0, 0.0), (1, 0.0), (2, 0.0)]
Copied!
​
Last modified 19d ago