Skip to content

Commit cc80067

Browse files
more mech docs touches + publish client docs (#100)
* wip * wip * wip * wip
1 parent 9004fa0 commit cc80067

File tree

6 files changed

+79
-8
lines changed

6 files changed

+79
-8
lines changed

docs/sdk/subtensor-api.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ print(sub.delegates.get_delegate_identities())
7474
sub.chain.tx_rate_limit()
7575
```
7676

77+
### Mechanism helpers (multiple incentive mechanisms)
78+
79+
Subnets can run multiple incentive mechanisms. The API adds helpers and optional `mechid` on key calls.
80+
81+
- New getters:
82+
- `get_mechanism_count(netuid)` → int
83+
- `get_mechanism_emission_split(netuid)` → list[int] or None (even split implied)
84+
- `is_in_admin_freeze_window(netuid)` → bool
85+
- Mechanism-aware methods now accept `mechid` (default `0`):
86+
- `set_weights`, `commit_weights`, `reveal_weights`, `weights`, `bonds`, `get_metagraph_info`, `get_all_metagraphs_info(all_mechanisms=False)`
87+
88+
```python
89+
import bittensor as bt
90+
91+
sub = bt.SubtensorApi()
92+
netuid = 14
93+
94+
count = sub.get_mechanism_count(netuid=netuid)
95+
split = sub.get_mechanism_emission_split(netuid=netuid)
96+
97+
# Set weights for mechanism 1
98+
ok, msg = sub.set_weights(
99+
wallet=bt.Wallet("alice"),
100+
netuid=netuid,
101+
mechid=1,
102+
uids=[0,1,2],
103+
weights=[1,1,1],
104+
)
105+
```
106+
77107
### Asynchronous
78108

79109
```python

docs/subnets/managing-mechanisms-btcli.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ title: "Managing Multiple Incentive Mechanisms with BTCLI"
66

77
This tutorial shows how to configure and manage multiple incentive mechanisms in a single subnet using BTCLI.
88

9-
For background on the concepts, see [Understanding Multiple Incentive Mechanisms](understanding-multiple-mech-subnets).
9+
For a discussion of the background concepts, see [Understanding Multiple Incentive Mechanisms](understanding-multiple-mech-subnets).
1010

1111
See also: [Managing Mechanisms with SDK](managing-mechanisms-with-sdk).
1212

13+
:::tip Hot new feature
14+
Multiple incentive mechanisms per subnet is a new feature that is still in development. It's initial release on mainnet is expected the week of September 22. In the meantime, it can be experimented with using a locally run chain.
15+
16+
See [Announcements](../learn/announcements) for updates.
17+
:::
18+
1319
**Prerequisites**
1420
- A local Subtensor chain running. See: [Run a Local Bittensor Blockchain Instance](../local-build/deploy)
1521
- A local subnet created (and emissions started). See: [Create a Subnet (Locally)](../local-build/create-subnet)
1622
- Wallets provisioned and funded for local development. See: [Provision Wallets](../local-build/provision-wallets)
1723
- BTCLI installed (development version required for mechanism commands)
1824

19-
::::tip
25+
:::tip
2026
Substitute your subnet's netuid, which you can find with `btcli subnet list`.
21-
::::
27+
:::
2228

2329
:::warning Runtime limit
2430
As of the current Subtensor runtime, a subnet can have a maximum of 2 mechanisms. Attempts to set a higher count will be rejected by the chain (runtime enforces `MaxMechanismCount = 2`).

docs/subnets/managing-mechanisms-with-sdk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ For background on the concepts, see [Understanding Multiple Incentive Mechanisms
1010

1111
See also [Managing Mechanisms with BTCLI](./managing-mechanisms-btcli).
1212

13+
:::tip Hot new feature
14+
Multiple incentive mechanisms per subnet is a new feature that is still in development. It's initial release on mainnet is expected the week of September 22. In the meantime, it can be experimented with using a locally run chain.
15+
16+
See [Announcements](../learn/announcements) for updates.
17+
:::
1318

1419
**Prerequisites**
1520
- A local Subtensor chain running. See: [Run a Local Bittensor Blockchain Instance](../local-build/deploy)

docs/subnets/metagraph.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ m = Metagraph(netuid=14, network="finney", sync=True)
7171
m = Metagraph(netuid=14, network="finney", lite=False, sync=True)
7272
```
7373

74+
### Mechanism-aware metagraphs (multiple incentive mechanisms)
75+
76+
Subnets can run multiple incentive mechanisms. The SDK supports selecting a mechanism and exposes mechanism-related fields:
77+
78+
- Metagraph accepts a `mechid` parameter (default `0`).
79+
- New fields: `mechid: int`, `mechanisms_emissions_split: list[int]`, `mechanism_count: int`.
80+
81+
```python
82+
from bittensor.core.metagraph import Metagraph
83+
84+
# Default mechanism (0)
85+
meta = Metagraph(netuid=14, network="finney", sync=True)
86+
print(meta.mechid) # 0
87+
print(meta.mechanism_count) # e.g., 2
88+
print(meta.mechanisms_emissions_split) # e.g., [60, 40]
89+
90+
# Specific mechanism (1)
91+
mech_meta = Metagraph(netuid=14, network="finney", sync=True, lite=False)
92+
mech_meta.mechid = 1
93+
await mech_meta.sync() # or re-init with mechid in helper constructors
94+
```
95+
96+
See also: [Multiple Incentive Mechanisms Within Subnets](./understanding-multiple-mech-subnets.md).
97+
7498
### Smart Contract Access (Metagraph Precompile)
7599

76100
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.

docs/subnets/understanding-multiple-mech-subnets.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
99

1010
This page explores how subnets can implement multiple incentive mechanisms to distribute emissions across different evaluation criteria.
1111

12+
:::tip Hot new feature
13+
Multiple incentive mechanisms per subnet is a new feature that is still in development. It's initial release on mainnet is expected the week of September 22. In the meantime, it can be experimented with using a locally run chain.
14+
15+
See [Announcements](../learn/announcements) for updates.
16+
:::
17+
1218
For an introduction to incentive mechanisms in general, see [Understanding Incentive Mechanisms](../learn/anatomy-of-incentive-mechanism). For the basics of subnets, miners, validators, and the blockchain, see [Components of the Bittensor platform](../learn/neurons).
1319

14-
<!-- For procedural coverage, see: -->
15-
<!-- - [Managing Mechanisms with SDK](managing-mechanisms-with-sdk) -->
16-
<!-- - [Managing Mechanisms with BTCLI](./managing-mechanisms-btcli) -->
20+
For coverage of the procedures involved, see:
21+
- [Managing Mechanisms with SDK](./managing-mechanisms-with-sdk)
22+
- [Managing Mechanisms with BTCLI](./managing-mechanisms-btcli)
1723

1824
Historically, each subnet operates with a single **incentive mechanism**, a function that validators run to assign weights to miners based on the value of their work. Subnets can now support **multiple incentive mechanisms**, allowing a subnet creator to apportion the subnet's emissions across different evaluation criteria, each running Yuma Consensus _independently_ with separate bond pools to evaluate miners' performance on distinct tasks.
1925

sidebars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ const sidebars = {
135135
"subnets/subnet-creators-btcli-guide",
136136
"subnets/subnet-hyperparameters",
137137
"subnets/working-with-subnets",
138-
// "subnets/managing-mechanisms-with-sdk",
139-
// "subnets/managing-mechanisms-btcli",
138+
"subnets/managing-mechanisms-with-sdk",
139+
"subnets/managing-mechanisms-btcli",
140140
"subnets/uid-trimming",
141141
"subnets/subnet-deregistration",
142142
"subnets/walkthrough-prompting",

0 commit comments

Comments
 (0)