Subnet Metagraph
This page documents the Bittensor subnet metagraph.
The metagraph is a core data structure in Bittensor that represents the complete state of a subnet at any given block. It contains comprehensive information about all neurons (miners and validators) participating in a subnet, their emissions, bonds, and trust, as well as subnet metrics.
The metagraph is implemented in the Bittensor blockchain (Subtensor) as a Rust data structure. The source code is located in the Subtensor repository.
Related reading:
Accessing the Metagraph
You can access metagraph data through multiple interfaces:
Bittensor CLI (btcli)
The btcli
command-line interface provides access to a subset of metagraph information (corresponding to "lite" mode in the SDK). For full metagraph data including weights and bonds, use the Python SDK with lite=False
.
# Dump metagraph subset to file (lite mode)
btcli subnets metagraph --netuid 14 --network finney \
--json-output > sn14_metagraph.json
# View abridged metagraph
btcli subnets metagraph --netuid 14 --network finney
Subnet 14: TAOHash
Network: finney
UID ┃ Stake (ξ) ┃ Alpha (ξ) ┃ Tao (τ) ┃ Dividends ┃ Incentive ┃ Emissions (ξ) ┃ Hotk… ┃ Coldkey ┃ Identity
━━━━━╇ ━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━
29 │ 271.67k ξ │ 254.83k ξ │ τ 16.84k │ 0.129183 │ 0.000000 │ 19.122456 ξ │ 5Cf4… │ 5CKhH8 │ Owner14 (*Owner)
3 │ 387.08k ξ │ 61.46k ξ │ τ 325.62k │ 0.184314 │ 0.000000 │ 27.280861 ξ │ 5C59… │ 5GZSAg │
...
The btcli output shows a subset of metagraph data (lite mode). For complete data including ranks, trust scores, weights, and bonds, use the Python SDK with lite=False
.
Python SDK
The Bittensor Python SDK Metagraph module provides programmatic access to metagraph data:
from bittensor.core.metagraph import Metagraph
# Initialize metagraph for subnet 14 (lite mode - excludes weights/bonds)
m = Metagraph(netuid=14, network="finney", sync=True)
# Initialize metagraph with full data including weights and bonds
m = Metagraph(netuid=14, network="finney", lite=False, sync=True)
Smart Contract Access (Metagraph Precompile)
For smart contract integration, you can access metagraph data through the Metagraph Precompile at address 0x0000000000000000000000000000000000000802
. This provides read-only access to individual neuron metrics and network information.
For detailed smart contract examples and complete ABI, see the Metagraph Precompile documentation.
RPC Functions
The blockchain provides several RPC functions for accessing metagraph data:
get_metagraph(netuid)
- Returns complete metagraph for a subnetget_all_metagraphs()
- Returns metagraphs for all subnetsget_selective_metagraph(netuid, indexes)
- Returns partial metagraph data
See Subtensor:Metagraph RPC source code
Performance Considerations
Lite vs Full Sync
- Lite Mode (
lite=True
): Faster sync, excludes weights and bonds (corresponds to btcli output) - Full Mode (
lite=False
): Complete data including weight matrices and bond matrices
Caching
The metagraph supports local caching to persistent files:
# Save metagraph for later use
metagraph.save()
# Load cached metagraph
metagraph.load()
# Custom save directory
metagraph.save(root_dir=['/custom', 'path'])
Metagraph files are saved to ~/.bittensor/metagraphs/network-{network}/netuid-{netuid}/block-{block_number}.pt
by default. The files are persistent and not temporary.
Data Structures
Metagraph Object
In the Bittensor Python SDK, the Metagraph
class encapsulates the following information about a particular subnet.
Metagraph class specification, SDK reference
Metagraph Properties
Name | Description |
---|---|
netuid | The subnet's unique identifier within the Bittensor network |
network | Name of the Bittensor network, i.e. mainnet ('finney'), test, or a locally deployed chain |
version | Bittensor version number |
n | Total number of neurons registered on the subnet |
block | Block number when the metagraph record was retrieved |
total_stake | Total stake weight (α + τ × 0.18) across all neurons |
Stake / S | Total stake weight (α + τ × 0.18) of each neuron, determining consensus power and emissions |
Alpha Stake / AS | Alpha token stake (α) for each neuron |
Tao Stake / TS | TAO token stake (τ) for each neuron |
Ranks / R | Final performance scores after consensus weight clipping - stake-weighted sum of clipped weights that directly determine emissions to miners |
Trust / T | Consensus alignment ratio (final rank / pre-rank) - measures how much consensus clipping affected the rank, where 1.0 indicates perfect consensus alignment |
Validator Trust / Tv | Validator trust - sum of clipped weights set by each validator, measuring validator influence in consensus |
Consensus / C | Consensus score - stake-weighted median of weights per neuron, serving as consensus threshold for weight clipping |
Incentive / I | Normalized ranks representing incentive allocation for miners based on performance |
Emission / E | Token emission amounts in RAO (10^-9 TAO) per block |
Dividends / D | Bond-based rewards for validators from their investments in miners |
Bonds / B | Inter-neuronal bond matrix representing validator investments in miners, used to calculate validator emissions |
Weights / W | Weight matrix (validator → miner assignments) formed from validator weight vectors, input for Yuma Consensus |
uids | Unique UID identifiers for each neuron |
hotkeys | Neuron hotkey addresses |
coldkeys | Neuron coldkey addresses |
addresses | Network IP addresses |
axons | Network connection details for axon servers |
neurons | Complete neuron objects with all metadata |
active | Neuron activity status within the activity_cutoff window |
last_update | Last update block numbers for staleness detection |
validator_permit | Boolean array indicating whether each neuron has validator permits to set weights and participate in consensus |
name | Subnet name |
symbol | Subnet token symbol |
network_registered_at | Registration block when subnet was created |
num_uids | Current number of neurons |
max_uids | Maximum allowed neurons (typically 256) |
identities | List of chain identities |
identity | Subnet identity information |
pruning_score | List of pruning scores based on emissions, used for deregistration when subnet is full |
block_at_registration | List of registration blocks for each neuron, used for immunity period calculations |
tao_dividends_per_hotkey | TAO dividends by hotkey |
alpha_dividends_per_hotkey | Alpha dividends by hotkey |
last_step | Last step block number |
tempo | Tempo - block interval for updates (360 blocks = 72 minutes) |
blocks_since_last_step | Blocks since last step |
owner_coldkey | Subnet owner coldkey |
owner_hotkey | Subnet owner hotkey |
hparams | Subnet hyperparameters (MetagraphInfoParams ) |
pool | Liquidity pool information (MetagraphInfoPool ) |
emissions | Emission configuration (MetagraphInfoEmissions ) |