server.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. **hivemind.moe.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.moe.client.RemoteExpert("addr:port", "expert.uid.here")**
  6. or as a part of **hivemind.moe.client.RemoteMixtureOfExperts** that finds the most suitable experts across the DHT.
  7. The hivemind.moe.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. - ModuleBackend_ is a wrapper for `torch.nn.Module <https://pytorch.org/docs/stable/generated/torch.nn.Module.html>`_ \
  10. that can be accessed by remote clients. It has two TaskPool_ s for forward and backward requests.
  11. - Runtime_ balances the device (GPU) usage between several ModuleBackend_ instances that each service one expert.
  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.moe.server
  15. .. currentmodule:: hivemind.moe.server
  16. .. _Server:
  17. .. autoclass:: Server
  18. :members:
  19. :member-order: bysource
  20. .. _ModuleBackend:
  21. .. autoclass:: ModuleBackend
  22. :members: forward, backward, on_backward, get_info, get_pools
  23. :member-order: bysource
  24. .. currentmodule:: hivemind.moe.server.runtime
  25. .. _Runtime:
  26. .. autoclass:: Runtime
  27. :members:
  28. :member-order: bysource
  29. .. currentmodule:: hivemind.moe.server.task_pool
  30. .. _TaskPool:
  31. .. autoclass:: TaskPool
  32. :members: submit_task, iterate_minibatches, load_batch_to_runtime, send_outputs_from_runtime, get_task_size, empty
  33. :member-order: bysource