File size: 7,885 Bytes
76d9c4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
---
title: Sweep
version: EN
---

### read_sweep
```python
vessl.read_sweep(
   sweep_name: str, **kwargs
)
```
Read sweep in the default organization/project. If you want to
override the default organization/project, then pass `organization_name` or
`project_name` as `**kwargs`.

**Args**
* `sweep_name` (str) : Sweep name.

**Example**
```python
vessl.read_sweep(
    sweep_name="pitch-lord",
)
```

----

## list_sweeps
```python
vessl.list_sweeps(
   **kwargs
)
```
List sweeps in the default organization/project. If you want to
override the default organization/project, then pass `organization_name` or
`project_name` as `**kwargs`.

**Example**
```python
vessl.list_sweeps()
```

----

## create_sweep
```python
vessl.create_sweep(
   name: str, algorithm: str, parameters: List[SweepParameter], cluster_name: str,
   command: str, objective: SweepObjective = None, max_experiment_count: int = None,
   parallel_experiment_count: int = None, max_failed_experiment_count: int = None,
   resource_spec_name: str = None, processor_type: str = None, cpu_limit: float = None,
   memory_limit: str = None, gpu_type: str = 'Any', gpu_limit: int = None,
   image_url: str = None, *, early_stopping_name: str = None,
   early_stopping_settings: List[Tuple[str, str]] = None, message: str = None,
   hyperparameters: List[Tuple[str, str]] = None, dataset_mounts: List[str] = None,
   git_ref_mounts: List[str] = None, git_diff_mount: str = None,
   archive_file_mount: str = None, object_storage_mount: str = None,
   root_volume_size: str = None, working_dir: str = None,
   output_dir: str = MOUNT_PATH_OUTPUT, **kwargs
)
```
Create sweep in the default organization/project. If you want to
override the default organization/project, then pass `organization_name` or
`project_name` as `**kwargs`. Pass `use_git_diff=True` if you want to run
experiment with uncommitted changes and pass `use_git_diff_untracked=True`
if you want to run untracked changes(only valid if `use_git_diff` is set).

**Args**
* `name` (str) : Name
* `objective` (Optional[vessl.SweepObjective]) : A sweep objective including goal, metric,
    and type.
* `max_experiment_count` (Optional[int]) : The maximum number of experiments to run.
    Required unless grid search.
* `parallel_experiment_count` (Optional[int]) : The number of experiments to run in
    parallel. Default: 1.
* `max_failed_experiment_count` (Optional[int]) : The maximum number of experiments to
    allow to fail. Default: 1.
* `algorithm` (str) : Parameter suggestion algorithm. `grid`, `random`, or
    `bayesian`.
* `parameters` (List[vessl.SweepParameter]) : A list of parameters to search.
    - SweepParameter
        - name(str): The names of hyperparameters to search.
        - type(str): `int`, `double`, `categorical`.
        - range(SweepParameterRange): Search range.
            - list(List[str]): A list of values to try.
                If `list` is given, `min`, `max` and `step` will be ignored.
            - min(str): The minimum value of the search range (inclusive).
            - max(str): The maximum value of the search range (inclusive).
            - step(Optional[str]): If provided, the values are limited to min + n*step.
* `cluster_name` (str) : Cluster name(must be specified before other options).
* `command` (str) : Start command to execute in experiment container.
* `resource_spec_name` (str) :  Resource type to run an experiment (for
    managed cluster only). Defaults to None.
* `cpu_limit` (float) : Number of vCPUs (for custom cluster only). Defaults to
    None.
* `memory_limit` (str) : Memory limit (for custom cluster only).
    Defaults to None. Example: "100Gi", "500Mi"
* `gpu_type` (str) : GPU type(name) (for custom cluster only). Defaults to "Any".
processor_type(str) cpu or gpu (for custom cluster only). Defaults to
    None.
**Example**
* `gpu_limit` (int) : Number of GPU cores (for custom cluster only). Defaults
    to None.
* `image_url` (str) : Kernel docker image URL. Defaults to None.
* `early_stopping_name` (str) : Early stopping algorithm name. Defaults to
    None.
