|
@@ -39,11 +39,26 @@ try:
|
|
output = pickle.dumps(output)
|
|
output = pickle.dumps(output)
|
|
return output
|
|
return output
|
|
|
|
|
|
|
|
+ ray_import_err = None
|
|
|
|
+
|
|
except ImportError as e:
|
|
except ImportError as e:
|
|
ray = None # type: ignore
|
|
ray = None # type: ignore
|
|
|
|
+ ray_import_err = e
|
|
RayWorkerWrapper = None # type: ignore
|
|
RayWorkerWrapper = None # type: ignore
|
|
|
|
|
|
|
|
|
|
|
|
+def ray_is_available() -> bool:
|
|
|
|
+ """Returns True if Ray is available."""
|
|
|
|
+ return ray is not None
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def assert_ray_available():
|
|
|
|
+ """Raise an exception if Ray is not available."""
|
|
|
|
+ if ray is None:
|
|
|
|
+ raise ValueError("Failed to import Ray, please install Ray with "
|
|
|
|
+ "`pip install ray`.") from ray_import_err
|
|
|
|
+
|
|
|
|
+
|
|
def initialize_ray_cluster(
|
|
def initialize_ray_cluster(
|
|
parallel_config: ParallelConfig,
|
|
parallel_config: ParallelConfig,
|
|
ray_address: Optional[str] = None,
|
|
ray_address: Optional[str] = None,
|
|
@@ -59,11 +74,7 @@ def initialize_ray_cluster(
|
|
ray_address: The address of the Ray cluster. If None, uses
|
|
ray_address: The address of the Ray cluster. If None, uses
|
|
the default Ray cluster address.
|
|
the default Ray cluster address.
|
|
"""
|
|
"""
|
|
- if ray is None:
|
|
|
|
- raise ImportError(
|
|
|
|
- "Ray is not installed. Please install Ray to use multi-node "
|
|
|
|
- "serving. You can install Ray by running "
|
|
|
|
- "`pip install aphrodite-engine[\"ray\"]`.")
|
|
|
|
|
|
+ assert_ray_available()
|
|
|
|
|
|
# Connect to a ray cluster.
|
|
# Connect to a ray cluster.
|
|
if is_hip() or is_xpu():
|
|
if is_hip() or is_xpu():
|