Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5cd3b70
Scaffold 🏗️
HudsonGraeme Aug 2, 2025
fdd67ea
Clean 🧹
HudsonGraeme Aug 2, 2025
76c0a0d
Add docker to preflight for miners
HudsonGraeme Aug 2, 2025
3af2e9b
Add DCAP models
HudsonGraeme Aug 7, 2025
75570da
Add install for teeonnx
HudsonGraeme Aug 8, 2025
d763d81
Refactor, add teeonnx to preflight
HudsonGraeme Aug 8, 2025
b00d0e6
Update doc
HudsonGraeme Aug 8, 2025
3435317
+1
HudsonGraeme Aug 8, 2025
6deccd0
Pin version
HudsonGraeme Aug 8, 2025
e61e2bf
Add model prefix
HudsonGraeme Aug 8, 2025
c16257d
Update prove, verify
HudsonGraeme Aug 8, 2025
83535ae
HudsonGraeme Aug 8, 2025
42b0e70
json -> bin
HudsonGraeme Aug 8, 2025
d6aee1a
Load toml config
HudsonGraeme Aug 8, 2025
16629c2
Update path
HudsonGraeme Aug 8, 2025
4c677e1
Context manager
HudsonGraeme Aug 8, 2025
a875d73
rm shell, update chmod
HudsonGraeme Aug 8, 2025
bb1b9ca
use 755 for exec
HudsonGraeme Aug 8, 2025
977eb09
witness -> quote
HudsonGraeme Aug 8, 2025
8e4734b
Add error trap
HudsonGraeme Aug 8, 2025
8df09f0
Add error traps
HudsonGraeme Aug 8, 2025
49a208c
Add another error trap
HudsonGraeme Aug 8, 2025
d1d4a01
Update post init
HudsonGraeme Aug 8, 2025
0f6f38f
Improve session storage handling
HudsonGraeme Aug 8, 2025
718d625
Improve hash
HudsonGraeme Aug 8, 2025
8652f05
Improve docker check
HudsonGraeme Aug 8, 2025
1854812
--verify -> verify
HudsonGraeme Aug 8, 2025
498ff39
Update comment
HudsonGraeme Aug 8, 2025
52c78b8
Break if miner
HudsonGraeme Aug 18, 2025
56401a1
Merge branch 'testnet' of inference.github.com:inference-labs-inc/omr…
HudsonGraeme Aug 18, 2025
d4d0a55
Improve preflight
HudsonGraeme Aug 18, 2025
a4c88c1
Adjust tag position
HudsonGraeme Aug 18, 2025
2eb9b3c
Temp disable network weight
HudsonGraeme Aug 18, 2025
a5470f4
Use CircuitMetadata
HudsonGraeme Aug 18, 2025
e814573
Refactor
HudsonGraeme Aug 18, 2025
852c571
Refactor
HudsonGraeme Aug 18, 2025
118d079
Rename imports
HudsonGraeme Aug 18, 2025
2f7b954
Update perms, mv model to tmp
HudsonGraeme Aug 18, 2025
6394d6e
Tweak param
HudsonGraeme Aug 18, 2025
008f560
Simplify metadata load in preflight
HudsonGraeme Aug 18, 2025
1b64289
Adjust key
HudsonGraeme Aug 18, 2025
3533507
typo
HudsonGraeme Aug 18, 2025
0d51517
Add sudo :/
HudsonGraeme Aug 18, 2025
43fb377
Adjust format
HudsonGraeme Aug 18, 2025
ef953c7
Add exec
HudsonGraeme Aug 18, 2025
94ce9f4
Several small improvements
HudsonGraeme Aug 19, 2025
b8310f3
Improve conditional and log
HudsonGraeme Aug 19, 2025
a8f48a0
750 -> 700
HudsonGraeme Aug 19, 2025
24296db
Improve cmd
HudsonGraeme Aug 19, 2025
06d9421
300s -> 1h
HudsonGraeme Aug 19, 2025
0d422d3
Merge branch 'testnet' of inference.github.com:inference-labs-inc/omr…
HudsonGraeme Aug 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,4 @@ competition_circuit/**

# intellij files
.idea/
**.onnx
17 changes: 17 additions & 0 deletions neurons/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ class Roles:
)
# EZKL path
LOCAL_EZKL_PATH = os.path.join(os.path.expanduser("~"), ".ezkl", "ezkl")
# TEEONNX path
LOCAL_TEEONNX_PATH = os.path.join(os.path.expanduser("~"), ".teeonnx", "teeonnx")
# SNARKJS paths
LOCAL_SNARKJS_INSTALL_DIR = os.path.join(os.path.expanduser("~"), ".snarkjs")
LOCAL_SNARKJS_PATH = os.path.join(
LOCAL_SNARKJS_INSTALL_DIR, "node_modules", ".bin", "snarkjs"
)
# External files required by miners and validators
MINER_EXTERNAL_FILES = [
"circuit.zkey",
"pk.key",
"network.onnx",
]
VALIDATOR_EXTERNAL_FILES = [
"circuit.zkey",
"network.onnx",
]
# GitHub repository URL
REPO_URL = "https://github.com/inference-labs-inc/omron-subnet"
# Various time constants in seconds
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import annotations
from pydantic import BaseModel
from execution_layer.base_input import BaseInput
from execution_layer.input_registry import InputRegistry
from _validator.models.request_type import RequestType
import numpy as np

BATCH_SIZE = 1
SEQUENCE_LENGTH = 64


class CircuitInputSchema(BaseModel):
input_ids: list[list[int]]
shapes: list[list[int]]
variables: list[list[object]]


@InputRegistry.register(
"815d49886a610c17e34204b1c544c363bb06328a6cb126181bd0b6e77164cd4b"
)
class CircuitInput(BaseInput):

schema = CircuitInputSchema

def __init__(
self, request_type: RequestType, data: dict[str, object] | None = None
):
super().__init__(request_type, data)

@staticmethod
def generate() -> dict[str, object]:
input_ids = np.random.randint(
0, 256, size=(BATCH_SIZE, SEQUENCE_LENGTH)
).tolist()
return {
"input_ids": input_ids,
"shapes": [[BATCH_SIZE, SEQUENCE_LENGTH]],
"variables": [["batch_size", BATCH_SIZE], ["sequence", SEQUENCE_LENGTH]],
}

@staticmethod
def validate(data: dict[str, object]) -> None:
return CircuitInputSchema(**data)

@staticmethod
def process(data: dict[str, object]) -> dict[str, object]:
return data
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "Dishonest Advisor"
description = "A dishonest advisor which provides generic cryptocurrency advise (NFA)"
author = "Inference Labs"
version = "0.0.1"
proof_system = "DCAP"
type = "proof_of_computation"
benchmark_choice_weight = 0.2
network_weight = 0.1

[external_files]
network.onnx = "https://storage.omron.ai/815d49886a610c17e34204b1c544c363bb06328a6cb126181bd0b6e77164cd4b/network.onnx"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import annotations
from pydantic import BaseModel
from execution_layer.base_input import BaseInput
from execution_layer.input_registry import InputRegistry
from _validator.models.request_type import RequestType
import numpy as np

BATCH_SIZE = 1
SEQUENCE_LENGTH = 64


class CircuitInputSchema(BaseModel):
input_ids: list[list[int]]
shapes: list[list[int]]
variables: list[list[object]]


@InputRegistry.register(
"c2493244e153e8dcb2bfa6e0ebb411b76069074041d95718c47a36f4ec637237"
)
class CircuitInput(BaseInput):

schema = CircuitInputSchema

def __init__(
self, request_type: RequestType, data: dict[str, object] | None = None
):
super().__init__(request_type, data)

@staticmethod
def generate() -> dict[str, object]:
input_ids = np.random.randint(
0, 256, size=(BATCH_SIZE, SEQUENCE_LENGTH)
).tolist()
return {
"input_ids": input_ids,
"shapes": [[BATCH_SIZE, SEQUENCE_LENGTH]],
"variables": [["batch_size", BATCH_SIZE], ["sequence", SEQUENCE_LENGTH]],
}

@staticmethod
def validate(data: dict[str, object]) -> None:
return CircuitInputSchema(**data)

@staticmethod
def process(data: dict[str, object]) -> dict[str, object]:
return data
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "Honest Advisor"
description = "An honest advisor which provides generic cryptocurrency advise (NFA)"
author = "Inference Labs"
version = "0.0.1"
proof_system = "DCAP"
type = "proof_of_computation"
benchmark_choice_weight = 0.2
network_weight = 0.1

[external_files]
network.onnx = "https://storage.omron.ai/c2493244e153e8dcb2bfa6e0ebb411b76069074041d95718c47a36f4ec637237/network.onnx"
31 changes: 22 additions & 9 deletions neurons/execution_layer/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from utils import with_rate_limit
import time
import re
import toml

# trunk-ignore(pylint/E0611)
from bittensor import logging, subtensor, Wallet
Expand All @@ -38,11 +39,11 @@ class ProofSystem(str, Enum):
Enum representing supported proof systems.
"""

# ZK Proof Systems
# Supported provers
ZKML = "ZKML"
CIRCOM = "CIRCOM"
JOLT = "JOLT"
EZKL = "EZKL"
DCAP = "DCAP"

def __str__(self):
return self.value
Expand Down Expand Up @@ -101,7 +102,10 @@ def __post_init__(self):
f"model_{self.model_id}",
)
self.input = os.path.join(self.base_path, "input.json")
self.metadata = os.path.join(self.base_path, "metadata.json")
if os.path.exists(os.path.join(self.base_path, "metadata.toml")):
self.metadata = os.path.join(self.base_path, "metadata.toml")
else:
self.metadata = os.path.join(self.base_path, "metadata.json")
self.compiled_model = os.path.join(self.base_path, "model.compiled")
self.settings = os.path.join(self.base_path, "settings.json")
self.witness = os.path.join(self.base_path, "witness.json")
Expand All @@ -121,14 +125,12 @@ def set_proof_system_paths(self, proof_system: ProofSystem):
self.pk = os.path.join(self.external_base_path, "circuit.zkey")
self.vk = os.path.join(self.base_path, "verification_key.json")
self.compiled_model = os.path.join(self.base_path, "circuit.wasm")
elif proof_system == ProofSystem.JOLT:
self.compiled_model = os.path.join(
self.base_path, "target", "release", "circuit"
)
elif proof_system == ProofSystem.EZKL:
self.pk = os.path.join(self.external_base_path, "pk.key")
self.vk = os.path.join(self.base_path, "vk.key")
self.compiled_model = os.path.join(self.base_path, "model.compiled")
elif proof_system == ProofSystem.DCAP:
self.compiled_model = os.path.join(self.external_base_path, "network.onnx")
else:
raise ValueError(f"Proof system {proof_system} not supported")

Expand All @@ -143,7 +145,7 @@ class CircuitMetadata:
description: str
author: str
version: str
proof_system: str
proof_system: ProofSystem
type: CircuitType
external_files: dict[str, str]
netuid: int | None = None
Expand All @@ -163,7 +165,18 @@ def from_file(cls, metadata_path: str) -> CircuitMetadata:
ModelMetadata: An instance of ModelMetadata.
"""
with open(metadata_path, "r", encoding="utf-8") as f:
metadata = json.load(f)
if metadata_path.endswith(".json"):
metadata = json.load(f)
elif metadata_path.endswith(".toml"):
metadata = toml.load(f)
else:
metadata = {}

if "proof_system" in metadata:
metadata["proof_system"] = ProofSystem(metadata["proof_system"])
if "type" in metadata:
metadata["type"] = CircuitType(metadata["type"])

return cls(**metadata)


Expand Down
12 changes: 0 additions & 12 deletions neurons/execution_layer/proof_handlers/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,3 @@ def generate_witness(
session (VerifiedModelSession): The current handler session.
return_content (bool): Whether to return the witness content.
"""

@abstractmethod
def aggregate_proofs(
self, session: VerifiedModelSession, proofs: list[str]
) -> tuple[str, float]:
"""
Aggregate multiple proofs into a single proof for the given session.

Returns:
tuple[str, float]: A tuple containing the aggregated proof content (str)
and the time taken to aggregate the proofs (float).
"""
8 changes: 0 additions & 8 deletions neurons/execution_layer/proof_handlers/circom_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,3 @@ def proof_worker(
bt.logging.error(f"Proof generation stdout: {e.stdout}")
bt.logging.error(f"Proof generation stderr: {e.stderr}")
raise

@staticmethod
def aggregate_proofs(
session: "VerifiedModelSession", proofs: list[str]
) -> tuple[str, float]:
raise NotImplementedError(
"Aggregation of proofs is not implemented for CircomHandler"
)
Loading
Loading