mathewjacob1002 commented on code in PR #41770:
URL: https://github.com/apache/spark/pull/41770#discussion_r1261547715


##########
python/pyspark/ml/deepspeed/deepspeed_distributor.py:
##########
@@ -0,0 +1,154 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import json
+import os
+import sys
+import tempfile
+from typing import (
+    Union,
+    Callable,
+    List,
+    Dict,
+    Optional,
+    Any,
+    Tuple,
+)
+
+from pyspark.ml.torch.distributor import TorchDistributor
+
+
+class DeepspeedTorchDistributor(TorchDistributor):
+
+    _DEEPSPEED_SSL_CONF = "deepspeed.spark.distributor.ignoreSsl"
+
+    def __init__(
+        self,
+        num_gpus: int = 1,
+        nnodes: int = 1,
+        local_mode: bool = True,
+        use_gpu: bool = True,
+        deepspeed_config: Optional[Union[str, Dict[str, Any]]] = None,
+    ):
+        """
+        This class is used to run deepspeed training workloads with spark 
clusters. The user has the option to
+        specify the number of gpus per node and the number of nodes (the same 
as if running from terminal),
+        as well as specify a deepspeed configuration file.
+
+        Parameters
+        ----------
+        num_gpus: int
+            The number of GPUs to use per node (analagous to num_gpus in 
deepspeed command).
+
+        nnodes: int
+            The number of nodes that should be used for the run.
+
+        local_mode: bool
+            Whether or not to run the training in a distributed fashion or 
just locally.
+
+        use_gpu: bool
+            Boolean flag to determine whether to utilize gpus.
+
+        deepspeed_config: Union[Dict[str,Any], str] or None:
+            The configuration file to be used for launching the deepspeed 
application.
+            If it is a dictionary mapping parameters to values, then we will 
create the file.
+            If None, deepspeed will fall back to default parameters.
+        """
+        num_processes = num_gpus * nnodes
+        self.deepspeed_config = deepspeed_config

Review Comment:
   The user can't access the num_processes anyways, but for deepspeed_config 
I'll add a leading underscore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to