Skip to content

Commit

Permalink
Fix Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
borzunov committed Jul 15, 2023
1 parent 3e23a2e commit aab1dad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/petals/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import time
from typing import Dict, List, Optional, Sequence, Union

import torch
import hivemind
import torch
from hivemind import DHT, MAX_DHT_TIME_DISCREPANCY_SECONDS, BatchTensorDescriptor, get_dht_time
from hivemind.moe.server.layers import add_custom_models_from_file
from hivemind.moe.server.runtime import Runtime
Expand Down
4 changes: 2 additions & 2 deletions src/petals/utils/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, dht: hivemind.DHT, *, ema_alpha: float = 0.1, expiration: flo

def ping(self, peer_ids: Sequence[hivemind.PeerID], **kwargs):
current_rtts = self.dht.run_coroutine(partial(ping_parallel, peer_ids, **kwargs))
logger.debug(f"Current RTTs: {current_rtts=}")
logger.debug(f"Current RTTs: {current_rtts}")

expiration = hivemind.get_dht_time() + self.expiration
for peer_id, rtt in current_rtts.items():
Expand All @@ -54,7 +54,7 @@ def ping(self, peer_ids: Sequence[hivemind.PeerID], **kwargs):
def fastest(self, n_peers: int) -> Dict[hivemind.PeerID, float]:
with self.ping_emas.freeze():
smoothed_rtts = {peer_id: rtt.value for peer_id, rtt in self.ping_emas.items()}
logger.debug(f"Smothed RTTs: {smoothed_rtts=}")
logger.debug(f"Smothed RTTs: {smoothed_rtts}")

fastest_rtts = sorted(smoothed_rtts.items(), key=lambda item: item[1])[:n_peers]
return dict(fastest_rtts)

0 comments on commit aab1dad

Please sign in to comment.