Skip to content

Commit 936547c

Browse files
authored
Merge pull request #406 from macrocosm-os/staging
Staging
2 parents 5079b63 + f9eb13d commit 936547c

File tree

6 files changed

+16
-110
lines changed

6 files changed

+16
-110
lines changed

folding/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.3.2"
1+
__version__ = "2.3.3"
22
version_split = __version__.split(".")
33
__spec_version__ = (
44
(10000 * int(version_split[0]))

folding/base/miner.py

-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import bittensor as bt
66

77
from folding.base.neuron import BaseNeuron
8-
from folding.protocol import PingSynapse
98
from folding.utils.config import add_miner_args
109
from folding.utils.logger import logger
1110

@@ -45,8 +44,6 @@ def __init__(self, config=None):
4544
forward_fn=self.forward,
4645
blacklist_fn=self.blacklist,
4746
priority_fn=self.priority,
48-
).attach(
49-
forward_fn=self.ping_forward, # not sure if we need blacklist on this.
5047
)
5148
logger.info(f"Axon created: {self.axon}")
5249

@@ -56,23 +53,6 @@ def __init__(self, config=None):
5653
self.thread: threading.Thread = None
5754
self.lock = asyncio.Lock()
5855

59-
def ping_forward(self, synapse: PingSynapse):
60-
"""Respond to the validator with the necessary information about serving
61-
62-
Args:
63-
self (PingSynapse): must attach "can_serve" and "available_compute"
64-
"""
65-
66-
logger.info(f"Received ping request from {synapse.dendrite.hotkey[:8]}")
67-
68-
synapse.available_compute = self.max_workers - len(self.simulations)
69-
70-
# TODO: add more conditions.
71-
if synapse.available_compute > 0:
72-
synapse.can_serve = True
73-
logger.success("Telling validator you can serve ✅")
74-
return synapse
75-
7656
def run(self):
7757
pass
7858

folding/utils/config.py

-6
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,6 @@ def add_validator_args(cls, parser):
309309
help="The timeout for each forward call. (seconds)",
310310
default=45,
311311
)
312-
parser.add_argument(
313-
"--neuron.ping_timeout",
314-
type=float,
315-
help="Controls the timeout for the PingSynapse call",
316-
default=45,
317-
)
318312

