mathewjacob1002 commented on code in PR #41770:
URL: https://github.com/apache/spark/pull/41770#discussion_r1258940911
##########
python/pyspark/ml/torch/distributor.py:
##########
@@ -155,10 +155,7 @@ class Distributor:
"""
def __init__(
- self,
- num_processes: int = 1,
- local_mode: bool = True,
- use_gpu: bool = True,
+ self, num_processes: int = 1, local_mode: bool = True, use_gpu: bool =
True, ssl_conf=None
Review Comment:
This is from the spark formatter that will be run from the tests.
##########
python/pyspark/ml/torch/deepspeed/deepspeed_distributor.py:
##########
@@ -0,0 +1,143 @@
+#
+# 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):
+ def __init__(
+ self,
+ num_gpus: int = 1,
+ nnodes: int = 1,
+ local_mode: bool = True,
+ use_gpu: bool = True,
+ deepspeed_config=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
+ DEEPSPEED_SSL_CONF = "deepspeed.spark.distributor.ignoreSsl"
+ self.deepspeed_config = deepspeed_config
+ super().__init__(num_processes, local_mode, use_gpu,
_ssl_conf=DEEPSPEED_SSL_CONF)
+ self.cleanup_deepspeed_conf = False
+
+ @staticmethod
+ def _get_deepspeed_config_path(deepspeed_config):
+ if isinstance(deepspeed_config, dict):
+ with tempfile.NamedTemporaryFile(mode="w+", delete=False,
suffix=".json") as fil:
Review Comment:
Done
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]