Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ MedCode Intelligence Network (MCIN)

Bittensor Subnet β€” Decentralized Medical Coding Inference

CI Python 3.10+ Bittensor License: MIT


What is MCIN?

MCIN is a Bittensor subnet that decentralizes the inference workload of the HP UMACSβ„’ medical coding AI system. Instead of running inference on a fixed fleet of owned GPU servers, the subnet creates an open market where miners compete to serve the best, fastest, and most reliable medical coding predictions β€” and earn TAO for doing so.

Doctor's Note (de-identified)
        β”‚
        β–Ό
  Validator samples task
  from private benchmark
        β”‚
        β–Ό (broadcast)
  β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”
  β”‚ πŸ–₯  β”‚ πŸ–₯  β”‚ πŸ–₯  β”‚   ← Miners (H200 GPU servers)
  β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
  Validator scores:
  quality Γ— capacity Γ— reliability
        β”‚
        β–Ό
  Yuma Consensus β†’ TAO emissions

Incentive Mechanism

Core principle: Emissions follow verified useful inference β€” not machine count.

Two-Mechanism Emission Split

Mechanism Weight Measures
Mechanism 0: Quality Γ— Capacity 75% Coding accuracy Γ— verified concurrent throughput
Mechanism 1: Service Reliability 25% Latency, uptime, format validity

Capacity-Weighted Scoring

More H200 servers = more emissions β€” but only if quality stays high under load.

The validator measures each miner's Verified Concurrent Capacity (VCC): the highest number of simultaneous requests the miner can correctly handle without degrading quality or latency.

# Capacity multiplier (logarithmic β€” every GPU doubling = fixed bonus)
capacity_multiplier = 1.0 + log2(VCC / 1) * 0.5

# Example VCC β†’ multiplier mapping:
# VCC =   1  (1 GPU   β€” baseline)     β†’  Γ—1.00
# VCC =   2  (2 GPUs)                 β†’  Γ—1.50
# VCC =   4  (4 GPUs)                 β†’  Γ—2.00
# VCC =   8  (1Γ— 8-GPU server)        β†’  Γ—2.50
# VCC =  16  (2Γ— 8-GPU servers)       β†’  Γ—3.00
# VCC =  32  (4Γ— 8-GPU servers)       β†’  Γ—3.50
# VCC =  64  (8Γ— 8-GPU servers)       β†’  Γ—4.00
#   ...unlimited scaling...

# Quality gate (cubic collapse below 85% quality under burst):
quality_gate = 1.0 if avg_quality >= 0.85 else (avg_quality / 0.85) ** 3

# Final epoch score:
score = quality_score Γ— capacity_multiplier Γ— quality_gate Γ— reliability_factor

Key property: A miner with 4 servers delivering 95% accuracy beats one with 30 servers at 88% accuracy. Scaling without quality never wins.

Quality Score Formula

quality_score = 0.50 Γ— code_F1
              + 0.20 Γ— modifier_F1
              + 0.15 Γ— hierarchy_score     (partial credit for parent codes)
              + 0.10 Γ— consistency_score   (same note, different phrasing)
              βˆ’ 0.05 Γ— hallucination_penalty

Repository Structure

mcin-subnet/
β”œβ”€β”€ template/
β”‚   β”œβ”€β”€ protocol.py      # MCINRequest / MCINResponse synapse schemas
β”‚   β”œβ”€β”€ scoring.py       # Full incentive mechanism + capacity scoring
β”‚   └── benchmark.py     # Gold label set management + task sampling
β”œβ”€β”€ neurons/
β”‚   β”œβ”€β”€ miner.py         # Miner neuron (inference server)
β”‚   └── validator.py     # Validator neuron (scoring + weight setting)
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_scoring.py  # Incentive mechanism unit tests
β”‚   └── test_protocol.py # Schema validation tests
β”œβ”€β”€ scripts/
β”‚   └── run_local.sh     # One-command local development setup
β”œβ”€β”€ benchmark/
β”‚   └── sample/          # Sample benchmark cases for local testing
β”œβ”€β”€ .github/workflows/
β”‚   └── ci.yml           # GitHub Actions CI
└── pyproject.toml

Quick Start

1. Install

git clone https://github.com/your-org/mcin-subnet
cd mcin-subnet
pip install -e ".[dev]"

2. Run tests

