-
Couldn't load subscription status.
- Fork 409
add transfer engine for training and inference. #569
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Import for backward compatibility | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import torch | ||
| import zmq | ||
|
|
||
| from transfer_engine import MooncakeTransferEngine | ||
| from new_tensor import create_tensor | ||
|
|
||
| class MooncakeInference: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these class names do not precisely reveal what they are actually doing. Maybe the usage is for RL training and inference, but the names are very confusing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Will fix |
||
| def __init__(self, config: dict): | ||
| self.config = config | ||
| self._engine = MooncakeTransferEngine( | ||
| hostname = config["inference_ip"], | ||
| gpu_id = config["inference_gpu_id"], # Using GPU | ||
| ib_device = None # No specific IB device | ||
| ) | ||
| self._context = zmq.Context() | ||
| self._socket = self._context.socket(zmq.REQ) | ||
| self._socket.connect(f"tcp://{config['training_ip']}:{config['port']}") | ||
|
|
||
| def __del__(self): | ||
| self._socket.close() | ||
| self._context.destroy() | ||
|
|
||
| def recv_tensor(self) -> dict: | ||
| self._socket.send_json({"session_id": self._engine.get_session_id()}) | ||
| ret = self._socket.recv_json() # ["name", "shape", "dtype"] | ||
| tensor = create_tensor(ret[1], ret[2], self.config["inference_gpu_id"]) | ||
| self._engine.register(tensor.data_ptr(), tensor.numel() * tensor.element_size()) | ||
| self._socket.send_json({"ptr": tensor.data_ptr()}) | ||
| self._socket.recv_json() | ||
| self._engine.deregister(tensor.data_ptr()) | ||
| return {ret[0]: tensor} | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||
| import torch | ||||||
| import zmq | ||||||
| import time | ||||||
| from threading import Thread | ||||||
| from queue import Queue | ||||||
| from new_tensor import get_dtype_str | ||||||
|
|
||||||
| from transfer_engine import MooncakeTransferEngine | ||||||
|
||||||
| from transfer_engine import MooncakeTransferEngine | |
| from .transfer_engine import MooncakeTransferEngine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a relative import for the local transfer_engine module to avoid import errors (e.g.,
from .transfer_engine import MooncakeTransferEngine).