SynaptraDocs

    Examples

    Example: Bittensor miner

    A miner on a Bittensor subnet, where someone else's validator scores you, rivals adapt and every run costs real money. Synaptra was built here first.

    #

    What it registers

    KindNameWhat
    actionanswerThe miner's response to a validator query.
    scorervalidator_scoreThe subnet's own scoring function, run locally on replayed queries.
    datasetreplayed-queriesQueries captured from recent validator rounds (location and fingerprint).
    runnerrunnerpython replay.py --variant {variant} --tier {tier}
    #

    How it's scored

    The metric is validator_score from the subnet's published scoring code, replayed locally (bar: the score you need to earn, which moves; update it on the card as the top miners change). Tiers go local replay → recent rounds → testnet → mainnet, and mainnet only with your OK. A miner that wins the replay but not the real validator is the classic trap: keep the subnet's own rule as the gate, not a looser statistic.

    #

    The code

    miner_harness.py
    h = Harness.create("SN-xx miner", objective="Earn emissions on subnet xx",
                       metric="validator_score", bar=0.41,
                       url="https://synaptra.my", token=TOKEN)
    
    @h.tool
    def answer(query: dict) -> dict:
        """The miner's response to one validator query."""
    
    h.register("validator_score", "scorer", "Subnet xx scoring, from its repo at commit abc123")
    h.dataset("replayed-queries", path="./replays/rounds-1200-1260.jsonl", size=3600)
    
    rows = [{"task": q["round_id"], "variant": "ensemble-v2", "tier": "T1",
             "metrics": {"validator_score": score_like_validator(miner("ensemble-v2", q), q)},
             "cost_usd": gpu_cost(q)} for q in recent_rounds]
    h.report(rows, experiment_id=EXP)
    miner_harness.ts
    const h = await Harness.create({ name: "SN-xx miner", objective: "Earn emissions on subnet xx",
                                     metric: "validator_score", bar: 0.41,
                                     url: "https://synaptra.my", token: TOKEN });
    
    await h.tool({ name: "answer", description: "The miner's response to one validator query.",
                   schema: { type: "object", properties: { query: { type: "object" } }, required: ["query"] } }, answer);
    
    await h.register({ name: "validator_score", kind: "scorer",
                       description: "Subnet xx scoring, from its repo at commit abc123" });
    // A local file on Node or Bun is fingerprinted where it lies: bytes, SHA-256 and line count
    await h.dataset("replayed-queries", { path: "./replays/rounds-1200-1260.jsonl" });
    
    const rows = recentRounds.map((q) => ({
      task: q.round_id, variant: "ensemble-v2", tier: "T1",
      metrics: { validator_score: scoreLikeValidator(miner("ensemble-v2", q), q) },
      cost_usd: gpuCost(q),
    }));
    await h.report(rows, { experimentId: EXP });
    #

    A first experiment

    Python
    e = h.propose(
        "Ensemble two models", "ensemble-v2",
        {"T0": {"pass_rate": 1}, "T1": {"mean_validator_score": 0.43, "cost_usd": 14}},
        hypothesis="Errors of the two models rarely overlap on hard rounds",
        max_cost_usd=20,
    )
    TypeScript
    const e = await h.propose({
      title: "Ensemble two models",
      variant: "ensemble-v2",
      hypothesis: "Errors of the two models rarely overlap on hard rounds",
      predictions: { T0: { pass_rate: 1 }, T1: { mean_validator_score: 0.43, cost_usd: 14 } },
      maxCostUsd: 20,
    });
    POST /api/harnesses/sn-xx-miner/experiments
    {"title": "Ensemble two models", "variant": "ensemble-v2",
     "hypothesis": "Errors of the two models rarely overlap on hard rounds",
     "max_cost_usd": 20,
     "predictions": {"T0": {"pass_rate": 1}, "T1": {"mean_validator_score": 0.43, "cost_usd": 14}}}
    #

    What this won't tell you

    • What the validator will do next: subnets change their rules. Watch the subnet's repo and re-run the replay when it changes.
    • Whether a ceiling exists: if the top score is out of reach with what you can change, more experiments won't fix it. Say so with kill.

    Something unclear or missing? Email support@synaptra.my.