-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathL0_MergeRequest.groovy
More file actions
1419 lines (1323 loc) · 58.7 KB
/
L0_MergeRequest.groovy
File metadata and controls
1419 lines (1323 loc) · 58.7 KB
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
@Library(['bloom-jenkins-shared-lib@main', 'trtllm-jenkins-shared-lib@main']) _
import java.lang.InterruptedException
import groovy.transform.Field
import groovy.json.JsonOutput
import com.nvidia.bloom.KubernetesManager
import com.nvidia.bloom.Constants
import org.jenkinsci.plugins.workflow.cps.CpsThread
import org.jsoup.Jsoup
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils as jUtils
// LLM repository configuration
withCredentials([string(credentialsId: 'default-llm-repo', variable: 'DEFAULT_LLM_REPO')]) {
LLM_REPO = env.gitlabSourceRepoHttpUrl ? env.gitlabSourceRepoHttpUrl : "${DEFAULT_LLM_REPO}"
}
LLM_ROOT = "llm"
// LLM repository configuration
withCredentials([string(credentialsId: 'default-scan-repo', variable: 'DEFAULT_SCAN_REPO')]) {
SCAN_REPO = "${DEFAULT_SCAN_REPO}"
}
SCAN_COMMIT = "main"
SCAN_ROOT = "scan"
ARTIFACT_PATH = env.artifactPath ? env.artifactPath : "sw-tensorrt-generic/llm-artifacts/${JOB_NAME}/${BUILD_NUMBER}"
UPLOAD_PATH = env.uploadPath ? env.uploadPath : "sw-tensorrt-generic/llm-artifacts/${JOB_NAME}/${BUILD_NUMBER}"
// Container configuration
def getContainerURIs()
{
// available tags can be found in: https://urm.nvidia.com/artifactory/sw-tensorrt-docker/tensorrt-llm/
// [base_image_name]-[arch]-[os](-[python_version])-[trt_version]-[torch_install_type]-[stage]-[date]-[mr_id]
tagProps = readProperties file: "${LLM_ROOT}/jenkins/current_image_tags.properties", interpolate: true
uris = [:]
keys = [
"LLM_DOCKER_IMAGE",
"LLM_SBSA_DOCKER_IMAGE",
"LLM_ROCKYLINUX8_PY310_DOCKER_IMAGE",
"LLM_ROCKYLINUX8_PY312_DOCKER_IMAGE"
]
for (key in keys) {
uris[key] = tagProps[key]
}
return uris
}
// Stage choices
STAGE_CHOICE_NORMAL = "normal"
STAGE_CHOICE_SKIP = "skip"
STAGE_CHOICE_IGNORE = "ignore"
RELESE_CHECK_CHOICE = env.releaseCheckChoice ? env.releaseCheckChoice : STAGE_CHOICE_NORMAL
X86_TEST_CHOICE = env.x86TestChoice ? env.x86TestChoice : STAGE_CHOICE_NORMAL
SBSA_TEST_CHOICE = env.SBSATestChoice ? env.SBSATestChoice : STAGE_CHOICE_NORMAL
def gitlabParamsFromBot = [:]
if (env.gitlabTriggerPhrase)
{
gitlabParamsFromBot = readJSON text: env.gitlabTriggerPhrase, returnPojo: true
}
// "Fail Fast" feature is enabled by default for the pre-merge pipeline.
// "Fail Fast" feature is always disabled for the post-merge pipeline.
boolean enableFailFast = !(env.JOB_NAME ==~ /.*PostMerge.*/ || env.JOB_NAME ==~ /.*Dependency_Testing_TRT.*/) && !gitlabParamsFromBot.get("disable_fail_fast", false)
boolean isReleaseCheckMode = (gitlabParamsFromBot.get("run_mode", "full") == "release_check")
GEN_POST_MERGE_BUILDS_ONLY = (env.JOB_NAME?.contains("GenPostMergeBuilds") ?: false)
BUILD_STATUS_NAME = isReleaseCheckMode ? "Jenkins Release Check" : "Jenkins Full Build"
def trimForStageList(stageNameList)
{
if (stageNameList == null) {
return null
}
trimedList = []
stageNameList.each { stageName ->
trimedList.add(stageName.trim().replaceAll('\\\\', ''))
}
return trimedList
}
@Field
def REUSE_TEST = "reuse_test" // Determine if the pipeline should reuse test results in a stage from the previous pipelines.
@Field
def REUSE_STAGE_LIST = "reuse_stage_list"
@Field
def ENABLE_SKIP_TEST = "skip_test"
@Field
def TEST_STAGE_LIST = "stage_list"
@Field
def GPU_TYPE_LIST = "gpu_type"
@Field
def TEST_BACKEND = "test_backend"
@Field
def IS_POST_MERGE = "post_merge"
@Field
def ADD_MULTI_GPU_TEST = "add_multi_gpu_test"
@Field
def ENABLE_MULTI_GPU_TEST = "multi_gpu_test"
@Field
def ONLY_MULTI_GPU_TEST = "only_multi_gpu_test"
@Field
def DISABLE_MULTI_GPU_TEST = "disable_multi_gpu_test"
@Field
def EXTRA_STAGE_LIST = "extra_stage"
@Field
def MULTI_GPU_FILE_CHANGED = "multi_gpu_file_changed"
@Field
def ONLY_ONE_GROUP_CHANGED = "only_one_group_changed"
@Field
def AUTO_TRIGGER_TAG_LIST = "auto_trigger_tag_list"
@Field
def DEBUG_MODE = "debug"
@Field
def DETAILED_LOG = "detailed_log"
def testFilter = [
(REUSE_TEST): gitlabParamsFromBot.get(REUSE_TEST, null),
(REUSE_STAGE_LIST): trimForStageList(gitlabParamsFromBot.get(REUSE_STAGE_LIST, null)?.tokenize(',')),
(ENABLE_SKIP_TEST): gitlabParamsFromBot.get((ENABLE_SKIP_TEST), false),
(TEST_STAGE_LIST): trimForStageList(gitlabParamsFromBot.get((TEST_STAGE_LIST), null)?.tokenize(',')),
(GPU_TYPE_LIST): trimForStageList(gitlabParamsFromBot.get((GPU_TYPE_LIST), null)?.tokenize(',')),
(TEST_BACKEND): trimForStageList(gitlabParamsFromBot.get((TEST_BACKEND), null)?.tokenize(',')),
(IS_POST_MERGE): (env.JOB_NAME ==~ /.*PostMerge.*/) || gitlabParamsFromBot.get((IS_POST_MERGE), false),
(ADD_MULTI_GPU_TEST): gitlabParamsFromBot.get((ADD_MULTI_GPU_TEST), false),
(ONLY_MULTI_GPU_TEST): gitlabParamsFromBot.get((ONLY_MULTI_GPU_TEST), false) || gitlabParamsFromBot.get((ENABLE_MULTI_GPU_TEST), false),
(DISABLE_MULTI_GPU_TEST): gitlabParamsFromBot.get((DISABLE_MULTI_GPU_TEST), false),
(EXTRA_STAGE_LIST): trimForStageList(gitlabParamsFromBot.get((EXTRA_STAGE_LIST), null)?.tokenize(',')),
(MULTI_GPU_FILE_CHANGED): false,
(ONLY_ONE_GROUP_CHANGED): "",
(DEBUG_MODE): gitlabParamsFromBot.get(DEBUG_MODE, false),
(AUTO_TRIGGER_TAG_LIST): [],
(DETAILED_LOG): gitlabParamsFromBot.get(DETAILED_LOG, false),
]
String reuseBuild = gitlabParamsFromBot.get('reuse_build', null)
@Field
def GITHUB_PR_API_URL = "github_pr_api_url"
@Field
def CACHED_CHANGED_FILE_LIST = "cached_changed_file_list"
@Field
def ACTION_INFO = "action_info"
@Field
def IMAGE_KEY_TO_TAG = "image_key_to_tag"
@Field
def TARGET_BRANCH = "target_branch"
def globalVars = [
(GITHUB_PR_API_URL): gitlabParamsFromBot.get('github_pr_api_url', null),
(CACHED_CHANGED_FILE_LIST): null,
(ACTION_INFO): gitlabParamsFromBot.get('action_info', null),
(IMAGE_KEY_TO_TAG): [:],
(TARGET_BRANCH): gitlabParamsFromBot.get('target_branch', null),
]
// If not running all test stages in the L0 pre-merge, we will not update the GitLab status at the end.
// GenPostMergeBuilds pipelines do not update GitLab status.
boolean enableUpdateGitlabStatus =
!GEN_POST_MERGE_BUILDS_ONLY &&
!testFilter[ENABLE_SKIP_TEST] &&
!testFilter[ONLY_MULTI_GPU_TEST] &&
!testFilter[DISABLE_MULTI_GPU_TEST] &&
!testFilter[DEBUG_MODE] &&
testFilter[GPU_TYPE_LIST] == null &&
testFilter[TEST_STAGE_LIST] == null &&
testFilter[TEST_BACKEND] == null
String getShortenedJobName(String path)
{
static final nameMapping = [
"L0_MergeRequest": "l0-mr",
"L0_Custom": "l0-cus",
"L0_PostMerge": "l0-pm",
"L0_PostMergeDocker": "l0-pmd",
"L1_Custom": "l1-cus",
"L1_Nightly": "l1-nt",
"L1_Stable": "l1-stb",
]
def parts = path.split('/')
// Apply nameMapping to the last part (jobName)
def jobName = parts[-1]
boolean replaced = false
nameMapping.each { key, value ->
if (jobName.contains(key)) {
jobName = jobName.replace(key, value)
replaced = true
}
}
if (!replaced) {
jobName = jobName.length() > 7 ? jobName.substring(0, 7) : jobName
}
// Replace the last part with the transformed jobName
parts[-1] = jobName
// Rejoin the parts with '-', convert to lowercase
return parts.join('-').toLowerCase()
}
def createKubernetesPodConfig(image, type, arch = "amd64")
{
def targetCould = "kubernetes-cpu"
def selectors = """
nvidia.com/node_type: builder
kubernetes.io/os: linux"""
def containerConfig = ""
def nodeLabelPrefix = ""
def jobName = getShortenedJobName(env.JOB_NAME)
def buildID = env.BUILD_ID
def archSuffix = arch == "arm64" ? "arm" : "amd"
def jnlpImage = "urm.nvidia.com/sw-ipp-blossom-sre-docker-local/lambda/custom_jnlp_images_${archSuffix}_linux:jdk17"
switch(type)
{
case "agent":
containerConfig = """
- name: alpine
image: urm.nvidia.com/docker/alpine:latest
command: ['cat']
tty: true
resources:
requests:
cpu: '2'
memory: 5Gi
ephemeral-storage: 25Gi
limits:
cpu: '2'
memory: 5Gi
ephemeral-storage: 25Gi
imagePullPolicy: Always"""
nodeLabelPrefix = "cpu"
break
case "package":
containerConfig = """
- name: trt-llm
image: ${image}
command: ['cat']
tty: true
resources:
requests:
cpu: '2'
memory: 10Gi
ephemeral-storage: 25Gi
limits:
cpu: '2'
memory: 10Gi
ephemeral-storage: 25Gi
imagePullPolicy: Always"""
nodeLabelPrefix = "cpu"
break
}
def nodeLabel = trtllm_utils.appendRandomPostfix("${nodeLabelPrefix}---tensorrt-${jobName}-${buildID}")
def podConfig = [
cloud: targetCould,
namespace: "sw-tensorrt",
label: nodeLabel,
yaml: """
apiVersion: v1
kind: Pod
spec:
qosClass: Guaranteed
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "tensorrt/taints"
operator: DoesNotExist
- key: "tensorrt/affinity"
operator: NotIn
values:
- "core"
nodeSelector: ${selectors}
containers:
${containerConfig}
env:
- name: HOST_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: jnlp
image: ${jnlpImage}
args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
resources:
requests:
cpu: '2'
memory: 5Gi
ephemeral-storage: 25Gi
limits:
cpu: '2'
memory: 5Gi
ephemeral-storage: 25Gi
qosClass: Guaranteed
volumes:
- name: sw-tensorrt-pvc
persistentVolumeClaim:
claimName: sw-tensorrt-pvc
""".stripIndent(),
]
return podConfig
}
def echoNodeAndGpuInfo(pipeline, stageName)
{
String hostNodeName = sh(script: 'echo $HOST_NODE_NAME', returnStdout: true)
String gpuUuids = pipeline.sh(script: "nvidia-smi -q | grep \"GPU UUID\" | awk '{print \$4}' | tr '\n' ',' || true", returnStdout: true)
pipeline.echo "HOST_NODE_NAME = ${hostNodeName} ; GPU_UUIDS = ${gpuUuids} ; STAGE_NAME = ${stageName}"
}
def setupPipelineEnvironment(pipeline, testFilter, globalVars)
{
sh "env | sort"
if (!GEN_POST_MERGE_BUILDS_ONLY) {
updateGitlabCommitStatus name: "${BUILD_STATUS_NAME}", state: 'running'
}
echo "Using GitLab repo: ${LLM_REPO}."
sh "git config --global --add safe.directory \"*\""
// NB: getContainerURIs reads files in ${LLM_ROOT}/jenkins/
if (env.gitlabMergeRequestLastCommit) {
env.gitlabCommit = env.gitlabMergeRequestLastCommit
trtllm_utils.checkoutSource(LLM_REPO, env.gitlabCommit, LLM_ROOT, false, true)
} else {
branch = env.gitlabBranch ? env.gitlabBranch : "main"
trtllm_utils.checkoutSource(LLM_REPO, branch, LLM_ROOT, false, true)
checkoutCommit = sh (script: "cd ${LLM_ROOT} && git rev-parse HEAD",returnStdout: true).trim()
env.gitlabCommit = checkoutCommit
}
echo "Env.gitlabMergeRequestLastCommit: ${env.gitlabMergeRequestLastCommit}."
echo "Freeze GitLab commit. Branch: ${env.gitlabBranch}. Commit: ${env.gitlabCommit}."
testFilter[(MULTI_GPU_FILE_CHANGED)] = getMultiGpuFileChanged(pipeline, testFilter, globalVars)
testFilter[(ONLY_ONE_GROUP_CHANGED)] = getOnlyOneGroupChanged(pipeline, testFilter, globalVars)
testFilter[(AUTO_TRIGGER_TAG_LIST)] = getAutoTriggerTagList(pipeline, testFilter, globalVars)
getContainerURIs().each { k, v ->
globalVars[k] = v
}
}
def mergeWaiveList(pipeline, globalVars)
{
// Get current waive list
sh "git config --global --add safe.directory \"*\""
sh "cp ${LLM_ROOT}/tests/integration/test_lists/waives.txt ./waives_CUR_${env.gitlabCommit}.txt"
sh "cp ${LLM_ROOT}/jenkins/scripts/mergeWaiveList.py ./"
try {
// Get TOT waive list
targetBranch = env.gitlabTargetBranch ? env.gitlabTargetBranch : globalVars[TARGET_BRANCH]
echo "Target branch: ${targetBranch}"
withCredentials([string(credentialsId: 'default-llm-repo', variable: 'DEFAULT_LLM_REPO')]) {
trtllm_utils.checkoutFile(DEFAULT_LLM_REPO, targetBranch, "tests/integration/test_lists/waives.txt", ".")
}
sh "mv waives.txt waives_TOT.txt"
// Get waive list diff in current MR
def diff = getMergeRequestOneFileChanges(pipeline, globalVars, "tests/integration/test_lists/waives.txt")
// Write diff to a temporary file to avoid shell escaping issues
writeFile file: 'diff_content.txt', text: diff
// Merge waive lists
sh """
python3 mergeWaiveList.py \
--cur-waive-list=waives_CUR_${env.gitlabCommit}.txt \
--latest-waive-list=waives_TOT.txt \
--diff-file=diff_content.txt \
--output-file=waives.txt
"""
trtllm_utils.uploadArtifacts("waives*.txt", "${UPLOAD_PATH}/waive_list/")
echo "New merged test waive list: https://urm.nvidia.com/artifactory/${UPLOAD_PATH}/waive_list/waives.txt"
} catch (InterruptedException e) {
throw e
} catch (Exception e) {
catchError(
buildResult: 'SUCCESS',
stageResult: 'UNSTABLE') {
error "Merge test waive list failed. Fallback to use the default test waive list from the PR. Error: ${e.toString()}"
}
}
}
def preparation(pipeline, testFilter, globalVars)
{
image = "urm.nvidia.com/docker/golang:1.22"
setupPipelineSpec = createKubernetesPodConfig(image, "package")
trtllm_utils.launchKubernetesPod(pipeline, setupPipelineSpec, "trt-llm", {
stage("Setup Environment") {
setupPipelineEnvironment(pipeline, testFilter, globalVars)
}
stage("Merge Test Waive List") {
mergeWaiveList(pipeline, globalVars)
}
})
}
def launchReleaseCheck(pipeline)
{
stages = {
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apt-get update && apt-get install -y python3-pip")
sh "pip3 config set global.break-system-packages true"
sh "git config --global --add safe.directory \"*\""
// Step 1: Clone TRT-LLM source codes
trtllm_utils.checkoutSource(LLM_REPO, env.gitlabCommit, LLM_ROOT, false, true)
sh "cd ${LLM_ROOT} && git config --unset-all core.hooksPath"
// Step 2: Run guardwords scan
def isOfficialPostMergeJob = (env.JOB_NAME ==~ /.*PostMerge.*/)
if (env.alternativeTRT || isOfficialPostMergeJob) {
trtllm_utils.checkoutSource(SCAN_REPO, SCAN_COMMIT, SCAN_ROOT, false, true)
trtllm_utils.llmExecStepWithRetry(pipeline, script: "cd ${SCAN_ROOT} && pip3 install -e .")
try {
ignoreList = [
"*/.git/*",
"*/3rdparty/*",
"*/cpp/tensorrt_llm/deep_ep/nvshmem_src_*.txz",
"*/examples/scaffolding/contrib/mcp/weather/weather.py",
"*/tensorrt_llm_internal_cutlass_kernels_static.tar.xz"
]
sh "cd ${LLM_ROOT} && confidentiality-scan \$(find . -type f ${ignoreList.collect { "-not -path \"${it}\"" }.join(' ')}) 2>&1 | tee scan.log"
def lastLine = sh(script: "tail -n 1 ${LLM_ROOT}/scan.log", returnStdout: true).trim()
if (lastLine.toLowerCase().contains("error")) {
error "Guardwords Scan Failed."
}
} catch (Exception e) {
throw e
} finally {
trtllm_utils.uploadArtifacts("${LLM_ROOT}/scan.log", "${UPLOAD_PATH}/guardwords-scan-results/")
echo "Guardwords Scan Results: https://urm.nvidia.com/artifactory/${UPLOAD_PATH}/guardwords-scan-results/scan.log"
}
}
// Step 3: Run pre-commit checks
trtllm_utils.llmExecStepWithRetry(pipeline, script: "cd ${LLM_ROOT} && python3 -u scripts/release_check.py || (git restore . && false)")
// Step 4: Run license check
withEnv(['GONOSUMDB=*.nvidia.com']) {
withCredentials([
gitUsernamePassword(
credentialsId: 'svc_tensorrt_gitlab_read_api_token',
gitToolName: 'git-tool'
),
string(
credentialsId: 'default-git-url',
variable: 'DEFAULT_GIT_URL'
)
]) {
sh "go install ${DEFAULT_GIT_URL}/TensorRT/Infrastructure/licensechecker/cmd/license_checker@v0.3.0"
}
}
sh "cd ${LLM_ROOT}/cpp && /go/bin/license_checker -config ../jenkins/license_cpp.json include tensorrt_llm"
}
def image = "urm.nvidia.com/docker/golang:1.22"
stageName = "Release-Check"
trtllm_utils.launchKubernetesPod(pipeline, createKubernetesPodConfig(image, "package"), "trt-llm", {
stage("[${stageName}] Run") {
if (RELESE_CHECK_CHOICE == STAGE_CHOICE_SKIP) {
echo "Release Check job is skipped due to Jenkins configuration"
return
}
try {
echoNodeAndGpuInfo(pipeline, stageName)
stages()
} catch (InterruptedException e) {
throw e
} catch (Exception e) {
if (RELESE_CHECK_CHOICE == STAGE_CHOICE_IGNORE) {
catchError(
buildResult: 'SUCCESS',
stageResult: 'FAILURE') {
error "Release Check failed but ignored due to Jenkins configuration"
}
} else {
throw e
}
}
}
})
}
def getGitlabMRChangedFile(pipeline, function, filePath="") {
def result = null
def pageId = 0
withCredentials([
usernamePassword(
credentialsId: 'svc_tensorrt_gitlab_read_api_token',
usernameVariable: 'GITLAB_API_USER',
passwordVariable: 'GITLAB_API_TOKEN'
),
string(credentialsId: 'default-git-url', variable: 'DEFAULT_GIT_URL')
]) {
while(true) {
pageId += 1
def rawDataJson = pipeline.sh(
script: """
curl --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" \
--url "https://${DEFAULT_GIT_URL}/api/v4/projects/${env.gitlabMergeRequestTargetProjectId}/merge_requests/${env.gitlabMergeRequestIid}/diffs?page=${pageId}&per_page=20"
""",
returnStdout: true
)
def rawDataList = readJSON text: rawDataJson, returnPojo: true
if (function == "getOneFileChanges") {
if (result == null) {
result = ""
}
rawDataList.find { rawData ->
if (rawData.get("new_path") == filePath || rawData.get("old_path") == filePath) {
result = rawData.get("diff")
return true
}
return false
}
if (result != "") { break }
} else if (function == "getChangedFileList") {
if (result == null) {
result = []
}
rawDataList.each { rawData ->
result += [rawData.get("old_path"), rawData.get("new_path")]
}
}
if (!rawDataList) { break }
}
}
return result
}
def getGithubMRChangedFile(pipeline, githubPrApiUrl, function, filePath="") {
def result = null
def pageId = 0
withCredentials([
usernamePassword(
credentialsId: 'github-cred-trtllm-ci',
usernameVariable: 'NOT_USED_YET',
passwordVariable: 'GITHUB_API_TOKEN'
),
]) {
while(true) {
pageId += 1
def rawDataJson = pipeline.sh(
script: """
curl --header "Authorization: Bearer \${GITHUB_API_TOKEN}" \
--url "${githubPrApiUrl}/files?page=${pageId}&per_page=20"
""",
returnStdout: true
)
echo "rawDataJson: ${rawDataJson}"
def rawDataList = readJSON text: rawDataJson, returnPojo: true
if (function == "getOneFileChanges") {
if (result == null) {
result = ""
}
rawDataList.find { rawData ->
if (rawData.get("filename") == filePath || rawData.get("previous_filename") == filePath) {
result = rawData.get("patch")
return true
}
return false
}
if (result != "") { break }
} else if (function == "getChangedFileList") {
if (result == null) {
result = []
}
rawDataList.each { rawData ->
result += [rawData.get("filename"), rawData.get("previous_filename")].findAll { it }
}
}
if (!rawDataList) { break }
}
}
return result
}
def getMergeRequestChangedFileList(pipeline, globalVars) {
def isOfficialPostMergeJob = (env.JOB_NAME ==~ /.*PostMerge.*/)
if (env.alternativeTRT || isOfficialPostMergeJob) {
pipeline.echo("Force set changed file list to empty list.")
return []
}
def githubPrApiUrl = globalVars[GITHUB_PR_API_URL]
if (globalVars[CACHED_CHANGED_FILE_LIST] != null) {
return globalVars[CACHED_CHANGED_FILE_LIST]
}
try {
def changedFileList = []
if (githubPrApiUrl != null) {
changedFileList = getGithubMRChangedFile(pipeline, githubPrApiUrl, "getChangedFileList")
} else {
changedFileList = getGitlabMRChangedFile(pipeline, "getChangedFileList")
}
def changedFileListStr = changedFileList.join(",\n")
pipeline.echo("The changeset of this MR is: ${changedFileListStr}.")
globalVars[CACHED_CHANGED_FILE_LIST] = changedFileList
return globalVars[CACHED_CHANGED_FILE_LIST]
} catch (InterruptedException e) {
throw e
} catch (Exception e) {
pipeline.echo("Get merge request changed file list failed. Error: ${e.toString()}")
globalVars[CACHED_CHANGED_FILE_LIST] = []
return globalVars[CACHED_CHANGED_FILE_LIST]
}
}
def getMergeRequestOneFileChanges(pipeline, globalVars, filePath) {
// Note: This function intentionally propagates exceptions to the caller.
// If there is an error to get the changed file diff, skip merging the waive list.
def isOfficialPostMergeJob = (env.JOB_NAME ==~ /.*PostMerge.*/)
if (env.alternativeTRT || isOfficialPostMergeJob) {
pipeline.echo("Force set changed file diff to empty string.")
return ""
}
def githubPrApiUrl = globalVars[GITHUB_PR_API_URL]
def diff = ""
if (githubPrApiUrl != null) {
diff = getGithubMRChangedFile(pipeline, githubPrApiUrl, "getOneFileChanges", filePath)
} else {
diff = getGitlabMRChangedFile(pipeline, "getOneFileChanges", filePath)
}
pipeline.echo("The change of ${filePath} is: ${diff}")
return diff
}
def getAutoTriggerTagList(pipeline, testFilter, globalVars) {
def autoTriggerTagList = []
def isOfficialPostMergeJob = (env.JOB_NAME ==~ /.*PostMerge.*/)
if (env.alternativeTRT || isOfficialPostMergeJob) {
pipeline.echo("Force set auto trigger tags to empty list.")
return autoTriggerTagList
}
def changedFileList = getMergeRequestChangedFileList(pipeline, globalVars)
if (!changedFileList || changedFileList.isEmpty()) {
return autoTriggerTagList
}
def specialFileToTagMap = [
"tensorrt_llm/_torch/models/modeling_deepseekv3.py": ["-DeepSeek-"],
"tests/integration/defs/triton_server/": ["-Triton-"],
"triton_backend/": ["-Triton-"],
"cpp/kernels/fmha_v2/": ["-FMHA-"],
"tensorrt_llm/_torch/models/modeling_gpt_oss.py": ["-GptOss-"],
]
for (file in changedFileList) {
for (String key : specialFileToTagMap.keySet()) {
if (file.startsWith(key)) {
autoTriggerTagList += specialFileToTagMap[key]
}
}
}
autoTriggerTagList = autoTriggerTagList.unique()
if (!autoTriggerTagList.isEmpty()) {
pipeline.echo("Auto trigger tags detected: ${autoTriggerTagList.join(', ')}")
}
return autoTriggerTagList
}
def getMultiGpuFileChanged(pipeline, testFilter, globalVars)
{
if (testFilter[(DISABLE_MULTI_GPU_TEST)]) {
pipeline.echo("Force not run multi-GPU testing.")
return false
}
if (env.alternativeTRT || testFilter[(ADD_MULTI_GPU_TEST)] || testFilter[(ONLY_MULTI_GPU_TEST)] || testFilter[(IS_POST_MERGE)]) {
pipeline.echo("Force run multi-GPU testing.")
return true
}
def relatedFileList = [
"cpp/include/tensorrt_llm/batch_manager/",
"cpp/include/tensorrt_llm/executor/",
"cpp/include/tensorrt_llm/runtime/gptJsonConfig.h",
"cpp/include/tensorrt_llm/runtime/utils/mpiUtils.h",
"cpp/include/tensorrt_llm/runtime/utils/multiDeviceUtils.h",
"cpp/include/tensorrt_llm/runtime/worldConfig.h",
"cpp/tensorrt_llm/batch_manager/",
"cpp/tensorrt_llm/executor/",
"cpp/tensorrt_llm/executor_worker/",
"cpp/tensorrt_llm/kernels/communicationKernels/",
"cpp/tensorrt_llm/kernels/customAllReduceKernels.cu",
"cpp/tensorrt_llm/kernels/customAllReduceKernels.h",
"cpp/tensorrt_llm/kernels/gptKernels.cu",
"cpp/tensorrt_llm/kernels/gptKernels.h",
"cpp/tensorrt_llm/kernels/moe",
"cpp/tensorrt_llm/kernels/unfusedAttentionKernels.cu",
"cpp/tensorrt_llm/kernels/unfusedAttentionKernels.h",
"cpp/tensorrt_llm/kernels/userbuffers/",
"cpp/tensorrt_llm/plugins/cpSplitPlugin/cpSplitPlugin.cpp",
"cpp/tensorrt_llm/plugins/cpSplitPlugin/cpSplitPlugin.h",
"cpp/tensorrt_llm/plugins/gptAttentionCommon/gptAttentionCommon.cpp",
"cpp/tensorrt_llm/plugins/gptAttentionCommon/gptAttentionCommon.h",
"cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.cpp",
"cpp/tensorrt_llm/plugins/gptAttentionPlugin/gptAttentionPlugin.h",
"cpp/tensorrt_llm/plugins/ncclPlugin/",
"cpp/tensorrt_llm/nanobind/",
"cpp/tensorrt_llm/runtime/ipcUtils.cpp",
"cpp/tensorrt_llm/runtime/ncclCommunicator.cpp",
"cpp/tensorrt_llm/runtime/utils/mpiUtils.cpp",
"cpp/tensorrt_llm/runtime/workerPool.h",
"cpp/tensorrt_llm/runtime/worldConfig.cpp",
"cpp/tensorrt_llm/thop/allgatherOp.cpp",
"cpp/tensorrt_llm/thop/allreduceOp.cpp",
"cpp/tensorrt_llm/thop/reducescatterOp.cpp",
"cpp/tests/e2e_tests/batch_manager/",
"cpp/tests/e2e_tests/executor/",
"cpp/tests/unit_tests/multi_gpu/",
"jenkins/L0_Test.groovy",
"tensorrt_llm/_ipc_utils.py",
"tensorrt_llm/_torch/compilation/patterns/ar_residual_norm.py",
"tensorrt_llm/_torch/compilation/patterns/ub_allreduce.py",
"tensorrt_llm/_torch/custom_ops/torch_custom_ops.py",
"tensorrt_llm/_torch/custom_ops/userbuffers_custom_ops.py",
"tensorrt_llm/_torch/distributed/",
"tensorrt_llm/_torch/models/modeling_llama.py",
"tensorrt_llm/_torch/models/modeling_qwen3_next.py",
"tensorrt_llm/_torch/modules/fused_moe/",
"tensorrt_llm/_torch/pyexecutor/_util.py",
"tensorrt_llm/_torch/pyexecutor/model_engine.py",
"tensorrt_llm/_torch/pyexecutor/py_executor.py",
"tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py",
"tensorrt_llm/evaluate/json_mode_eval.py",
"tensorrt_llm/evaluate/mmlu.py",
"tensorrt_llm/executor/",
"tensorrt_llm/functional.py",
"tensorrt_llm/llmapi/",
"tensorrt_llm/mapping.py",
"tensorrt_llm/models/llama/",
"tensorrt_llm/parameter.py",
"tensorrt_llm/serve/",
"tests/integration/defs/cpp/test_multi_gpu.py",
"tests/integration/test_lists/test-db/l0_dgx_h100.yml",
"tests/integration/test_lists/test-db/l0_dgx_h200.yml",
"tests/unittest/_torch/auto_deploy/unit/multigpu",
"tests/unittest/_torch/multi_gpu/",
"tests/unittest/_torch/multi_gpu_modeling/",
"tests/unittest/disaggregated/",
"tests/unittest/llmapi/test_llm_multi_gpu.py",
"tests/unittest/llmapi/test_llm_multi_gpu_pytorch.py",
"tests/integration/defs/accuracy/test_disaggregated_serving.py",
"tests/unittest/_torch/ray_orchestrator/multi_gpu/",
"tests/integration/defs/examples/test_ray.py",
"tests/integration/defs/accuracy/test_llm_api_autodeploy.py",
"tests/unittest/llmapi/test_async_llm.py",
"docker/common/install_ucx.sh",
"docker/common/install_nixl.sh",
]
def changedFileList = getMergeRequestChangedFileList(pipeline, globalVars)
if (!changedFileList || changedFileList.isEmpty()) {
return false
}
def changedFileListStr = ","
def relatedFileChanged = false
try {
changedFileListStr = changedFileList.join(", ")
relatedFileChanged = relatedFileList.any { it ->
if (changedFileListStr.contains(it)) {
return true
}
}
}
catch (InterruptedException e)
{
throw e
}
catch (Exception e)
{
pipeline.echo("getMultiGpuFileChanged failed execution. Error: ${e.toString()}")
}
if (relatedFileChanged) {
pipeline.echo("Detect multi-GPU related files changed.")
}
return relatedFileChanged
}
def getOnlyOneGroupChanged(pipeline, testFilter, globalVars) {
def isOfficialPostMergeJob = (env.JOB_NAME ==~ /.*PostMerge.*/)
if (env.alternativeTRT || isOfficialPostMergeJob) {
pipeline.echo("Force set ONLY_ONE_GROUP_CHANGED \"\".")
return ""
}
def groupFileMap = [
"Docs": [ // TODO: Add more docs path to the list, e.g. *.md files in other directories
"docs/",
],
"PyTorch": [
"tensorrt_llm/_torch/",
"tensorrt_llm/scaffolding/",
"tests/unittest/_torch/",
"tests/unittest/scaffolding/",
"tests/unittest/llmapi/test_llm_pytorch.py",
"tests/unittest/llmapi/test_llm_multi_gpu_pytorch.py",
"tests/integration/defs/accuracy/test_llm_api_pytorch.py",
"tests/integration/defs/disaggregated/",
"examples/auto_deploy",
"examples/disaggregated",
"examples/pytorch/",
"examples/scaffolding/",
"docs/",
],
"Triton": [
"tests/integration/defs/triton_server/",
"triton_backend/",
],
]
def changedFileList = getMergeRequestChangedFileList(pipeline, globalVars)
if (!changedFileList || changedFileList.isEmpty()) {
return ""
}
for (group in groupFileMap.keySet()) {
def groupPrefixes = groupFileMap[group]
def allFilesInGroup = changedFileList.every { file ->
groupPrefixes.any { prefix -> file.startsWith(prefix) }
}
if (allFilesInGroup) {
pipeline.echo("Only ${group} files changed.")
return group
} else {
def nonGroupFile = changedFileList.find { file ->
!groupPrefixes.any { prefix -> file.startsWith(prefix) }
}
if (nonGroupFile != null) {
pipeline.echo("Found non-${group} file: ${nonGroupFile}")
}
}
}
return ""
}
def collectTestResults(pipeline, testFilter)
{
collectResultPodSpec = createKubernetesPodConfig("", "agent")
trtllm_utils.launchKubernetesPod(pipeline, collectResultPodSpec, "alpine", {
stage ("Collect Test Result") {
sh "rm -rf **/*.xml *.tar.gz"
testResultLink = "https://urm.nvidia.com/artifactory/sw-tensorrt-generic/llm-artifacts/${JOB_NAME}/${BUILD_NUMBER}/test-results"
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add --no-cache curl")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add python3")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "wget ${testResultLink}/", allowStepFailed: true)
sh "cat index.html | grep \"tar.gz\" | cut -d \"\\\"\" -f 2 > result_file_names.txt"
sh "cat result_file_names.txt"
trtllm_utils.llmExecStepWithRetry(pipeline, script: "cat result_file_names.txt | xargs -n1 -I {} wget -c -nv ${testResultLink}/{}", allowStepFailed: true)
sh "ls -l | grep \"tar.gz\" || true"
resultFileNumber = sh(script: "cat result_file_names.txt | wc -l", returnStdout: true)
resultFileDownloadedNumber = sh(script: "ls -l | grep \"tar.gz\" | wc -l", returnStdout: true)
echo "Result File Number: ${resultFileNumber}, Downloaded: ${resultFileDownloadedNumber}"
sh "find . -name results-\\*.tar.gz -type f -exec tar -zxvf {} \\; || true"
trtllm_utils.checkoutSource(LLM_REPO, env.gitlabCommit, LLM_ROOT, false, true)
if (testFilter[(IS_POST_MERGE)]) {
try {
sh "python3 llm/scripts/generate_duration.py --duration-file=new_test_duration.json"
trtllm_utils.uploadArtifacts("new_test_duration.json", "${UPLOAD_PATH}/test-results/")
} catch (Exception e) {
// No need to fail the stage if the duration file generation fails
echo "An error occurred while generating or uploading the duration file: ${e.toString()}"
}
}
junit(testResults: '**/results*.xml', allowEmptyResults : true)
} // Collect test result stage
stage("Collect Perf Sanity Test Result") {
def yamlFiles = sh(
returnStdout: true,
script: 'find . -type f -name "perf_data.yaml" 2>/dev/null || true'
).trim()
echo "Perf data yaml files: ${yamlFiles}"
if (yamlFiles) {
def yamlFileList = yamlFiles.split(/\s+/).collect { it.trim() }.findAll { it }.join(",")
echo "Found perf data files: ${yamlFileList}"
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add python3")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add py3-pip")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "pip3 config set global.break-system-packages true")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "pip3 install pyyaml requests")
sh """
python3 llm/jenkins/scripts/perf/get_pre_merge_html.py \
--input-files=${yamlFileList} \
--output-file=perf_sanity_report.html
"""
trtllm_utils.uploadArtifacts("perf_sanity_report.html", "${UPLOAD_PATH}/test-results/")
echo "Perf sanity report: https://urm.nvidia.com/artifactory/${UPLOAD_PATH}/test-results/perf_sanity_report.html"
} else {
echo "No perf_data.yaml files found."
}
} // Collect Perf Sanity Test Result stage
stage("Rerun Report") {
sh "rm -rf rerun && mkdir -p rerun"
sh "find . -type f -wholename '*/rerun_results.xml' -exec sh -c 'mv \"{}\" \"rerun/\$(basename \$(dirname \"{}\"))_rerun_results.xml\"' \\; || true"
sh "find rerun -type f"
def rerunFileCount = sh(returnStdout: true, script: 'find rerun -type f | wc -l').replaceAll("\\s","").toInteger()
if (rerunFileCount == 0) {
echo "Rerun report is skipped because there is no rerun test data file."
return
}
def xmlFiles = findFiles(glob: 'rerun/**/*.xml')
def xmlFileList = xmlFiles.collect { it.path }
def inputfiles = xmlFileList.join(',')
echo "inputfiles: ${inputfiles}"
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add python3")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add py3-pip")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "pip3 config set global.break-system-packages true")
sh """
python3 llm/jenkins/scripts/test_rerun.py \
generate_rerun_report \
--output-file=rerun/rerun_report.xml \
--input-files=${inputfiles}
"""
trtllm_utils.uploadArtifacts("rerun/rerun_report.html", "${UPLOAD_PATH}/test-results/")
echo "Rerun report: https://urm.nvidia.com/artifactory/${UPLOAD_PATH}/test-results/rerun_report.html"
catchError(
buildResult: 'SUCCESS',
stageResult: 'UNSTABLE') {
error "Some failed tests were reruned, please check the rerun report."
}
} // Rerun report stage
try {
stage("Test Coverage") {
sh "ls"
def CUR_PATH = sh(returnStdout: true, script: 'pwd').replaceAll("\\s","")
sh "echo ${CUR_PATH}"
sh "rm -rf cov && mkdir -p cov"
sh "find . -type f -wholename '*/.coverage.*' -exec mv {} cov/ \\; || true"
sh "cd cov && find . -type f"
def fileCount = sh(returnStdout: true, script: 'find cov -type f | wc -l').replaceAll("\\s","").toInteger()
if (fileCount == 0) {
echo "Test coverage is skipped because there is no test data file."
return
}
trtllm_utils.llmExecStepWithRetry(pipeline, script: "apk add py3-pip")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "pip3 config set global.break-system-packages true")
trtllm_utils.llmExecStepWithRetry(pipeline, script: "pip3 install coverage")
sh "coverage --version"
sh "cp llm/examples/openai_triton/manual_plugin/fmha_triton.py llm/examples/openai_triton/plugin_autogen/"
def coverageConfigFile = "cov/.coveragerc"
sh """
echo '[paths]' > ${coverageConfigFile}
echo 'source1=\n ${CUR_PATH}/llm/examples/\n */TensorRT-LLM/src/examples/' >> ${coverageConfigFile}
echo 'source2=\n ${CUR_PATH}/llm/tensorrt_llm/\n */tensorrt_llm/' >> ${coverageConfigFile}
cat ${coverageConfigFile}
"""
sh "cd cov && coverage combine"
sh "cd cov && find . -type f"
sh "cd cov && coverage report -i" // -i: ignore errors. Ignore the error that the source code file cannot be found.
sh "cd cov && coverage html -d test_coverage_html -i"
trtllm_utils.uploadArtifacts("cov/test_coverage_html/*", "${UPLOAD_PATH}/test-results/coverage-report/")
echo "Test coverage report: https://urm.nvidia.com/artifactory/${UPLOAD_PATH}/test-results/coverage-report/index.html"
} // Test coverage
}
catch (InterruptedException e)
{
throw e
}
catch (Exception e)
{
pipeline.echo("Test coverage failed execution.")
}
})
}
def getCommonParameters()
{
return [
'gitlabSourceRepoHttpUrl': LLM_REPO,
'gitlabCommit': env.gitlabCommit,
'artifactPath': UPLOAD_PATH,
'uploadPath': UPLOAD_PATH,
]
}
def triggerJob(jobName, parameters, jenkinsUrl = "", credentials = "")
{
if (jenkinsUrl == "" && env.localJobCredentials) {
jenkinsUrl = env.JENKINS_URL
credentials = env.localJobCredentials
}
def status = ""
if (jenkinsUrl != "") {
def jobPath = trtllm_utils.resolveFullJobName(jobName).replace('/', '/job/').substring(1)
def handle = triggerRemoteJob(
job: "${jenkinsUrl}${jobPath}/",
auth: CredentialsAuth(credentials: credentials),
parameters: trtllm_utils.toRemoteBuildParameters(parameters),
pollInterval: 60,
abortTriggeredJob: true,
)
status = handle.getBuildResult().toString()