Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/miners no weight setting #130

Merged
merged 5 commits into from
Feb 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def log_event(self, timing: float, prompt: str, completion: str, system_prompt:

def log_status(self):
m = self.metagraph
bt.logging.info(f"Miner running:: network: {self.subtensor.network} | block: {self.block} | step: {self.step} | uid: {self.uid} | last updated: {self.block-m.last_update[self.uid]} | trust: {m.trust[self.uid]:.3f} | emission {m.emission[self.uid]:.3f}")
bt.logging.info(f"Miner running:: network: {self.subtensor.network} | step: {self.step} | uid: {self.uid} | trust: {m.trust[self.uid]:.3f} | emission {m.emission[self.uid]:.3f}")

# This is the main function, which runs the miner.
if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion prompting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# DEALINGS IN THE SOFTWARE.

# Define the version of the template module.
__version__ = "1.1.1"
__version__ = "1.1.2"
version_split = __version__.split(".")
__spec_version__ = (
(10000 * int(version_split[0]))
Expand Down
32 changes: 0 additions & 32 deletions prompting/base/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,38 +183,6 @@ def __exit__(self, exc_type, exc_value, traceback):
"""
self.stop_run_thread()

def set_weights(self):
"""
Self-assigns a weight of 1 to the current miner (identified by its UID) and
a weight of 0 to all other peers in the network. The weights determine the trust level the miner assigns to other nodes on the network.

Raises:
Exception: If there's an error while setting weights, the exception is logged for diagnosis.
"""
try:
# --- query the chain for the most current number of peers on the network
chain_weights = torch.zeros(
self.subtensor.subnetwork_n(netuid=self.metagraph.netuid)
)
chain_weights[self.uid] = 1

# --- Set weights.
self.subtensor.set_weights(
wallet=self.wallet,
netuid=self.metagraph.netuid,
uids=torch.arange(0, len(chain_weights)),
weights=chain_weights.to("cpu"),
wait_for_inclusion=False,
version_key=self.spec_version,
)

except Exception as e:
bt.logging.error(
f"Failed to set weights on chain with exception: { e }"
)

bt.logging.info(f"Set weights: {chain_weights}")

def resync_metagraph(self):
"""Resyncs the metagraph and updates the hotkeys and moving averages based on the new metagraph."""
bt.logging.info("resync_metagraph()")
Expand Down
3 changes: 3 additions & 0 deletions prompting/base/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def should_set_weights(self) -> bool:
if self.config.neuron.disable_set_weights:
return False

if not self.metagraph.validator_permit[self.uid]:
return False

# Define appropriate logic for when set weights.
return (
self.block - self.metagraph.last_update[self.uid]
Expand Down
Loading