Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions graphite/validator/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import os
import random
import requests
import uuid

from pydantic import ValidationError

Expand Down Expand Up @@ -82,11 +83,20 @@ async def forward(self):
bt.logging.info(f"n_nodes V2 {n_nodes}")
bt.logging.info(f"dataset ref {dataset_ref} selected from {list(self.loaded_datasets.keys())}" )
selected_node_idxs = random.sample(range(len(self.loaded_datasets[dataset_ref]['data'])), n_nodes)
test_problem_obj = GraphV2Problem(problem_type="Metric TSP", n_nodes=n_nodes, selected_ids=selected_node_idxs, cost_function="Geom", dataset_ref=dataset_ref)
task_uuid = str(uuid.uuid1())

test_problem_obj = GraphV2Problem(
problem_type="Metric TSP",
n_nodes=n_nodes,
selected_ids=selected_node_idxs,
cost_function="Geom",
dataset_ref=dataset_ref,
task_uuid=task_uuid
)

try:
graphsynapse_req = GraphV2Synapse(problem=test_problem_obj)
bt.logging.info(f"GraphV2Synapse Problem, n_nodes: {graphsynapse_req.problem.n_nodes}")
bt.logging.info(f"GraphV2Synapse Problem, n_nodes: {graphsynapse_req.problem.n_nodes}, task_id: {task_uuid}")
except ValidationError as e:
bt.logging.debug(f"GraphV2Synapse Validation Error: {e.json()}")
bt.logging.debug(e.errors())
Expand Down Expand Up @@ -288,7 +298,7 @@ async def forward(self):
}),
)
for rewIdx in range(self.metagraph.n.item()):
wandb.log({f"rewards-{self.wallet.hotkey.ss58_address}": wandb_rewards[rewIdx], f"distance-{self.wallet.hotkey.ss58_address}": wandb_miner_distance[rewIdx]}, step=int(rewIdx))
wandb.log({f"rewards-{self.wallet.hotkey.ss58_address}/task-{task_uuid}": wandb_rewards[rewIdx], f"distance-{self.wallet.hotkey.ss58_address}/task-{task_uuid}": wandb_miner_distance[rewIdx]}, step=int(rewIdx))

self.cleanup_wandb(wandb)
except Exception as e:
Expand Down
12 changes: 9 additions & 3 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ async def forwardV1(
synapse.solution = route

bt.logging.info(
f"Miner returned value {synapse.solution} {len(synapse.solution) if isinstance(synapse.solution, list) else synapse.solution}"
f"Miner completed task {synapse.problem.task_uuid} and returned value {synapse.solution} {len(synapse.solution) if isinstance(synapse.solution, list) else synapse.solution}"
)

# TODO: Add logging to private WandB or optional public WandB

return synapse

async def forwardV2(
Expand Down Expand Up @@ -189,7 +192,7 @@ async def forwardV2(
# f.write(log_line)

bt.logging.info(
f"Miner received input to solve {synapse.problem.n_nodes}"
f"Miner received task {synapse.problem.task_uuid} to solve {synapse.problem.n_nodes}"
)

if isinstance(synapse.problem, GraphV2Problem):
Expand All @@ -208,8 +211,11 @@ async def forwardV2(
synapse.problem.edges = None

bt.logging.info(
f"Miner returned value {synapse.solution} {len(synapse.solution) if isinstance(synapse.solution, list) else synapse.solution}"
f"Miner completed task {synapse.problem.task_uuid} and returned value {synapse.solution} {len(synapse.solution) if isinstance(synapse.solution, list) else synapse.solution}"
)

# TODO: Add logging to private WandB or optional public WandB

return synapse

async def blacklist(
Expand Down