server.rst 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. **hivemind.server**
  2. ========================================
  3. A hivemind server hosts one or several experts and processes incoming requests to those experts. It periodically
  4. re-publishes these experts to the dht via a dedicated **hivemind.dht.DHT** peer that runs in background.
  5. The experts can be accessed directly as **hivemind.client.RemoteExpert("addr:port", "expert.uid.here")**
  6. or as a part of **hivemind.client.RemoteMixtureOfExperts** that finds the most suitable experts across the DHT.
  7. The hivemind.server module is organized as follows:
  8. - Server_ is the main class that publishes experts, accepts incoming requests, and passes them to Runtime_ for compute.
  9. - Runtime_ balances the device (GPU) usage between several ExpertBackend_ instances that each service one expert.
  10. - ExpertBackend_ is a wrapper for `torch.nn.Module <https://pytorch.org/docs/stable/generated/torch.nn.Module.html>`_ \
  11. that can be accessed by remote clients. It has two TaskPool_ -s for forward and backward requests.
  12. - TaskPool_ stores incoming requests for a batch-parallel computation (e.g. forward pass), groups them into batches \
  13. and offers those batches to Runtime_ for processing.
  14. .. automodule:: hivemind.server
  15. .. currentmodule:: hivemind.server
  16. .. _Server:
  17. .. autoclass:: Server
  18. :members:
  19. :member-order: bysource
  20. .. _Runtime:
  21. .. autoclass:: Runtime
  22. :members:
  23. :member-order: bysource
  24. .. _ExpertBackend:
  25. .. autoclass:: ExpertBackend
  26. :members: forward, backward, apply_gradients, get_info, get_pools
  27. :member-order: bysource
  28. .. _TaskPool:
  29. .. autoclass:: TaskPool
  30. :members: submit_task, iterate_minibatches, load_batch_to_runtime, send_outputs_from_runtime, get_task_size, empty
  31. :member-order: bysource