node.py 725 B

1234567891011121314151617181920212223242526272829
  1. from typing import Optional
  2. import numpy as np
  3. from abc import ABC, abstractmethod
  4. from inference.shard import Shard
  5. from topology.topology import Topology
  6. class Node(ABC):
  7. @abstractmethod
  8. async def start(self, wait_for_peers: int = 0) -> None:
  9. pass
  10. @abstractmethod
  11. async def stop(self) -> None:
  12. pass
  13. @abstractmethod
  14. async def process_tensor(self, shard: Shard, tensor: np.ndarray) -> None:
  15. pass
  16. @abstractmethod
  17. async def process_prompt(self, shard: Shard, prompt: str) -> None:
  18. pass
  19. @abstractmethod
  20. async def reset_shard(self, shard: Shard) -> None:
  21. pass
  22. async def collect_topology(self, max_depth: int = 2) -> Topology:
  23. pass