pytest tests/ -v

3. Local development (one command)

chmod +x scripts/run_local.sh
./scripts/run_local.sh

This will:

  • Start a local Subtensor node
  • Create and fund test wallets
  • Register and launch a mock miner + validator

4. Run a miner manually

python neurons/miner.py \
  --netuid <NETUID> \
  --subtensor.network finney \
  --wallet.name miner \
  --wallet.hotkey default \
  --inference_endpoint http://YOUR_UMACS_ENDPOINT/predict \
  --api_key YOUR_API_KEY

5. Run a validator manually

python neurons/validator.py \
  --netuid <NETUID> \
  --subtensor.network finney \
  --wallet.name validator \
  --wallet.hotkey default \
  --benchmark_dir ./benchmark

Becoming a Miner

What you need

Requirement Details
GPU hardware Any NVIDIA H100/H200 GPU (even 1 GPU is a valid baseline miner)
Access HP UMACS API key (contact Med.Report)
Wallet Registered coldkey + hotkey on MCIN subnet
Stake β‰₯ 1 TAO on validator to avoid blacklisting

How capacity rewards work

Each epoch, validators run burst probes β€” sending 1, 2, 4, 8, 16... simultaneous requests to find your VCC. The highest N where you maintain:

  • β‰₯ 90% of your baseline quality
  • p95 latency ≀ 1.5Γ— your baseline latency
  • β‰₯ 97% success rate

...is your VCC. More properly-loaded H200 servers β†’ higher VCC β†’ higher capacity multiplier β†’ more TAO.

Tips for maximizing emissions

  • Use FP8 quantization and CUDA graphs for maximum H200 throughput
  • Pre-warm the model on startup (avoids cold-start latency)
  • Use async batching to serve concurrent validator requests efficiently
  • Don't fake availability β€” burst tests reveal real capacity

Validator Guide

Validators are the backbone of the subnet. To run a validator:

  1. Prepare a benchmark dataset in ./benchmark/ with gold.jsonl, online.jsonl, and adversarial.jsonl files.
  2. Keep your benchmark private. Never publish your gold set.
  3. Rotate monthly β€” BenchmarkManager handles rotation automatically.

See template/benchmark.py for the full benchmark format spec.


Protocol

All miners implement the MCINRequest / MCINResponse synapse pair:

# Request (validator β†’ miner)
MCINRequest(
    job_id        = "uuid",
    note_text     = "De-identified clinical note...",
    specialty     = "Cardiology",
    code_families = ["ICD10CM", "HCPCS"],
    deadline_ms   = 3000,
)

# Response (miner β†’ validator)
MCINResponse(
    job_id    = "uuid",
    codes     = [
        {"code": "I21.0", "system": "ICD10CM", "confidence": 0.97, "rationale": "acute MI mentioned"},
    ],
    modifiers      = ["acute", "STEMI"],
    latency_ms     = 312.5,
    model_hash     = "a3f7...",
    schema_version = "1.0",
)

Anti-Gaming Rules

Rule Implementation
Hidden test sets 30% of scored jobs come from private gold set
Challenge-response No batch downloads; all evaluation is live
Duplicate detection Identical outputs across miners β†’ collusion flag β†’ score = 0
Sybil protection Throughput bonus saturates; node count never directly rewarded
Burst validation Capacity only counted when quality + latency hold under concurrent load

Creating the Subnet On-Chain

Check burn cost

btcli subnet burn_cost --subtensor.network finney

Create subnet

btcli subnet create --wallet.name owner --subtensor.network finney

Activate emissions

btcli subnet start --netuid <NETUID> --wallet.name owner --subtensor.network finney

⚠️ Important Notices

HIPAA / PHI: All clinical note text entering the subnet must be fully de-identified before transmission. No real Protected Health Information (PHI) may enter miner traffic under any circumstances. Consult your legal team before deployment.

IP Protection: The HP UMACS model is owner-operated. Miners call the inference API endpoint β€” they do not receive model weights. Obfuscation alone is not a durable IP control; the API boundary is the primary protection.

Not for clinical use: Outputs from this subnet are for billing and coding assistance only. They must not be used for medical diagnosis, treatment decisions, or any other clinical purpose.


License

MIT License β€” see LICENSE.

Built on Bittensor by Med.Report / IFORELS Inc.

About

Bittensor Subnet

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages