Skip to content

Commit d5d1204

Browse files
committedMar 29, 2024·
dded kubeflow overview.
1 parent 6fa9ad4 commit d5d1204

File tree

1 file changed

+62
-18
lines changed

1 file changed

+62
-18
lines changed
 

‎sections/docker-hpc-cloud.qmd

+62-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: "Containers in HPC and Cloud"
2+
title: "Container orchestration"
33
---
44

55
## Learning Objectives
66

7-
- Discuss containers in high performace computing environments
8-
- Explore orchestration formats
7+
- Discuss containers in high performace computing and cloud computing
8+
- Explore orchestration approaches
99
- Learn how to use docker compose to build a workflow
1010
- Explore a real world Kubernetes service
1111

@@ -197,45 +197,75 @@ Like other container systems, Kubernetes is configured through a set of YAML con
197197

198198
::: {layout="[[70,30]]"}
199199

200-
Parsl is all about the beef...
200+
Parsl provides a simple mechanism to decorate python functions to be executed concurrently on a variety of platforms and under different execution models, inlcuding the `ThreadPoolExecutor` and the `HighThroughputExecutor`, which we used previously.
201201

202202
![](../images/parsl-logo.png)
203203

204204
:::
205205

206-
Remember the basic layout of a parsl app:
206+
Remember the basic layout of a parsl app, in which the `@python_app` decorator is used to wrap task functions that should be executed by parsl.
207207

208208
```python
209209
# Define the square task.
210210
import parsl
211211
@python_app
212212
def square(x):
213213
return x * x
214+
```
214215

215-
# Launch four parallel square tasks.
216-
futures = [square(i) for i in range(4)]
216+
This works because parsl is configured ahead of time to use a particular type of execution environment on the nodes of a cluster. The `HighThroughPutExector` that we used previously with a `LocalProvider` can instead be easily configured to work using a `KubernetesProvider`. Here's a modification to our previous Config to use Kubernetes:
217217

218-
# Retrieve results.
219-
squares = [future.result() for future in futures]
220-
print(squares)
221-
# -> [0, 1, 4, 9]
218+
```python
219+
activate_env = 'workon scomp'
220+
htex_kube = Config(
221+
executors=[
222+
HighThroughputExecutor(
223+
label='kube-htex',
224+
cores_per_worker=cores_per_worker,
225+
max_workers=5,
226+
worker_logdir_root='/',
227+
# Address for the pod worker to connect back
228+
address=address_by_route(),
229+
provider=KubernetesProvider(
230+
231+
# Namespace in K8S to use for the run
232+
namespace='adccourse',
233+
234+
# Docker image url to use for pods
235+
image='ghcr.io/mbjones/k8sparsl:0.3',
236+
237+
# Command to be run upon pod start
238+
worker_init=activate_env,
239+
240+
# Should follow the Kubernetes naming rules
241+
pod_name='parsl-worker',
242+
243+
nodes_per_block=1,
244+
init_blocks=1,
245+
min_blocks=1,
246+
# Maximum number of pods to scale up
247+
max_blocks=1,
248+
# persistent_volumes (list[(str, str)]) – List of tuples
249+
# describing persistent volumes to be mounted in the pod.
250+
# The tuples consist of (PVC Name, Mount Directory).
251+
# persistent_volumes=[('mypvc','/var/data')]
252+
),
253+
),
254+
]
255+
)
222256
```
223-
257+
With that change, Parsl will send tasks to Kubernetes worker pods. Otherwise, the remaining parsl code is the smae as previously.
224258

225259
### Ray.io
226260

227261
::: {layout="[[60,40]]"}
228262

229-
[Ray](https://ray.io) is structured so similarly to Parsl...
263+
[Ray](https://ray.io) is structured similarly to Parsl, and also uses decorators to wrap task functions that are to be executed. [Ray Core](https://docs.ray.io/en/latest/ray-core/walkthrough.html) is the part that is fairly analogous to Parsl, and provides the core functionality for distributed execution for any kind of compute jobs.
230264

231265
![](../images/ray-logo.png)
232266

233267
:::
234268

235-
![](../images/ray-components.png)
236-
237-
[Ray Core](https://docs.ray.io/en/latest/ray-core/walkthrough.html) is fairly analogous to Parsl, and provides the core functionality for distributed execution.
238-
239269
```python
240270
# Define the square task.
241271
@ray.remote
@@ -250,11 +280,25 @@ print(ray.get(futures))
250280
# -> [0, 1, 4, 9]
251281
```
252282

283+
The execution model also returns a `Future`-like object that can be queried to get the function results when it is complete.
284+
285+
Ray Core defines `Tasks`, `Actors`, and `Objects`, all of which can be used on ditributed clusters such as Kubernetes. And like Parsl, Ray can be configured to use a wide variety of execution backends such as Kubernetes. Ray also provides a mature framework for training, tuning, and serving machine learning models and the associated data.
286+
287+
![](../images/ray-components.png)
288+
289+
253290
### Kubeflow
254291

255-
[Kubeflow](https://www.kubeflow.org/)
292+
::: {layout="[[85,15]]"}
293+
294+
[Kubeflow](https://www.kubeflow.org/) is yet another orchestration package designed to asynchronously execute tasks from containers, but Kubeflow is specific to Kubernetes clusters.
295+
256296
![](../images/kubeflow-logo.png)
257297

298+
:::
299+
300+
Here's the syntax for defining a Kubeflow component and pipeline to be executed on worker pods of a Kubernetes cluster. The similarities with the previous packages are striking. But unlike Parsl and Ray, a workflow built in Kubeflow can't be run on the rich variety of high performace computing clusters supported by the other libraries.
301+
258302
```python
259303
# Kubeflow pipeline example
260304
from kfp import dsl

0 commit comments

Comments
 (0)
Please sign in to comment.