* `early_stopping_settings` (List[Tuple[str, str]]) : Early stopping algorithm
    settings. Defaults to None.
* `message` (str) : Message. Defaults to None.
* `hyperparameters` (List[str]) : A list of fixed hyperparameters. Defaults to None.
* `dataset_mounts` (List[str]) : A list of dataset mounts. Defaults to None.
* `git_ref_mounts` (List[str]) : A list of git repository mounts. Defaults to
    None.
* `git_diff_mount` (str) : Git diff mounts. Defaults to None.
* `archive_file_mount` (str) : Local archive file mounts. Defaults to None.
* `object_storage_mount` (str) : Object storage mounts. Defaults to None.
* `root_volume_size` (str) : Root volume size. Defaults to None.
* `working_dir` (str) : Working directory path. Defaults to None.
* `output_dir` (str) : Output directory path. Defaults to "/output/".

**Example**
```python
sweep_objective = vessl.SweepObjective(
    type="maximize",
    goal="0.99",
    metric="val_accuracy",
)

parameters = [
    vessl.SweepParameter(
        name="optimizer",
        type="categorical",
        range=vessl.SweepParameterRange(
            list=["adam", "sgd", "adadelta"]
        )
    ),
    vessl.SweepParameter(
        name="batch_size",
        type="int",
        range=vessl.SweepParameterRange(
            max="256",
            min="64",
            step="8",
        )
    )
]

# Custom Cluster
vessl.create_sweep(
    name="example-sweep-name",
    objective=sweep_objective,
    max_experiment_count=4,
    parallel_experiment_count=2,
    max_failed_experiment_count=2,
    algorithm="random",
    parameters=parameters,
    dataset_mounts=["/input:mnist"],
    cluster_name="dgx-cluster",
    processor_type="gpu",
    gpu_type="NVIDIA-A100-SXM4-80GB",
    gpu_limit=2,
    cpu_limit=30,
    memory_limit="100Gi",
    kernel_image_url="public.ecr.aws/vessl/kernels:py36.full-cpu",
    start_command="pip install requirements.txt && python main.py",
)

# VESSL-Managed Cluster
vessl.create_sweep(
    name="example-sweep-name",
    objective=sweep_objective,
    max_experiment_count=4,
    parallel_experiment_count=2,
    max_failed_experiment_count=2,
    algorithm="random",
    parameters=parameters,
    dataset_mounts=["/input:mnist"],
    cluster_name="aws-apne2",
    kernel_resource_spec_name="v1.cpu-4.mem-13",
    kernel_image_url="public.ecr.aws/vessl/kernels:py36.full-cpu",
    start_command="pip install requirements.txt && python main.py",
)
```

----

## terminate_sweep
```python
vessl.terminate_sweep(
   sweep_name: str, **kwargs
)
```
Terminate sweep in the default organization/project. If you want to
override the default organization/project, then pass `organization_name` or
`project_name` as `**kwargs`.

**Args**
* `sweep_name` (str) : Sweep name.

**Example**
```python
vessl.terminate_sweep(
    sweep_name="pitch-lord",
)
```

----

## list_sweep_logs
```python
vessl.list_sweep_logs(
   sweep_name: str, tail: int = 200, **kwargs
)
```
List sweep logs in the default organization/project. If you want to
override the default organization/project, then pass `organization_name` or
`project_name` as `**kwargs`.

**Args**
* `sweep_name` (str) : Sweep name.
* `tail` (int) : The number of lines to display from the end. Display all if
    -1. Defaults to 200.

**Example**
```python
vessl.list_sweep_logs(
    sweep_name="pitch-lord",
)
```

----

## get_best_sweep_experiment
```python
vessl.get_best_sweep_experiment(
   sweep_name: str, **kwargs
)
```
Read sweep and return the best experiment info in the default
organization/project. If you want to override the default
organization/project, then pass `organization_name` or `project_name` as
`**kwargs`.

**Args**
* `sweep_name` (str) : Sweep name.

**Example**
```python
vessl.get_best_sweep_experiment(
    sweep_name="pitch-lord",
)
```