xpk 0.2.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,431 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: xpk
3
- Version: 0.2.0
4
- Summary: xpk helps Cloud developers to orchestrate training jobs on accelerators on GKE.
5
- Author-email: Cloud TPU Team <cloud-tpu-eng@google.com>
6
- License: Apache-2.0
7
- Project-URL: Homepage, https://github.com/google/xpk
8
- Project-URL: Bug Tracker, https://github.com/google/xpk/issues
9
- Classifier: Programming Language :: Python :: 3.10
10
- Classifier: Programming Language :: Python :: 3.11
11
- Requires-Python: >=3.10
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
-
15
- <!--
16
- Copyright 2023 Google LLC
17
-
18
- Licensed under the Apache License, Version 2.0 (the "License");
19
- you may not use this file except in compliance with the License.
20
- You may obtain a copy of the License at
21
-
22
- https://www.apache.org/licenses/LICENSE-2.0
23
-
24
- Unless required by applicable law or agreed to in writing, software
25
- distributed under the License is distributed on an "AS IS" BASIS,
26
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
- See the License for the specific language governing permissions and
28
- limitations under the License.
29
- -->
30
-
31
- # Overview
32
-
33
- xpk (Accelerated Processing Kit, pronounced x-p-k,) is a software tool to help
34
- Cloud developers to orchestrate training jobs on accelerators such as TPUs and
35
- GPUs on GKE. xpk handles the "multihost pods" of TPUs and GPUs (HGX H100) as
36
- first class citizens.
37
-
38
- xpk decouples provisioning capacity from running jobs. There are two structures:
39
- clusters (provisioned VMs) and workloads (training jobs). Clusters represent the
40
- physical resources you have available. Workloads represent training jobs -- at
41
- any time some of these will be completed, others will be running and some will
42
- be queued, waiting for cluster resources to become available.
43
-
44
- The ideal workflow starts by provisioning the clusters for all of the ML
45
- hardware you have reserved. Then, without re-provisioning, submit jobs as
46
- needed. By eliminating the need for re-provisioning between jobs, using Docker
47
- containers with pre-installed dependencies and cross-ahead of time compilation,
48
- these queued jobs run with minimal start times. Further, because workloads
49
- return the hardware back to the shared pool when they complete, developers can
50
- achieve better use of finite hardware resources. And automated tests can run
51
- overnight while resources tend to be underutilized.
52
-
53
- xpk supports the following TPU types:
54
- * v4
55
- * v5e
56
- * v5p
57
-
58
- # Installation
59
- To install xpk, run the following command:
60
-
61
- ```shell
62
- pip install xpk
63
- ```
64
-
65
- # XPK for Large Scale (>1k VMs)
66
-
67
- Follow user instructions in [xpk-large-scale-guide.sh](xpk-large-scale-guide.sh)
68
- to use xpk for a GKE cluster greater than 1000 VMs. Run these steps to set up a
69
- GKE cluster with large scale training and high throughput support with XPK, and
70
- run jobs with XPK. We recommend you manually copy commands per step and verify
71
- the outputs of each step.
72
-
73
- # Example usages:
74
-
75
- To get started, be sure to set your GCP Project and Zone as usual via `gcloud
76
- config set`.
77
-
78
- Below are reference commands. A typical journey starts with a `Cluster Create`
79
- followed by many `Workload Create`s. To understand the state of the system you
80
- might want to use `Cluster List` or `Workload List` commands. Finally, you can
81
- cleanup with a `Cluster Delete`.
82
-
83
- ## Cluster Create
84
-
85
- First set the project and zone through gcloud config or xpk arguments.
86
-
87
- ```shell
88
- PROJECT_ID=my-project-id
89
- ZONE=us-east5-b
90
- # gcloud config:
91
- gcloud config set project $PROJECT_ID
92
- gcloud config set compute/zone $ZONE
93
- # xpk arguments
94
- xpk .. --zone $ZONE --project $PROJECT_ID
95
- ```
96
-
97
-
98
- The cluster created is a regional cluster to enable the GKE control plane across
99
- all zones.
100
-
101
- * Cluster Create (provision reserved capacity):
102
-
103
- ```shell
104
- # Find your reservations
105
- gcloud compute reservations list --project=$PROJECT_ID
106
- # Run cluster create with reservation.
107
- python3 xpk.py cluster create \
108
- --cluster xpk-test --tpu-type=v5litepod-256 \
109
- --num-slices=2 \
110
- --reservation=$RESERVATION_ID
111
- ```
112
-
113
- * Cluster Create (provision on-demand capacity):
114
-
115
- ```shell
116
- python3 xpk.py cluster create \
117
- --cluster xpk-test --tpu-type=v5litepod-16 \
118
- --num-slices=4 --on-demand
119
- ```
120
-
121
- * Cluster Create (provision spot / preemptable capacity):
122
-
123
- ```shell
124
- python3 xpk.py cluster create \
125
- --cluster xpk-test --tpu-type=v5litepod-16 \
126
- --num-slices=4 --spot
127
- ```
128
-
129
- * Cluster Create can be called again with the same `--cluster name` to modify
130
- the number of slices or retry failed steps.
131
-
132
- For example, if a user creates a cluster with 4 slices:
133
-
134
- ```shell
135
- python3 xpk.py cluster create \
136
- --cluster xpk-test --tpu-type=v5litepod-16 \
137
- --num-slices=4 --reservation=$RESERVATION_ID
138
- ```
139
-
140
- and recreates the cluster with 8 slices. The command will rerun to create 4
141
- new slices:
142
-
143
- ```shell
144
- python3 xpk.py cluster create \
145
- --cluster xpk-test --tpu-type=v5litepod-16 \
146
- --num-slices=8 --reservation=$RESERVATION_ID
147
- ```
148
-
149
- and recreates the cluster with 6 slices. The command will rerun to delete 2
150
- slices. The command will warn the user when deleting slices.
151
- Use `--force` to skip prompts.
152
-
153
- ```shell
154
- python3 xpk.py cluster create \
155
- --cluster xpk-test --tpu-type=v5litepod-16 \
156
- --num-slices=6 --reservation=$RESERVATION_ID
157
-
158
- # Skip delete prompts using --force.
159
-
160
- python3 xpk.py cluster create --force \
161
- --cluster xpk-test --tpu-type=v5litepod-16 \
162
- --num-slices=6 --reservation=$RESERVATION_ID
163
-
164
- ```
165
- ## Cluster Delete
166
- * Cluster Delete (deprovision capacity):
167
-
168
- ```shell
169
- python3 xpk.py cluster delete \
170
- --cluster xpk-test
171
- ```
172
- ## Cluster List
173
- * Cluster List (see provisioned capacity):
174
-
175
- ```shell
176
- python3 xpk.py cluster list
177
- ```
178
- ## Cluster Describe
179
- * Cluster Describe (see capacity):
180
-
181
- ```shell
182
- python3 xpk.py cluster describe \
183
- --cluster xpk-test
184
- ```
185
-
186
- ## Cluster Cacheimage
187
- * Cluster Cacheimage (enables faster start times):
188
-
189
- ```shell
190
- python3 xpk.py cluster cacheimage \
191
- --cluster xpk-test --docker-image gcr.io/your_docker_image
192
- ```
193
-
194
- ## Workload Create
195
- * Workload Create (submit training job):
196
-
197
- ```shell
198
- python3 xpk.py workload create \
199
- --workload xpk-test-workload --command "echo goodbye" --cluster \
200
- xpk-test --tpu-type=v5litepod-16
201
- ```
202
-
203
- ### Set `max-restarts` for production jobs
204
-
205
- * `--max-restarts <value>`: By default, this is 0. This will restart the job ""
206
- times when the job terminates. For production jobs, it is recommended to
207
- increase this to a large number, say 50. Real jobs can be interrupted due to
208
- hardware failures and software updates. We assume your job has implemented
209
- checkpointing so the job restarts near where it was interrupted.
210
-
211
- ### Workload Priority and Preemption
212
- * Set the priority level of your workload with `--priority=LEVEL`
213
-
214
- We have five priorities defined: [`very-low`, `low`, `medium`, `high`, `very-high`].
215
- The default priority is `medium`.
216
-
217
- Priority determines:
218
-
219
- 1. Order of queued jobs.
220
-
221
- Queued jobs are ordered by
222
- `very-low` < `low` < `medium` < `high` < `very-high`
223
-
224
- 2. Preemption of lower priority workloads.
225
-
226
- A higher priority job will `evict` lower priority jobs.
227
- Evicted jobs are brought back to the queue and will re-hydrate appropriately.
228
-
229
- #### General Example:
230
- ```shell
231
- python3 xpk.py workload create \
232
- --workload xpk-test-medium-workload --command "echo goodbye" --cluster \
233
- xpk-test --tpu-type=v5litepod-16 --priority=medium
234
- ```
235
-
236
- ## Workload Delete
237
- * Workload Delete (delete training job):
238
-
239
- ```shell
240
- python3 xpk.py workload delete \
241
- --workload xpk-test-workload --cluster xpk-test
242
- ```
243
-
244
- ## Workload List
245
- * Workload List (see training jobs):
246
-
247
- ```shell
248
- python3 xpk.py workload list \
249
- --cluster xpk-test
250
- ```
251
-
252
- * Example Workload List Output:
253
-
254
- The below example shows four jobs of different statuses:
255
-
256
- * `user-first-job-failed`: **filter-status** is `FINISHED` and `FAILED`.
257
- * `user-second-job-success`: **filter-status** is `FINISHED` and `SUCCESSFUL`.
258
- * `user-third-job-running`: **filter-status** is `RUNNING`.
259
- * `user-forth-job-in-queue`: **filter-status** is `QUEUED`.
260
- * `user-fifth-job-in-queue-preempted`: **filter-status** is `QUEUED`.
261
-
262
- ```
263
- Jobset Name Created Time Priority TPU VMs Needed TPU VMs Running/Ran TPU VMs Done Status Status Message Status Time
264
- user-first-job-failed 2023-1-1T1:00:00Z medium 4 4 <none> Finished JobSet failed 2023-1-1T1:05:00Z
265
- user-second-job-success 2023-1-1T1:10:00Z medium 4 4 4 Finished JobSet finished successfully 2023-1-1T1:14:00Z
266
- user-third-job-running 2023-1-1T1:15:00Z medium 4 4 <none> Admitted Admitted by ClusterQueue cluster-queue 2023-1-1T1:16:00Z
267
- user-forth-job-in-queue 2023-1-1T1:16:05Z medium 4 <none> <none> Admitted couldn't assign flavors to pod set slice-job: insufficient unused quota for google.com/tpu in flavor 2xv4-8, 4 more need 2023-1-1T1:16:10Z
268
- user-fifth-job-preempted 2023-1-1T1:10:05Z low 4 <none> <none> Evicted Preempted to accommodate a higher priority Workload 2023-1-1T1:10:00Z
269
- ```
270
-
271
- * Workload List supports filtering. Observe a portion of jobs that match user criteria.
272
-
273
- * Filter by Status: `filter-by-status`
274
-
275
- Filter the workload list by the status of respective jobs.
276
- Status can be: `EVERYTHING`,`FINISHED`, `RUNNING`, `QUEUED`, `FAILED`, `SUCCESSFUL`
277
-
278
- * Filter by Job: `filter-by-job`
279
-
280
- Filter the workload list by the name of a job.
281
-
282
- ```shell
283
- python3 xpk.py workload list \
284
- --cluster xpk-test --filter-by-job=$USER
285
- ```
286
-
287
- # How to add docker images to a xpk workload
288
-
289
- The default behavior is `xpk workload create` will layer the local directory (`--script-dir`) into
290
- the base docker image (`--base-docker-image`) and run the workload command.
291
- If you don't want this layering behavior, you can directly use `--docker-image`. Do not mix arguments from the two flows in the same command.
292
-
293
- ## Recommended / Default Docker Flow: `--base-docker-image` and `--script-dir`
294
- This flow pulls the `--script-dir` into the `--base-docker-image` and runs the new docker image.
295
-
296
- * The below arguments are optional by default. xpk will pull the local
297
- directory with a generic base docker image.
298
-
299
- - `--base-docker-image` sets the base image that xpk will start with.
300
-
301
- - `--script-dir` sets which directory to pull into the image. This defaults to the current working directory.
302
-
303
- See `python3 xpk.py workload create --help` for more info.
304
-
305
- * Example with defaults which pulls the local directory into the base image:
306
- ```shell
307
- echo -e '#!/bin/bash \n echo "Hello world from a test script!"' > test.sh
308
- python3 xpk.py workload create --cluster xpk-test \
309
- --workload xpk-test-workload-base-image --command "bash test.sh" \
310
- --tpu-type=v5litepod-16 --num-slices=1
311
- ```
312
-
313
- * Recommended Flow For Normal Sized Jobs (fewer than 10k accelerators):
314
- ```shell
315
- python3 xpk.py workload create --cluster xpk-test \
316
- --workload xpk-test-workload-base-image --command "bash custom_script.sh" \
317
- --base-docker-image=gcr.io/your_dependencies_docker_image \
318
- --tpu-type=v5litepod-16 --num-slices=1
319
- ```
320
-
321
- ## Optional Direct Docker Image Configuration: `--docker-image`
322
- If a user wants to directly set the docker image used and not layer in the
323
- current working directory, set `--docker-image` to the image to be use in the
324
- workload.
325
-
326
- * Running with `--docker-image`:
327
- ```shell
328
- python3 xpk.py workload create --cluster xpk-test \
329
- --workload xpk-test-workload-base-image --command "bash test.sh" \
330
- --tpu-type=v5litepod-16 --num-slices=1 --docker-image=gcr.io/your_docker_image
331
- ```
332
-
333
- * Recommended Flow For Large Sized Jobs (more than 10k accelerators):
334
- ```shell
335
- python3 xpk.py cluster cacheimage \
336
- --cluster xpk-test --docker-image gcr.io/your_docker_image
337
- # Run workload create with the same image.
338
- python3 xpk.py workload create --cluster xpk-test \
339
- --workload xpk-test-workload-base-image --command "bash test.sh" \
340
- --tpu-type=v5litepod-16 --num-slices=1 --docker-image=gcr.io/your_docker_image
341
- ```
342
-
343
- # More advanced facts:
344
-
345
- * Workload create accepts a --env-file flag to allow specifying the container's
346
- environment from a file. Usage is the same as Docker's
347
- [--env-file flag](https://docs.docker.com/engine/reference/commandline/run/#env)
348
-
349
- Example File:
350
- ```shell
351
- LIBTPU_INIT_ARGS=--my-flag=true --performance=high
352
- MY_ENV_VAR=hello
353
- ```
354
-
355
- * Workload create accepts a --debug-dump-gcs flag which is a path to GCS bucket.
356
- Passing this flag sets the XLA_FLAGS='--xla_dump_to=/tmp/xla_dump/' and uploads
357
- hlo dumps to the specified GCS bucket for each worker.
358
-
359
-
360
- # Troubleshooting
361
-
362
- ## `Invalid machine type` for CPUs.
363
- XPK will create a regional GKE cluster. If you see issues like
364
-
365
- ```shell
366
- Invalid machine type e2-standard-32 in zone $ZONE_NAME
367
- ```
368
-
369
- Please select a CPU type that exists in all zones in the region.
370
-
371
- ```shell
372
- # Find CPU Types supported in zones.
373
- gcloud compute machine-types list --zones=$ZONE_LIST
374
- # Adjust default cpu machine type.
375
- python3 xpk.py cluster create --cluster-cpu-machine-type=CPU_TYPE ...
376
- ```
377
-
378
- ## Permission Issues: `requires one of ["permission_name"] permission(s)`.
379
-
380
- 1) Determine the role needed based on the permission error:
381
-
382
- ```shell
383
- # For example: `requires one of ["container.*"] permission(s)`
384
- # Add [Kubernetes Engine Admin](https://cloud.google.com/iam/docs/understanding-roles#kubernetes-engine-roles) to your user.
385
- ```
386
-
387
- 2) Add the role to the user in your project.
388
-
389
- Go to [iam-admin](https://console.cloud.google.com/iam-admin/) or use gcloud cli:
390
- ```shell
391
- PROJECT_ID=my-project-id
392
- CURRENT_GKE_USER=$(gcloud config get account)
393
- ROLE=roles/container.admin # container.admin is the role needed for Kubernetes Engine Admin
394
- gcloud projects add-iam-policy-binding $PROJECT_ID --member user:$CURRENT_GKE_USER --role=$ROLE
395
- ```
396
-
397
- 3) Check the permissions are correct for the users.
398
-
399
- Go to [iam-admin](https://console.cloud.google.com/iam-admin/) or use gcloud cli:
400
-
401
- ```shell
402
- PROJECT_ID=my-project-id
403
- CURRENT_GKE_USER=$(gcloud config get account)
404
- gcloud projects get-iam-policy $PROJECT_ID --filter="bindings.members:$CURRENT_GKE_USER" --flatten="bindings[].members"
405
- ```
406
-
407
- 4) Confirm you have logged in locally with the correct user.
408
-
409
- ```shell
410
- gcloud auth login
411
- ```
412
-
413
- ### Roles needed based on permission errors:
414
-
415
- * `requires one of ["container.*"] permission(s)`
416
-
417
- Add [Kubernetes Engine Admin](https://cloud.google.com/iam/docs/understanding-roles#kubernetes-engine-roles) to your user.
418
-
419
- ## Reservation Troubleshooting:
420
-
421
- ### How to determine your reservation and its size / utilization:
422
-
423
- ```shell
424
- PROJECT_ID=my-project
425
- ZONE=us-east5-b
426
- RESERVATION=my-reservation-name
427
- # Find the reservations in your project
428
- gcloud beta compute reservations list --project=$PROJECT_ID
429
- # Find the tpu machine type and current utilization of a reservation.
430
- gcloud beta compute reservations describe $RESERVATION --project=$PROJECT_ID --zone=$ZONE
431
- ```
@@ -1,7 +0,0 @@
1
- xpk.py,sha256=kalMJL7f3QTAyzE9PpJBpdMW0i6rEkjwneCktGAxIsQ,81325
2
- xpk-0.2.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
3
- xpk-0.2.0.dist-info/METADATA,sha256=T_MRDWRQvAxcxPHGTmajKkIF0GgTyBf9GwnQKm6orIo,15544
4
- xpk-0.2.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
5
- xpk-0.2.0.dist-info/entry_points.txt,sha256=lhrMqkTA09DLePaqxSMyW2RCLUKs2X1c84baGhMev_k,33
6
- xpk-0.2.0.dist-info/top_level.txt,sha256=aDe4N0jicmuWExx_6w0TxWQJaEuPSs9BnLU-3aF1GLo,4
7
- xpk-0.2.0.dist-info/RECORD,,
File without changes