forked from machine-learning-exchange/katalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trusted-ai-pipeline.yaml
401 lines (401 loc) · 15 KB
/
trusted-ai-pipeline.yaml
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# Copyright 2021 The MLX Contributors
#
# SPDX-License-Identifier: Apache-2.0
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: launch-trusted-ai-pipeline
annotations:
tekton.dev/output_artifacts: '{"adversarial-robustness-evaluation": [{"key": "artifacts/$PIPELINERUN/adversarial-robustness-evaluation/metric_path.tgz",
"name": "adversarial-robustness-evaluation-metric_path", "path": "/tmp/outputs/metric_path/data"},
{"key": "artifacts/$PIPELINERUN/adversarial-robustness-evaluation/robust_status.tgz",
"name": "adversarial-robustness-evaluation-robust_status", "path": "/tmp/outputs/robust_status/data"}],
"model-fairness-check": [{"key": "artifacts/$PIPELINERUN/model-fairness-check/metric_path.tgz",
"name": "model-fairness-check-metric_path", "path": "/tmp/outputs/metric_path/data"}]}'
tekton.dev/input_artifacts: '{}'
tekton.dev/artifact_bucket: mlpipeline
tekton.dev/artifact_endpoint: minio-service.kubeflow:9000
tekton.dev/artifact_endpoint_scheme: http://
tekton.dev/artifact_items: '{"adversarial-robustness-evaluation": [["metric_path",
"$(results.metric-path.path)"], ["robust_status", "$(results.robust-status.path)"]],
"model-fairness-check": [["metric_path", "$(results.metric-path.path)"]], "trust-ai-train-step":
[]}'
sidecar.istio.io/inject: "false"
pipelines.kubeflow.org/big_data_passing_format: $(workspaces.$TASK_NAME.path)/artifacts/$ORIG_PR_NAME/$TASKRUN_NAME/$TASK_PARAM_NAME
pipelines.kubeflow.org/pipeline_spec: '{"description": "An example for trusted-ai
integration.", "inputs": [{"default": "anonymous", "name": "namespace", "optional":
true, "type": "String"}, {"default": "0.2", "name": "fgsm_attack_epsilon", "optional":
true, "type": "String"}, {"default": "PyTorchModel.py", "name": "model_class_file",
"optional": true, "type": "String"}, {"default": "ThreeLayerCNN", "name": "model_class_name",
"optional": true, "type": "String"}, {"default": "processed_data/X_test.npy",
"name": "feature_testset_path", "optional": true, "type": "String"}, {"default":
"processed_data/y_test.npy", "name": "label_testset_path", "optional": true,
"type": "String"}, {"default": "processed_data/p_test.npy", "name": "protected_label_testset_path",
"optional": true, "type": "String"}, {"default": "0.0", "name": "favorable_label",
"optional": true, "type": "String"}, {"default": "1.0", "name": "unfavorable_label",
"optional": true, "type": "String"}, {"default": "[{''race'': 0.0}]", "name":
"privileged_groups", "optional": true, "type": "String"}, {"default": "[{''race'':
4.0}]", "name": "unprivileged_groups", "optional": true, "type": "String"},
{"default": "torch.nn.CrossEntropyLoss()", "name": "loss_fn", "optional": true,
"type": "String"}, {"default": "torch.optim.Adam(model.parameters(), lr=0.001)",
"name": "optimizer", "optional": true, "type": "String"}, {"default": "(0, 1)",
"name": "clip_values", "optional": true, "type": "String"}, {"default": "2",
"name": "nb_classes", "optional": true, "type": "String"}, {"default": "(1,3,64,64)",
"name": "input_shape", "optional": true, "type": "String"}], "name": "Trusted AI Pipeline"}'
spec:
params:
- name: clip_values
value: (0, 1)
- name: favorable_label
value: '0.0'
- name: feature_testset_path
value: processed_data/X_test.npy
- name: fgsm_attack_epsilon
value: '0.2'
- name: input_shape
value: (1,3,64,64)
- name: label_testset_path
value: processed_data/y_test.npy
- name: loss_fn
value: torch.nn.CrossEntropyLoss()
- name: model_class_file
value: PyTorchModel.py
- name: model_class_name
value: ThreeLayerCNN
- name: namespace
value: anonymous
- name: nb_classes
value: '2'
- name: optimizer
value: torch.optim.Adam(model.parameters(), lr=0.001)
- name: privileged_groups
value: '[{''race'': 0.0}]'
- name: protected_label_testset_path
value: processed_data/p_test.npy
- name: unfavorable_label
value: '1.0'
- name: unprivileged_groups
value: '[{''race'': 4.0}]'
pipelineSpec:
params:
- name: clip_values
default: (0, 1)
- name: favorable_label
default: '0.0'
- name: feature_testset_path
default: processed_data/X_test.npy
- name: fgsm_attack_epsilon
default: '0.2'
- name: input_shape
default: (1,3,64,64)
- name: label_testset_path
default: processed_data/y_test.npy
- name: loss_fn
default: torch.nn.CrossEntropyLoss()
- name: model_class_file
default: PyTorchModel.py
- name: model_class_name
default: ThreeLayerCNN
- name: namespace
default: anonymous
- name: nb_classes
default: '2'
- name: optimizer
default: torch.optim.Adam(model.parameters(), lr=0.001)
- name: privileged_groups
default: '[{''race'': 0.0}]'
- name: protected_label_testset_path
default: processed_data/p_test.npy
- name: unfavorable_label
default: '1.0'
- name: unprivileged_groups
default: '[{''race'': 4.0}]'
tasks:
- name: trust-ai-train-step
params:
- name: action
value: create
- name: output
value: |
- name: manifest
valueFrom: '{}'
- name: name
valueFrom: '{.metadata.name}'
- name: success-condition
value: status.succeeded > 0
- name: failure-condition
value: status.failed > 0
- name: set-ownerreference
value: "false"
- name: namespace
value: $(params.namespace)
taskSpec:
params:
- description: Action on the resource
name: action
type: string
- default: strategic
description: Merge strategy when using action patch
name: merge-strategy
type: string
- default: ''
description: An express to retrieval data from resource.
name: output
type: string
- default: ''
description: A label selector express to decide if the action on resource
is success.
name: success-condition
type: string
- default: ''
description: A label selector express to decide if the action on resource
is failure.
name: failure-condition
type: string
- default: aipipeline/kubectl-wrapper:1.1.1
description: Kubectl wrapper image
name: image
type: string
- default: "false"
description: Enable set owner reference for created resource.
name: set-ownerreference
type: string
- name: namespace
steps:
- args:
- --action=$(params.action)
- --merge-strategy=$(params.merge-strategy)
- |
--manifest=apiVersion: batch/v1
kind: Job
metadata:
name: trusted-ai-train-job-$(PIPELINERUN)
namespace: $(inputs.params.namespace)
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: 'false'
spec:
containers:
- command:
- python
- -u
- gender_classification_training.py
- --data_bucket
- mlpipeline
- --result_bucket
- mlpipeline
env:
- name: S3_ENDPOINT
value: minio-service.kubeflow:9000
image: aipipeline/gender-classification:latest
name: classification-training
restartPolicy: Never
ttlSecondsAfterFinished: 100
- --output=$(params.output)
- --success-condition=$(params.success-condition)
- --failure-condition=$(params.failure-condition)
- --set-ownerreference=$(params.set-ownerreference)
image: $(params.image)
name: main
resources: {}
env:
- name: PIPELINERUN
valueFrom:
fieldRef:
fieldPath: metadata.labels['tekton.dev/pipelineRun']
results:
- name: manifest
description: '{}'
- name: name
description: '{.metadata.name}'
metadata:
labels:
pipelines.kubeflow.org/pipelinename: ''
pipelines.kubeflow.org/generation: ''
pipelines.kubeflow.org/cache_enabled: "true"
annotations:
tekton.dev/template: ''
timeout: 525600m
- name: model-fairness-check
params:
- name: favorable_label
value: $(params.favorable_label)
- name: feature_testset_path
value: $(params.feature_testset_path)
- name: label_testset_path
value: $(params.label_testset_path)
- name: model_class_file
value: $(params.model_class_file)
- name: model_class_name
value: $(params.model_class_name)
- name: privileged_groups
value: $(params.privileged_groups)
- name: protected_label_testset_path
value: $(params.protected_label_testset_path)
- name: unfavorable_label
value: $(params.unfavorable_label)
- name: unprivileged_groups
value: $(params.unprivileged_groups)
taskSpec:
steps:
- name: main
args:
- -u
- fairness_check.py
- --model_id
- training-example
- --model_class_file
- $(inputs.params.model_class_file)
- --model_class_name
- $(inputs.params.model_class_name)
- --feature_testset_path
- $(inputs.params.feature_testset_path)
- --label_testset_path
- $(inputs.params.label_testset_path)
- --protected_label_testset_path
- $(inputs.params.protected_label_testset_path)
- --favorable_label
- $(inputs.params.favorable_label)
- --unfavorable_label
- $(inputs.params.unfavorable_label)
- --privileged_groups
- $(inputs.params.privileged_groups)
- --unprivileged_groups
- $(inputs.params.unprivileged_groups)
- --metric_path
- $(results.metric-path.path)
- --data_bucket_name
- mlpipeline
- --result_bucket_name
- mlpipeline
command:
- python
image: aipipeline/bias-detector:pytorch
imagePullPolicy: Always
params:
- name: favorable_label
- name: feature_testset_path
- name: label_testset_path
- name: model_class_file
- name: model_class_name
- name: privileged_groups
- name: protected_label_testset_path
- name: unfavorable_label
- name: unprivileged_groups
results:
- name: metric-path
description: /tmp/outputs/metric_path/data
metadata:
labels:
pipelines.kubeflow.org/pipelinename: ''
pipelines.kubeflow.org/generation: ''
pipelines.kubeflow.org/cache_enabled: "true"
annotations:
platform: OpenSource
pipelines.kubeflow.org/component_spec_digest: '{"name": "Model Fairness
Check", "outputs": [{"description": "Path for fairness check output",
"name": "metric_path", "type": "String"}], "version": "Model Fairness
Check@sha256=1706e2527a14053300b36c47885e9ee211eea65930a98ca0f80dde88b675a034"}'
tekton.dev/template: ''
runAfter:
- trust-ai-train-step
timeout: 525600m
- name: adversarial-robustness-evaluation
params:
- name: clip_values
value: $(params.clip_values)
- name: feature_testset_path
value: $(params.feature_testset_path)
- name: fgsm_attack_epsilon
value: $(params.fgsm_attack_epsilon)
- name: input_shape
value: $(params.input_shape)
- name: label_testset_path
value: $(params.label_testset_path)
- name: loss_fn
value: $(params.loss_fn)
- name: model_class_file
value: $(params.model_class_file)
- name: model_class_name
value: $(params.model_class_name)
- name: nb_classes
value: $(params.nb_classes)
- name: optimizer
value: $(params.optimizer)
taskSpec:
steps:
- name: main
args:
- -u
- robustness_evaluation_fgsm_pytorch.py
- --model_id
- training-example
- --model_class_file
- $(inputs.params.model_class_file)
- --model_class_name
- $(inputs.params.model_class_name)
- --feature_testset_path
- $(inputs.params.feature_testset_path)
- --label_testset_path
- $(inputs.params.label_testset_path)
- --epsilon
- $(inputs.params.fgsm_attack_epsilon)
- --loss_fn
- $(inputs.params.loss_fn)
- --optimizer
- $(inputs.params.optimizer)
- --clip_values
- $(inputs.params.clip_values)
- --nb_classes
- $(inputs.params.nb_classes)
- --input_shape
- $(inputs.params.input_shape)
- --metric_path
- $(results.metric-path.path)
- --robust_status
- $(results.robust-status.path)
- --data_bucket_name
- mlpipeline
- --result_bucket_name
- mlpipeline
- --adversarial_accuracy_threshold
- '0.2'
command:
- python
image: aipipeline/robustness-evaluation:pytorch
imagePullPolicy: Always
params:
- name: clip_values
- name: feature_testset_path
- name: fgsm_attack_epsilon
- name: input_shape
- name: label_testset_path
- name: loss_fn
- name: model_class_file
- name: model_class_name
- name: nb_classes
- name: optimizer
results:
- name: metric-path
description: /tmp/outputs/metric_path/data
- name: robust-status
description: /tmp/outputs/robust_status/data
metadata:
labels:
pipelines.kubeflow.org/pipelinename: ''
pipelines.kubeflow.org/generation: ''
pipelines.kubeflow.org/cache_enabled: "true"
annotations:
platform: OpenSource
pipelines.kubeflow.org/component_spec_digest: '{"name": "Adversarial Robustness
Evaluation", "outputs": [{"description": "Path for robustness check
output", "name": "metric_path", "type": "String"}, {"description": "Path
for robustness status output", "name": "robust_status", "type": "String"}],
"version": "Adversarial Robustness Evaluation@sha256=28e3f0baf616b9f2b32085a66efbcb3b462db8ccb2d509c024b87ab0d3337fe1"}'
tekton.dev/template: ''
runAfter:
- trust-ai-train-step
timeout: 525600m
timeout: 525600m