-
Notifications
You must be signed in to change notification settings - Fork 24
/
pipeline.yaml
2374 lines (2323 loc) · 124 KB
/
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# PIPELINE DEFINITION
# Name: instructlab
# Description: InstructLab pipeline
# Inputs:
# final_eval_batch_size: str [Default: 'auto']
# final_eval_few_shots: int [Default: 5.0]
# final_eval_max_workers: str [Default: 'auto']
# final_eval_merge_system_user_message: bool [Default: False]
# k8s_storage_class_name: str [Default: 'standard']
# mt_bench_max_workers: str [Default: 'auto']
# mt_bench_merge_system_user_message: bool [Default: False]
# sdg_base_model: str [Default: 's3://<BUCKET>/<PATH_TO_MODEL>']
# sdg_max_batch_len: int [Default: 5000.0]
# sdg_pipeline: str [Default: 'full']
# sdg_repo_branch: str
# sdg_repo_pr: int
# sdg_repo_url: str [Default: 'https://github.com/instructlab/taxonomy.git']
# sdg_sample_size: float [Default: 1.0]
# sdg_scale_factor: int [Default: 30.0]
# train_effective_batch_size_phase_1: int [Default: 128.0]
# train_effective_batch_size_phase_2: int [Default: 3840.0]
# train_learning_rate_phase_1: float [Default: 2e-05]
# train_learning_rate_phase_2: float [Default: 6e-06]
# train_max_batch_len: int [Default: 5000.0]
# train_nnodes: int [Default: 2.0]
# train_nproc_per_node: int [Default: 2.0]
# train_num_epochs_phase_1: int [Default: 7.0]
# train_num_epochs_phase_2: int [Default: 10.0]
# train_num_warmup_steps_phase_1: int [Default: 1000.0]
# train_num_warmup_steps_phase_2: int [Default: 1000.0]
# train_save_samples: int [Default: 250000.0]
# train_seed: int [Default: 42.0]
components:
comp-createpvc:
executorLabel: exec-createpvc
inputDefinitions:
parameters:
access_modes:
description: 'AccessModes to request for the provisioned PVC. May
be one or more of ``''ReadWriteOnce''``, ``''ReadOnlyMany''``, ``''ReadWriteMany''``,
or
``''ReadWriteOncePod''``. Corresponds to `PersistentVolumeClaim.spec.accessModes
<https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes>`_.'
parameterType: LIST
annotations:
description: Annotations for the PVC's metadata. Corresponds to `PersistentVolumeClaim.metadata.annotations
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
isOptional: true
parameterType: STRUCT
pvc_name:
description: 'Name of the PVC. Corresponds to `PersistentVolumeClaim.metadata.name
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
Only one of ``pvc_name`` and ``pvc_name_suffix`` can
be provided.'
isOptional: true
parameterType: STRING
pvc_name_suffix:
description: 'Prefix to use for a dynamically generated name, which
will take the form ``<argo-workflow-name>-<pvc_name_suffix>``. Only one
of ``pvc_name`` and ``pvc_name_suffix`` can be provided.'
isOptional: true
parameterType: STRING
size:
description: The size of storage requested by the PVC that will be provisioned.
For example, ``'5Gi'``. Corresponds to `PersistentVolumeClaim.spec.resources.requests.storage
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.
parameterType: STRING
storage_class_name:
defaultValue: ''
description: 'Name of StorageClass from which to provision the PV
to back the PVC. ``None`` indicates to use the cluster''s default
storage_class_name. Set to ``''''`` for a statically specified PVC.'
isOptional: true
parameterType: STRING
volume_name:
description: 'Pre-existing PersistentVolume that should back the
provisioned PersistentVolumeClaim. Used for statically
specified PV only. Corresponds to `PersistentVolumeClaim.spec.volumeName
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.'
isOptional: true
parameterType: STRING
outputDefinitions:
parameters:
name:
parameterType: STRING
comp-createpvc-2:
executorLabel: exec-createpvc-2
inputDefinitions:
parameters:
access_modes:
description: 'AccessModes to request for the provisioned PVC. May
be one or more of ``''ReadWriteOnce''``, ``''ReadOnlyMany''``, ``''ReadWriteMany''``,
or
``''ReadWriteOncePod''``. Corresponds to `PersistentVolumeClaim.spec.accessModes
<https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes>`_.'
parameterType: LIST
annotations:
description: Annotations for the PVC's metadata. Corresponds to `PersistentVolumeClaim.metadata.annotations
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
isOptional: true
parameterType: STRUCT
pvc_name:
description: 'Name of the PVC. Corresponds to `PersistentVolumeClaim.metadata.name
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
Only one of ``pvc_name`` and ``pvc_name_suffix`` can
be provided.'
isOptional: true
parameterType: STRING
pvc_name_suffix:
description: 'Prefix to use for a dynamically generated name, which
will take the form ``<argo-workflow-name>-<pvc_name_suffix>``. Only one
of ``pvc_name`` and ``pvc_name_suffix`` can be provided.'
isOptional: true
parameterType: STRING
size:
description: The size of storage requested by the PVC that will be provisioned.
For example, ``'5Gi'``. Corresponds to `PersistentVolumeClaim.spec.resources.requests.storage
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.
parameterType: STRING
storage_class_name:
defaultValue: ''
description: 'Name of StorageClass from which to provision the PV
to back the PVC. ``None`` indicates to use the cluster''s default
storage_class_name. Set to ``''''`` for a statically specified PVC.'
isOptional: true
parameterType: STRING
volume_name:
description: 'Pre-existing PersistentVolume that should back the
provisioned PersistentVolumeClaim. Used for statically
specified PV only. Corresponds to `PersistentVolumeClaim.spec.volumeName
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.'
isOptional: true
parameterType: STRING
outputDefinitions:
parameters:
name:
parameterType: STRING
comp-createpvc-3:
executorLabel: exec-createpvc-3
inputDefinitions:
parameters:
access_modes:
description: 'AccessModes to request for the provisioned PVC. May
be one or more of ``''ReadWriteOnce''``, ``''ReadOnlyMany''``, ``''ReadWriteMany''``,
or
``''ReadWriteOncePod''``. Corresponds to `PersistentVolumeClaim.spec.accessModes
<https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes>`_.'
parameterType: LIST
annotations:
description: Annotations for the PVC's metadata. Corresponds to `PersistentVolumeClaim.metadata.annotations
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
isOptional: true
parameterType: STRUCT
pvc_name:
description: 'Name of the PVC. Corresponds to `PersistentVolumeClaim.metadata.name
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaim>`_.
Only one of ``pvc_name`` and ``pvc_name_suffix`` can
be provided.'
isOptional: true
parameterType: STRING
pvc_name_suffix:
description: 'Prefix to use for a dynamically generated name, which
will take the form ``<argo-workflow-name>-<pvc_name_suffix>``. Only one
of ``pvc_name`` and ``pvc_name_suffix`` can be provided.'
isOptional: true
parameterType: STRING
size:
description: The size of storage requested by the PVC that will be provisioned.
For example, ``'5Gi'``. Corresponds to `PersistentVolumeClaim.spec.resources.requests.storage
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.
parameterType: STRING
storage_class_name:
defaultValue: ''
description: 'Name of StorageClass from which to provision the PV
to back the PVC. ``None`` indicates to use the cluster''s default
storage_class_name. Set to ``''''`` for a statically specified PVC.'
isOptional: true
parameterType: STRING
volume_name:
description: 'Pre-existing PersistentVolume that should back the
provisioned PersistentVolumeClaim. Used for statically
specified PV only. Corresponds to `PersistentVolumeClaim.spec.volumeName
<https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#PersistentVolumeClaimSpec>`_.'
isOptional: true
parameterType: STRING
outputDefinitions:
parameters:
name:
parameterType: STRING
comp-data-processing-op:
executorLabel: exec-data-processing-op
inputDefinitions:
parameters:
knowledge_path:
defaultValue: /data/knowledge
isOptional: true
parameterType: STRING
max_batch_len:
defaultValue: 20000.0
isOptional: true
parameterType: NUMBER_INTEGER
max_seq_len:
defaultValue: 4096.0
isOptional: true
parameterType: NUMBER_INTEGER
model_path:
defaultValue: /model
isOptional: true
parameterType: STRING
sdg_path:
defaultValue: /data/sdg
isOptional: true
parameterType: STRING
skills_path:
defaultValue: /data/skills
isOptional: true
parameterType: STRING
comp-deletepvc:
executorLabel: exec-deletepvc
inputDefinitions:
parameters:
pvc_name:
description: Name of the PVC to delete. Supports passing a runtime-generated
name, such as a name provided by ``kubernetes.CreatePvcOp().outputs['name']``.
parameterType: STRING
comp-deletepvc-2:
executorLabel: exec-deletepvc-2
inputDefinitions:
parameters:
pvc_name:
description: Name of the PVC to delete. Supports passing a runtime-generated
name, such as a name provided by ``kubernetes.CreatePvcOp().outputs['name']``.
parameterType: STRING
comp-deletepvc-3:
executorLabel: exec-deletepvc-3
inputDefinitions:
parameters:
pvc_name:
description: Name of the PVC to delete. Supports passing a runtime-generated
name, such as a name provided by ``kubernetes.CreatePvcOp().outputs['name']``.
parameterType: STRING
comp-git-clone-op:
executorLabel: exec-git-clone-op
inputDefinitions:
parameters:
repo_branch:
parameterType: STRING
repo_pr:
parameterType: NUMBER_INTEGER
repo_url:
parameterType: STRING
taxonomy_path:
defaultValue: /data/taxonomy
isOptional: true
parameterType: STRING
comp-importer:
executorLabel: exec-importer
inputDefinitions:
parameters:
uri:
parameterType: STRING
outputDefinitions:
artifacts:
artifact:
artifactType:
schemaTitle: system.Model
schemaVersion: 0.0.1
comp-knowledge-processed-data-to-artifact-op:
executorLabel: exec-knowledge-processed-data-to-artifact-op
inputDefinitions:
parameters:
pvc_path:
defaultValue: /data/knowledge
isOptional: true
parameterType: STRING
outputDefinitions:
artifacts:
knowledge_processed_data:
artifactType:
schemaTitle: system.Dataset
schemaVersion: 0.0.1
comp-model-to-pvc-op:
executorLabel: exec-model-to-pvc-op
inputDefinitions:
artifacts:
model:
artifactType:
schemaTitle: system.Model
schemaVersion: 0.0.1
parameters:
pvc_path:
defaultValue: /model
isOptional: true
parameterType: STRING
comp-pvc-to-model-op:
executorLabel: exec-pvc-to-model-op
inputDefinitions:
parameters:
pvc_path:
parameterType: STRING
outputDefinitions:
artifacts:
model:
artifactType:
schemaTitle: system.Model
schemaVersion: 0.0.1
comp-pvc-to-mt-bench-op:
executorLabel: exec-pvc-to-mt-bench-op
inputDefinitions:
parameters:
pvc_path:
parameterType: STRING
outputDefinitions:
artifacts:
mt_bench_output:
artifactType:
schemaTitle: system.Artifact
schemaVersion: 0.0.1
comp-pytorchjob-manifest-op:
executorLabel: exec-pytorchjob-manifest-op
inputDefinitions:
parameters:
effective_batch_size:
defaultValue: 3840.0
isOptional: true
parameterType: NUMBER_INTEGER
input_pvc_name:
parameterType: STRING
learning_rate:
defaultValue: 0.0001
isOptional: true
parameterType: NUMBER_DOUBLE
max_batch_len:
defaultValue: 20000.0
isOptional: true
parameterType: NUMBER_INTEGER
model_pvc_name:
parameterType: STRING
name_suffix:
parameterType: STRING
nnodes:
defaultValue: 2.0
isOptional: true
parameterType: NUMBER_INTEGER
nproc_per_node:
defaultValue: 3.0
isOptional: true
parameterType: NUMBER_INTEGER
num_epochs:
defaultValue: 2.0
isOptional: true
parameterType: NUMBER_INTEGER
num_warmup_steps:
defaultValue: 800.0
isOptional: true
parameterType: NUMBER_INTEGER
output_pvc_name:
parameterType: STRING
phase_num:
parameterType: NUMBER_INTEGER
save_samples:
defaultValue: 0.0
isOptional: true
parameterType: NUMBER_INTEGER
seed:
defaultValue: 42.0
isOptional: true
parameterType: NUMBER_INTEGER
comp-pytorchjob-manifest-op-2:
executorLabel: exec-pytorchjob-manifest-op-2
inputDefinitions:
parameters:
effective_batch_size:
defaultValue: 3840.0
isOptional: true
parameterType: NUMBER_INTEGER
input_pvc_name:
parameterType: STRING
learning_rate:
defaultValue: 0.0001
isOptional: true
parameterType: NUMBER_DOUBLE
max_batch_len:
defaultValue: 20000.0
isOptional: true
parameterType: NUMBER_INTEGER
model_pvc_name:
parameterType: STRING
name_suffix:
parameterType: STRING
nnodes:
defaultValue: 2.0
isOptional: true
parameterType: NUMBER_INTEGER
nproc_per_node:
defaultValue: 3.0
isOptional: true
parameterType: NUMBER_INTEGER
num_epochs:
defaultValue: 2.0
isOptional: true
parameterType: NUMBER_INTEGER
num_warmup_steps:
defaultValue: 800.0
isOptional: true
parameterType: NUMBER_INTEGER
output_pvc_name:
parameterType: STRING
phase_num:
parameterType: NUMBER_INTEGER
save_samples:
defaultValue: 0.0
isOptional: true
parameterType: NUMBER_INTEGER
seed:
defaultValue: 42.0
isOptional: true
parameterType: NUMBER_INTEGER
comp-run-final-eval-op:
executorLabel: exec-run-final-eval-op
inputDefinitions:
parameters:
base_branch:
parameterType: STRING
base_model_dir:
parameterType: STRING
batch_size:
parameterType: STRING
candidate_branch:
parameterType: STRING
candidate_model:
isOptional: true
parameterType: STRING
few_shots:
parameterType: NUMBER_INTEGER
max_workers:
parameterType: STRING
merge_system_user_message:
parameterType: BOOLEAN
sdg_path:
defaultValue: /input/sdg
isOptional: true
parameterType: STRING
taxonomy_path:
defaultValue: /input/taxonomy
isOptional: true
parameterType: STRING
outputDefinitions:
artifacts:
mmlu_branch_output:
artifactType:
schemaTitle: system.Artifact
schemaVersion: 0.0.1
mt_bench_branch_output:
artifactType:
schemaTitle: system.Artifact
schemaVersion: 0.0.1
comp-run-mt-bench-op:
executorLabel: exec-run-mt-bench-op
inputDefinitions:
parameters:
best_score_file:
isOptional: true
parameterType: STRING
max_workers:
parameterType: STRING
merge_system_user_message:
parameterType: BOOLEAN
models_folder:
parameterType: STRING
output_path:
defaultValue: /output/mt_bench_data.json
isOptional: true
parameterType: STRING
outputDefinitions:
parameters:
best_model:
parameterType: STRING
best_score:
parameterType: NUMBER_DOUBLE
comp-sdg-op:
executorLabel: exec-sdg-op
inputDefinitions:
parameters:
num_instructions_to_generate:
parameterType: NUMBER_INTEGER
pipeline:
parameterType: STRING
repo_branch:
parameterType: STRING
repo_pr:
parameterType: NUMBER_INTEGER
sdg_path:
defaultValue: /data/sdg
isOptional: true
parameterType: STRING
sdg_sampling_size:
defaultValue: 1.0
isOptional: true
parameterType: NUMBER_DOUBLE
taxonomy_path:
defaultValue: /data/taxonomy
isOptional: true
parameterType: STRING
comp-sdg-to-artifact-op:
executorLabel: exec-sdg-to-artifact-op
inputDefinitions:
parameters:
pvc_path:
defaultValue: /data/sdg
isOptional: true
parameterType: STRING
outputDefinitions:
artifacts:
sdg:
artifactType:
schemaTitle: system.Dataset
schemaVersion: 0.0.1
comp-skills-processed-data-to-artifact-op:
executorLabel: exec-skills-processed-data-to-artifact-op
inputDefinitions:
parameters:
pvc_path:
defaultValue: /data/skills
isOptional: true
parameterType: STRING
outputDefinitions:
artifacts:
skills_processed_data:
artifactType:
schemaTitle: system.Dataset
schemaVersion: 0.0.1
comp-taxonomy-to-artifact-op:
executorLabel: exec-taxonomy-to-artifact-op
inputDefinitions:
parameters:
pvc_path:
defaultValue: /data/taxonomy
isOptional: true
parameterType: STRING
outputDefinitions:
artifacts:
taxonomy:
artifactType:
schemaTitle: system.Dataset
schemaVersion: 0.0.1
deploymentSpec:
executors:
exec-createpvc:
container:
image: argostub/createpvc
exec-createpvc-2:
container:
image: argostub/createpvc
exec-createpvc-3:
container:
image: argostub/createpvc
exec-data-processing-op:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- data_processing_op
command:
- sh
- -ec
- 'program_path=$(mktemp -d)
printf "%s" "$0" > "$program_path/ephemeral_component.py"
_KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"
'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef data_processing_op(\n model_path: str = \"/model\",\n sdg_path:\
\ str = \"/data/sdg\",\n skills_path: str = \"/data/skills\",\n knowledge_path:\
\ str = \"/data/knowledge\",\n max_seq_len: Optional[int] = 4096,\n \
\ max_batch_len: Optional[int] = 20000,\n):\n import os\n\n import\
\ instructlab.training.data_process as dp\n from instructlab.training\
\ import (\n DataProcessArgs,\n TrainingArgs,\n )\n\n \
\ # define training-specific arguments\n skill_training_args = TrainingArgs(\n\
\ # define data-specific arguments\n model_path=model_path,\n\
\ data_path=f\"{sdg_path}/skills_train_msgs*.jsonl\",\n data_output_dir=skills_path,\n\
\ # define model-trianing parameters\n max_seq_len=max_seq_len,\n\
\ max_batch_len=max_batch_len,\n # XXX(shanand): We don't\
\ need the following arguments\n # for data processing. Added them\
\ for now to avoid\n # Pydantic validation errors for TrainingArgs\n\
\ ckpt_output_dir=\"data/saved_checkpoints\",\n num_epochs=2,\n\
\ effective_batch_size=3840,\n save_samples=0,\n learning_rate=2e-6,\n\
\ warmup_steps=800,\n is_padding_free=True,\n )\n\n \
\ knowledge_training_args = TrainingArgs(\n # define data-specific\
\ arguments\n model_path=model_path,\n data_path=f\"{sdg_path}/knowledge_train_msgs*.jsonl\"\
,\n data_output_dir=knowledge_path,\n # define model-trianing\
\ parameters\n max_seq_len=max_seq_len,\n max_batch_len=max_batch_len,\n\
\ # XXX(shanand): We don't need the following arguments\n \
\ # for data processing. Added them for now to avoid\n # Pydantic\
\ validation errors for TrainingArgs\n ckpt_output_dir=\"data/saved_checkpoints\"\
,\n num_epochs=2,\n effective_batch_size=3840,\n save_samples=0,\n\
\ learning_rate=2e-6,\n warmup_steps=800,\n is_padding_free=True,\n\
\ )\n\n def data_processing(train_args: TrainingArgs) -> None:\n \
\ # early validation logic here\n if train_args.max_batch_len\
\ < train_args.max_seq_len:\n raise ValueError(\n \
\ f\"the 'max_batch_len' cannot be less than 'max_seq_len': {train_args.max_batch_len=}\
\ < {train_args.max_seq_len=}\"\n )\n\n # process\
\ the training data\n if not os.path.exists(train_args.data_output_dir):\n\
\ os.makedirs(train_args.data_output_dir, exist_ok=True)\n \
\ dp.main(\n DataProcessArgs(\n # XXX(osilkin):\
\ make a decision here, either:\n # 1. the CLI is fully\
\ responsible for managing where the data is written\n #\
\ 2. we never cache it and simply write it to a tmp file every time.\n\
\ #\n # An important reason for why #1 would\
\ be preferable is in the case of OpenShift/SELinux\n # where\
\ the user has a defined place for new temporary data to be written.\n \
\ data_output_path=train_args.data_output_dir,\n \
\ model_path=train_args.model_path,\n data_path=train_args.data_path,\n\
\ max_seq_len=train_args.max_seq_len,\n chat_tmpl_path=train_args.chat_tmpl_path,\n\
\ )\n )\n\n data_processing(train_args=skill_training_args)\n\
\ data_processing(train_args=knowledge_training_args)\n\n"
env:
- name: XDG_CACHE_HOME
value: /tmp
image: registry.stage.redhat.io/rhelai1/instructlab-nvidia-rhel9:1.3.1
exec-deletepvc:
container:
image: argostub/deletepvc
exec-deletepvc-2:
container:
image: argostub/deletepvc
exec-deletepvc-3:
container:
image: argostub/deletepvc
exec-git-clone-op:
container:
args:
- 'git clone {{$.inputs.parameters[''repo_url'']}} {{$.inputs.parameters[''taxonomy_path'']}}
&& cd {{$.inputs.parameters[''taxonomy_path'']}} && if [ -n "{{$.inputs.parameters[''repo_branch'']}}"
]; then git fetch origin {{$.inputs.parameters[''repo_branch'']}} && git
checkout {{$.inputs.parameters[''repo_branch'']}}; elif [ -n "{{$.inputs.parameters[''repo_pr'']}}"
] && [ {{$.inputs.parameters[''repo_pr'']}} -gt 0 ]; then git fetch origin
pull/{{$.inputs.parameters[''repo_pr'']}}/head:{{$.inputs.parameters[''repo_pr'']}}
&& git checkout {{$.inputs.parameters[''repo_pr'']}}; fi '
command:
- /bin/sh
- -c
image: registry.access.redhat.com/ubi9/toolbox
exec-importer:
importer:
artifactUri:
runtimeParameter: uri
typeSchema:
schemaTitle: system.Model
schemaVersion: 0.0.1
exec-knowledge-processed-data-to-artifact-op:
container:
args:
- cp -r {{$.inputs.parameters['pvc_path']}} {{$.outputs.artifacts['knowledge_processed_data'].path}}
command:
- /bin/sh
- -c
image: registry.access.redhat.com/ubi9/toolbox
exec-model-to-pvc-op:
container:
args:
- cp -r {{$.inputs.artifacts['model'].path}}/* {{$.inputs.parameters['pvc_path']}}
command:
- /bin/sh
- -c
image: registry.access.redhat.com/ubi9/toolbox
exec-pvc-to-model-op:
container:
args:
- cp -r {{$.inputs.parameters['pvc_path']}} {{$.outputs.artifacts['model'].path}}
command:
- /bin/sh
- -c
image: registry.access.redhat.com/ubi9/toolbox
exec-pvc-to-mt-bench-op:
container:
args:
- cp -r {{$.inputs.parameters['pvc_path']}} {{$.outputs.artifacts['mt_bench_output'].path}}
command:
- /bin/sh
- -c
image: registry.access.redhat.com/ubi9/toolbox
exec-pytorchjob-manifest-op:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- pytorchjob_manifest_op
command:
- sh
- -ec
- 'program_path=$(mktemp -d)
printf "%s" "$0" > "$program_path/ephemeral_component.py"
_KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"
'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef pytorchjob_manifest_op(\n model_pvc_name: str,\n input_pvc_name:\
\ str,\n output_pvc_name: str,\n name_suffix: str,\n # path_to_model:\
\ str,\n phase_num: int,\n nproc_per_node: int = 3,\n nnodes: int\
\ = 2,\n num_epochs: int = 2,\n effective_batch_size: int = 3840,\n\
\ learning_rate: float = 1e-4,\n num_warmup_steps: int = 800,\n \
\ save_samples: int = 0,\n max_batch_len: int = 20000,\n seed: int\
\ = 42,\n):\n import inspect\n import os\n import time\n\n import\
\ kubernetes\n import urllib3\n import yaml\n\n def list_phase1_final_model():\n\
\ model_dir = \"/output/phase_1/model/hf_format\"\n models\
\ = os.listdir(model_dir)\n newest_idx = max(\n (os.path.getmtime(f\"\
{model_dir}/{model}\"), i)\n for i, model in enumerate(models)\n\
\ )[-1]\n newest_model = models[newest_idx]\n return\
\ f\"{model_dir}/{newest_model}\"\n\n name = f\"train-phase-{phase_num}-{name_suffix.rstrip('-sdg')}\"\
\n\n if phase_num == 1:\n path_to_model = \"/input_model\"\n \
\ path_to_data = \"/input_data/knowledge/data.jsonl\"\n elif phase_num\
\ == 2:\n path_to_model = list_phase1_final_model()\n path_to_data\
\ = \"/input_data/skills/data.jsonl\"\n else:\n raise RuntimeError(f\"\
Unsupported value of {phase_num=}\")\n\n image = \"registry.stage.redhat.io/rhelai1/instructlab-nvidia-rhel9:1.3.1\"\
\n\n manifest = inspect.cleandoc(\n f\"\"\"\n apiVersion:\
\ kubeflow.org/v1\n kind: PyTorchJob\n metadata:\n \
\ name: {name}\n spec:\n nprocPerNode: \\\"{nproc_per_node}\\\
\"\n pytorchReplicaSpecs:\n Master:\n replicas:\
\ 1\n restartPolicy: OnFailure\n template:\n \
\ metadata:\n annotations:\n \
\ sidecar.istio.io/inject: 'false'\n spec:\n \
\ containers:\n - args:\n \
\ - |\n echo \"Running phase {phase_num}\"\
\n echo \"Using {path_to_model} model for training\"\
\n echo \"Using {path_to_data} data for training\"\
\n mkdir -p /output/phase_{phase_num}/model;\n\
\ mkdir -p /output/data;\n \
\ torchrun --nnodes {nnodes} \\\n --nproc_per_node\
\ {nproc_per_node} \\\n --node_rank \\$(RANK)\
\ \\\n --rdzv_endpoint \\$(MASTER_ADDR):\\\
$(MASTER_PORT) \\\n -m instructlab.training.main_ds\
\ \\\n --model_name_or_path={path_to_model}\
\ \\\n --data_path={path_to_data} \\\n \
\ --output_dir=/output/phase_{phase_num}/model\
\ \\\n --num_epochs={num_epochs} \\\n \
\ --effective_batch_size={effective_batch_size}\
\ \\\n --learning_rate={learning_rate} \\\n\
\ --num_warmup_steps={num_warmup_steps} \\\n\
\ --save_samples={save_samples} \\\n \
\ --log_level=INFO \\\n \
\ --max_batch_len={max_batch_len} \\\n \
\ --seed={seed} \\\n --cpu_offload_optimizer\
\ \\\n --cpu_offload_params_fsdp \\\n \
\ --distributed_training_framework fsdp \\\n \
\ --checkpoint_at_epoch\n \
\ command:\n - /bin/bash\n \
\ - '-c'\n - '--'\n image:\
\ {image}\n name: pytorch\n volumeMounts:\n\
\ - mountPath: /input_data\n \
\ name: input-data\n readOnly: true\n \
\ - mountPath: /input_model\n \
\ name: model\n readOnly: true\n \
\ - mountPath: /output\n name: output\n\
\ env:\n - name: NNODES\n \
\ value: \\\"{nnodes}\\\"\n \
\ - name: NPROC_PER_NODE\n value: \\\"{nproc_per_node}\\\
\"\n - name: XDG_CACHE_HOME\n \
\ value: /tmp\n - name: TRITON_CACHE_DIR\n\
\ value: /tmp\n - name:\
\ HF_HOME\n value: /tmp\n \
\ - name: TRANSFORMERS_CACHE\n value: /tmp\n\
\ resources:\n requests:\n \
\ \"nvidia.com/gpu\": {nproc_per_node}\n \
\ limits:\n \"nvidia.com/gpu\"\
: {nproc_per_node}\n volumes:\n - name:\
\ input-data\n persistentVolumeClaim:\n \
\ claimName: {input_pvc_name}\n - name: model\n\
\ persistentVolumeClaim:\n claimName:\
\ {model_pvc_name}\n - name: output\n \
\ persistentVolumeClaim:\n claimName: {output_pvc_name}\n\
\ Worker:\n replicas: {nnodes-1}\n \
\ restartPolicy: OnFailure\n template:\n metadata:\n\
\ annotations:\n sidecar.istio.io/inject:\
\ 'false'\n spec:\n containers:\n \
\ - args:\n - |\n \
\ echo \"Running phase {phase_num}\"\n echo\
\ \"Using {path_to_model} model for training\"\n \
\ echo \"Using {path_to_data} data for training\"\n \
\ mkdir -p /tmp/model;\n torchrun --nnodes\
\ {nnodes} \\\n --nproc_per_node {nproc_per_node}\
\ \\\n --node_rank \\$(RANK) \\\n \
\ --rdzv_endpoint \\$(MASTER_ADDR):\\$(MASTER_PORT) \\\n\
\ -m instructlab.training.main_ds \\\n \
\ --model_name_or_path={path_to_model} \\\n \
\ --data_path={path_to_data} \\\n \
\ --output_dir=/tmp/model \\\n --num_epochs={num_epochs}\
\ \\\n --effective_batch_size={effective_batch_size}\
\ \\\n --learning_rate={learning_rate} \\\n \
\ --num_warmup_steps={num_warmup_steps} \\\n \
\ --save_samples={save_samples} \\\n \
\ --log_level=INFO \\\n --max_batch_len={max_batch_len}\
\ \\\n --seed={seed} \\\n \
\ --cpu_offload_optimizer \\\n --cpu_offload_params_fsdp\
\ \\\n --distributed_training_framework fsdp\
\ \\\n --checkpoint_at_epoch\n \
\ command:\n - /bin/bash\n \
\ - '-c'\n - '--'\n \
\ image: {image}\n name: pytorch\n \
\ volumeMounts:\n - mountPath: /input_data\n\
\ name: input-data\n readOnly:\
\ true\n - mountPath: /input_model\n \
\ name: model\n readOnly: true\n \
\ - mountPath: /output\n \
\ name: output\n readOnly: true\n \
\ env:\n - name: NNODES\n \
\ value: \\\"{nnodes}\\\"\n - name: NPROC_PER_NODE\n\
\ value: \\\"{nproc_per_node}\\\"\n \
\ - name: XDG_CACHE_HOME\n value: /tmp\n\
\ - name: TRITON_CACHE_DIR\n \
\ value: /tmp\n - name: HF_HOME\n \
\ value: /tmp\n - name: TRANSFORMERS_CACHE\n\
\ value: /tmp\n resources:\n\
\ requests:\n \"nvidia.com/gpu\"\
: {nproc_per_node}\n limits:\n \
\ \"nvidia.com/gpu\": {nproc_per_node}\n volumes:\n\
\ - name: input-data\n persistentVolumeClaim:\n\
\ claimName: {input_pvc_name}\n \
\ - name: model\n persistentVolumeClaim:\n \
\ claimName: {model_pvc_name}\n - name:\
\ output\n persistentVolumeClaim:\n \
\ claimName: {output_pvc_name}\n \"\"\"\n )\n\n try:\n\
\ manifest_yaml = yaml.safe_load(manifest)\n except yaml.YAMLError\
\ as exc:\n raise RuntimeError(f\"Error parsing manifest: {exc}\"\
) from exc\n\n # Discover the namespace in which the pod is running\n\
\ with open(\n \"/var/run/secrets/kubernetes.io/serviceaccount/namespace\"\
, \"r\", encoding=\"utf-8\"\n ) as f:\n namespace = f.read().strip()\n\
\ print(f\"The pod is running in the namespace: {namespace}\")\n\n\
\ try:\n kubernetes.config.load_kube_config()\n print(\"\
Loaded kube config\")\n except kubernetes.config.ConfigException:\n \
\ print(\"Failed to load kube config. Trying in-cluster config\")\n\
\ kubernetes.config.load_incluster_config()\n\n api = kubernetes.client.CustomObjectsApi()\n\
\ try:\n api.create_namespaced_custom_object(\n group=\"\
kubeflow.org\",\n version=\"v1\",\n namespace=namespace,\n\
\ plural=\"pytorchjobs\",\n body=manifest_yaml,\n\
\ )\n except kubernetes.client.rest.ApiException as exc:\n \
\ if exc.status == 409:\n print(\n \"{} '{}/{}'\
\ already exists.\".format(\n manifest_yaml[\"kind\"\
],\n namespace,\n manifest_yaml[\"\
metadata\"][\"name\"],\n )\n )\n else:\n\
\ raise\n\n # Get the CR status and wait for it to be completed\n\
\ w = kubernetes.watch.Watch()\n exit_flag = False\n start_time\
\ = time.time()\n timeout_seconds = 24 * 60 * 60 # 24 hours\n\n while\
\ not exit_flag: # Keep the watch active\n if time.time() - start_time\
\ > timeout_seconds:\n raise RuntimeError(\n \"\
Timeout (24h) reached waiting for the PytorchJob to complete.\"\n \
\ )\n\n try:\n print(\"Watching for PytorchJob\"\
)\n for event in w.stream(\n api.list_namespaced_custom_object,\n\
\ group=\"kubeflow.org\",\n version=\"v1\"\
,\n namespace=namespace,\n plural=\"pytorchjobs\"\
,\n timeout_seconds=60, # Timeout after 1 minute\n \
\ ):\n pytorchjob_event = event[\"object\"]\n \
\ if (\n pytorchjob_event[\"metadata\"][\"\
name\"]\n != manifest_yaml[\"metadata\"][\"name\"]\n\
\ ):\n continue\n pytorchjob_name\
\ = pytorchjob_event[\"metadata\"][\"name\"]\n\n if (\n \
\ \"status\" not in pytorchjob_event\n \
\ or \"conditions\" not in pytorchjob_event[\"status\"]\n \
\ ):\n continue\n print(\n \
\ f\"PytorchJob: {pytorchjob_name} - {pytorchjob_event['status'].get('conditions',\
\ 'No conditions yet')}\"\n )\n for job_condition\
\ in reversed(pytorchjob_event[\"status\"][\"conditions\"]):\n \
\ if job_condition[\"type\"] == \"Succeeded\":\n \
\ print(\n f\"PytorchJob '{pytorchjob_name}'\
\ completed successfully: {job_condition['reason']}\"\n \
\ )\n print(f\"Training phase {phase_num}\
\ completed.\")\n w.stop()\n \
\ exit_flag = True\n # Break here to avoid going\
\ into other conditions, we are done\n break\n \
\ elif job_condition[\"type\"] == \"Failed\":\n \
\ print(\n f\"PytorchJob '{pytorchjob_name}'\
\ failed: {job_condition['reason']}\"\n )\n \
\ w.stop()\n raise RuntimeError(\"\
Job failed.\")\n except kubernetes.client.exceptions.ApiException\
\ as e:\n print(f\"API exception occurred: {str(e)}\")\n \
\ time.sleep(5) # Backoff before retrying\n # Catches the\
\ following error:\n # urllib3.exceptions.ProtocolError: (\"Connection\
\ broken: InvalidChunkLength\n except urllib3.exceptions.ProtocolError\
\ as e:\n print(f\"Connection broken reconnecting the watcher\
\ {str(e)}\")\n time.sleep(5) # Backoff before retrying\n \
\ finally:\n w.stop()\n\n"
image: quay.io/modh/odh-generic-data-science-notebook:v3-2024b-20241111
exec-pytorchjob-manifest-op-2:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- pytorchjob_manifest_op
command:
- sh
- -ec
- 'program_path=$(mktemp -d)
printf "%s" "$0" > "$program_path/ephemeral_component.py"
_KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"
'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef pytorchjob_manifest_op(\n model_pvc_name: str,\n input_pvc_name:\
\ str,\n output_pvc_name: str,\n name_suffix: str,\n # path_to_model:\
\ str,\n phase_num: int,\n nproc_per_node: int = 3,\n nnodes: int\
\ = 2,\n num_epochs: int = 2,\n effective_batch_size: int = 3840,\n\
\ learning_rate: float = 1e-4,\n num_warmup_steps: int = 800,\n \
\ save_samples: int = 0,\n max_batch_len: int = 20000,\n seed: int\
\ = 42,\n):\n import inspect\n import os\n import time\n\n import\
\ kubernetes\n import urllib3\n import yaml\n\n def list_phase1_final_model():\n\
\ model_dir = \"/output/phase_1/model/hf_format\"\n models\
\ = os.listdir(model_dir)\n newest_idx = max(\n (os.path.getmtime(f\"\
{model_dir}/{model}\"), i)\n for i, model in enumerate(models)\n\
\ )[-1]\n newest_model = models[newest_idx]\n return\
\ f\"{model_dir}/{newest_model}\"\n\n name = f\"train-phase-{phase_num}-{name_suffix.rstrip('-sdg')}\"\
\n\n if phase_num == 1:\n path_to_model = \"/input_model\"\n \
\ path_to_data = \"/input_data/knowledge/data.jsonl\"\n elif phase_num\
\ == 2:\n path_to_model = list_phase1_final_model()\n path_to_data\
\ = \"/input_data/skills/data.jsonl\"\n else:\n raise RuntimeError(f\"\
Unsupported value of {phase_num=}\")\n\n image = \"registry.stage.redhat.io/rhelai1/instructlab-nvidia-rhel9:1.3.1\"\
\n\n manifest = inspect.cleandoc(\n f\"\"\"\n apiVersion:\
\ kubeflow.org/v1\n kind: PyTorchJob\n metadata:\n \
\ name: {name}\n spec:\n nprocPerNode: \\\"{nproc_per_node}\\\
\"\n pytorchReplicaSpecs:\n Master:\n replicas:\
\ 1\n restartPolicy: OnFailure\n template:\n \
\ metadata:\n annotations:\n \
\ sidecar.istio.io/inject: 'false'\n spec:\n \
\ containers:\n - args:\n \
\ - |\n echo \"Running phase {phase_num}\"\
\n echo \"Using {path_to_model} model for training\"\
\n echo \"Using {path_to_data} data for training\"\
\n mkdir -p /output/phase_{phase_num}/model;\n\
\ mkdir -p /output/data;\n \
\ torchrun --nnodes {nnodes} \\\n --nproc_per_node\
\ {nproc_per_node} \\\n --node_rank \\$(RANK)\
\ \\\n --rdzv_endpoint \\$(MASTER_ADDR):\\\
$(MASTER_PORT) \\\n -m instructlab.training.main_ds\
\ \\\n --model_name_or_path={path_to_model}\
\ \\\n --data_path={path_to_data} \\\n \
\ --output_dir=/output/phase_{phase_num}/model\
\ \\\n --num_epochs={num_epochs} \\\n \
\ --effective_batch_size={effective_batch_size}\
\ \\\n --learning_rate={learning_rate} \\\n\
\ --num_warmup_steps={num_warmup_steps} \\\n\
\ --save_samples={save_samples} \\\n \
\ --log_level=INFO \\\n \
\ --max_batch_len={max_batch_len} \\\n \
\ --seed={seed} \\\n --cpu_offload_optimizer\
\ \\\n --cpu_offload_params_fsdp \\\n \
\ --distributed_training_framework fsdp \\\n \
\ --checkpoint_at_epoch\n \
\ command:\n - /bin/bash\n \
\ - '-c'\n - '--'\n image:\
\ {image}\n name: pytorch\n volumeMounts:\n\
\ - mountPath: /input_data\n \
\ name: input-data\n readOnly: true\n \
\ - mountPath: /input_model\n \
\ name: model\n readOnly: true\n \
\ - mountPath: /output\n name: output\n\
\ env:\n - name: NNODES\n \
\ value: \\\"{nnodes}\\\"\n \
\ - name: NPROC_PER_NODE\n value: \\\"{nproc_per_node}\\\
\"\n - name: XDG_CACHE_HOME\n \
\ value: /tmp\n - name: TRITON_CACHE_DIR\n\
\ value: /tmp\n - name:\
\ HF_HOME\n value: /tmp\n \