319313
parser.add_argument(
320314
"--neuron.update_interval",

folding/validators/forward.py

+6-24
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from folding.validators.protein import Protein
1111
from folding.utils.logging import log_event
1212
from folding.validators.reward import get_energies
13-
from folding.protocol import PingSynapse, JobSubmissionSynapse
13+
from folding.protocol import JobSubmissionSynapse
1414
import asyncio
1515
from folding.utils.openmm_forcefields import FORCEFIELD_REGISTRY
1616
from folding.validators.hyperparameters import HyperParameters
@@ -26,28 +26,6 @@
2626
ROOT_DIR = Path(__file__).resolve().parents[2]
2727

2828

29-
async def run_ping_step(self, uids: List[int], timeout: float) -> Dict:
30-
"""Report a dictionary of ping information from all miners that were
31-
randomly sampled for this batch.
32-
"""
33-
axons = [self.metagraph.axons[uid] for uid in uids]
34-
synapse = PingSynapse()
35-
36-
logger.info(f"Pinging {len(axons)} uids")
37-
responses: List[PingSynapse] = await self.dendrite.forward(
38-
axons=axons,
39-
synapse=synapse,
40-
timeout=timeout,
41-
)
42-
43-
ping_report = defaultdict(list)
44-
for resp in responses:
45-
ping_report["miner_status"].append(resp.can_serve)
46-
ping_report["reported_compute"].append(resp.available_compute)
47-
48-
return ping_report
49-
50-
5129
async def run_step(
5230
self,
5331
protein: Protein,
@@ -69,7 +47,11 @@ async def run_step(
6947

7048
# Get all uids on the network that are NOT validators.
7149
# the .is_serving flag means that the uid does not have an axon address.
72-
uids = get_all_miner_uids(self.metagraph, self.config.neuron.vpermit_tao_limit, include_serving_in_check=False)
50+
uids = get_all_miner_uids(
51+
self.metagraph,
52+
self.config.neuron.vpermit_tao_limit,
53+
include_serving_in_check=False,
54+
)
7355

7456
# Get the list of uids to query for this step.
7557
axons = [self.metagraph.axons[uid] for uid in uids]

neurons/validator.py

+8-58
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
upload_to_s3,
3535
DigitalOceanS3Handler,
3636
)
37-
from folding.validators.forward import create_new_challenge, run_ping_step, run_step
37+
from folding.validators.forward import create_new_challenge, run_step
3838
from folding.validators.protein import Protein
3939
from folding.registries.miner_registry import MinerRegistry
4040
from folding.organic.api import start_organic_api
@@ -52,7 +52,11 @@ def __init__(self, config=None):
5252

5353
# Sample all the uids on the network, and return only the uids that are non-valis.
5454
logger.info("Determining all miner uids...⏳")
55-
self.all_miner_uids: List = get_all_miner_uids(metagraph=self.metagraph, vpermit_tao_limit=self.config.neuron.vpermit_tao_limit)
55+
self.all_miner_uids: List = get_all_miner_uids(
56+
metagraph=self.metagraph,
57+
vpermit_tao_limit=self.config.neuron.vpermit_tao_limit,
58+
include_serving_in_check=False,
59+
)
5660

5761
# If we do not have any miner registry saved to the machine, create.
5862
if not hasattr(self, "miner_registry"):
@@ -79,24 +83,6 @@ def __init__(self, config=None):
7983
except ValueError as e:
8084
raise f"Failed to create S3 handler, check your .env file: {e}"
8185

82-
def get_uids(self, hotkeys: List[str]) -> List[int]:
83-
"""Returns the uids corresponding to the hotkeys.
84-
It is possible that some hotkeys have been dereg'd,
85-
so we need to check for them in the metagraph.
86-
87-
Args:
88-
hotkeys (List[str]): List of hotkeys
89-
90-
Returns:
91-
List[int]: List of uids
92-
"""
93-
return [
94-
self.metagraph.hotkeys.index(hotkey)
95-
for hotkey in hotkeys
96-
if hotkey in self.metagraph.hotkeys
97-
and self.metagraph.axons[self.metagraph.hotkeys.index(hotkey)].is_serving
98-
]
99-
10086
async def forward(self, job: Job) -> dict:
10187
"""Carries out a query to the miners to check their progress on a given job (pdb) and updates the job status based on the results.
10288
@@ -123,32 +109,6 @@ async def forward(self, job: Job) -> dict:
123109
job_type=job.job_type,
124110
)
125111

126-
async def ping_all_miners(
127-
self,
128-
exclude_uids: List[int],
129-
) -> Tuple[List[int], List[int]]:
130-
"""Sample ALL (non-excluded) miner uids and return the list of uids
131-
that can serve jobs.
132-
133-
Args:
134-
exclude_uids (List[int]): uids to exclude from the uids search
135-
136-
Returns:
137-
Tuple(List,List): Lists of active and inactive uids
138-
"""
139-
140-
current_miner_uids = list(
141-
set(self.all_miner_uids).difference(set(exclude_uids))
142-
)
143-
144-
ping_report = await run_ping_step(
145-
self, uids=current_miner_uids, timeout=self.config.neuron.ping_timeout
146-
)
147-
can_serve = ping_report["miner_status"] # list of booleans
148-
149-
active_uids = np.array(current_miner_uids)[can_serve].tolist()
150-
return active_uids
151-
152112
async def add_job(self, job_event: dict[str, Any], protein: Protein = None) -> bool:
153113
"""Add a job to the job store while also checking to see what uids can be assigned to the job.
154114
If uids are not provided, then the function will sample random uids from the network.
@@ -255,16 +215,6 @@ async def add_k_synthetic_jobs(self, k: int):
255215
await self.add_job(job_event=job_event)
256216
await asyncio.sleep(0.01)
257217

258-
async def update_scores_wrapper(
259-
self, rewards: torch.FloatTensor, hotkeys: List[str]
260-
):
261-
"""Wrapper function to update the scores of the miners based on the rewards they received."""
262-
uids = self.get_uids(hotkeys=hotkeys)
263-
await self.update_scores(
264-
rewards=rewards,
265-
uids=uids,
266-
)
267-
268218
async def update_job(self, job: Job):
269219
"""Updates the job status based on the event information
270220
@@ -523,9 +473,9 @@ async def read_and_update_rewards(self):
523473
)
524474
continue
525475

526-
await self.update_scores_wrapper(
476+
await self.update_scores(
527477
rewards=torch.Tensor(inactive_job.computed_rewards),
528-
hotkeys=inactive_job.hotkeys,
478+
uids=inactive_job.event["uids"],
529479
)
530480
await asyncio.sleep(0.01)
531481

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "folding"
3-
version = "2.3.2"
3+
version = "2.3.3"
44
description = "Macrocosmos Subnet 25: Folding"
55
authors = ["Brian McCrindle <[email protected]>", "Sergio Champoux <[email protected]>", "Szymon Fonau <[email protected]>"]
66

0 commit comments

Comments
 (0)