inference-labs-inc/subnet-2

Verifiable inference on Bittensor

Subnet 2 (τ, β) – Proof‑of‑Inference for Bittensor

What it is – Subnet 2 is a Rust‑based implementation that adds a Proof‑of‑Inference layer to the Bittensor decentralized AI network. It lets miners run AI models that are compiled into zero‑knowledge (zk‑ML) circuits, generate predictions, and produce a succinct zk‑proof that the output really came from that model. Validators receive the data, check the proof, and score the miner on proof size, latency and other metrics. Rewards are tied to the quality of the proof rather than just the raw output.


Key Features

  • Zero‑knowledge verification – AI model predictions are turned into a cryptographic “fingerprint” (a zk‑ML circuit). Validators can confirm the prediction’s source without seeing the model itself.
  • Native Rust binaries – Separate sn2-miner and sn2-validator executables, built with Rust for performance and safety.
  • Dual transport – Communication over HTTP (via axum) and QUIC (using btlightning), giving low‑latency, peer‑to‑peer messaging.
  • Auto‑updating binaries – Released binaries poll GitHub every 5 minutes and replace themselves atomically; works with PM2 process manager.
  • Docker‑first deployment – Official Docker image (ghcr.io/inference-labs-inc/subnet-2) with ready‑made compose files and a Watchtower side‑car for automatic image updates.
  • Reward mechanism – Scores miners on proof size, generation time and cryptographic integrity, encouraging efficient zk‑ML circuit design.
  • Integration with Bittensor – Uses btcli for wallet handling, Substrate RPC via subxt, and follows the Opentensor subnet standards.

Quick‑Start Guide

Prerequisites

Tool Why needed
Rust (rustup) Build from source if you don’t use the pre‑built binary
PM2 Process manager for running the binaries continuously
btcli Bittensor CLI for wallet creation and subnet registration
Docker (optional) Run miner/validator without installing Rust

Install a binary (one‑liner)

curl -fsSL https://raw.githubusercontent.com/inference-labs-inc/subnet-2/main/install.sh | bash

Add sn2-miner or sn2-validator after the script to install only that component.

Register on the network

btcli subnet register \
  --subtensor.network finney \
  --netuid 2 \
  --wallet.name YOUR_COLDKEY \
  --wallet.hotkey YOUR_HOTKEY

Run a miner (Docker compose – recommended)

services:
  subnet-2-miner:
    image: ghcr.io/inference-labs-inc/subnet-2:latest
    restart: unless-stopped
    ports: ["8091:8091"]
    volumes:
      - /path/to/.bittensor:/home/subnet2/.bittensor
    environment:
      - PUID=1000
      - HOME=/home/subnet2
    command: >
      sn2-miner \
      --wallet-name YOUR_MINER_KEY \
      --wallet-hotkey YOUR_MINER_HOTKEY \
      --netuid 2

Add a Watchtower container (shown in the README) to auto‑update the image.

Run a validator (Docker compose)

services:
  subnet-2-validator:
    image: ghcr.io/inference-labs-inc/subnet-2:latest
    restart: unless-stopped
    ports: ["8443:8443", "9090:9090"]
    volumes:
      - /path/to/.bittensor:/home/subnet2/.bittensor
    environment:
      - PUID=1000
      - HOME=/home/subnet2
    command: >
      sn2-validator \
      --wallet-name YOUR_VALIDATOR_KEY \
      --wallet-hotkey YOUR_VALIDATOR_HOTKEY \
      --netuid 2

You can also run the binaries directly with PM2 or via make pm2‑miner / make pm2‑validator as described in the README.


Architecture Overview

The repository is a Rust workspace with several crates:

Crate Role
sn2-types Shared constants, data structures, and protocol definitions used by both miner and validator
sn2-chain Handles wallet interaction, metagraph queries, subnet registration, weight updates and the auto‑update logic
sn2-verify Implements zk‑proof verification using the Expander backend (a separate repo)
sn2-validator The validator binary – receives inputs, issues challenges, checks zk‑proofs, and scores miners
sn2-miner The miner binary – fetches challenges, runs a locally stored zk‑ML model, returns prediction + proof

Communication layers:

  • HTTP via axum for simple REST‑style requests.
  • QUIC via btlightning for faster, connection‑less messaging.
  • Substrate RPC via subxt for on‑chain operations (weights, rewards, registration).

Hardware Recommendations

Miner (minimum)

  • CPU: 8 cores @ 3.2 GHz
  • RAM: 32 GB
  • Network: 400 Mbps up/down
  • Storage: 1 TB NVMe SSD

Miner (recommended)

  • CPU: 8 cores @ 3.6 GHz+
  • RAM: 64 GB+
  • Network: 1 Gbps up/down
  • Storage: 2 TB NVMe SSD

Validator (minimum)

  • CPU: 8 cores @ 3.2 GHz
  • RAM: 16 GB
  • Network: 400 Mbps up/down
  • Storage: 1 TB SSD

Validator (recommended)

  • CPU: 8 cores @ 3.4 GHz+
  • RAM: 32 GB
  • Network: 1 Gbps+
  • Storage: 2 TB SSD

Higher specs generally translate to better proof‑generation speed and thus higher rewards.


Where to Learn More


Subnet 2 has been rebranded to Dani Labs (https://danilabs.ai/), but the code and deployment instructions remain valid for the current Bittensor subnet.

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Dispatch